Skip to content

Commit fc464f3

Browse files
committed
Merge branch 'feature/mergeBitrice' of gitlab.peersafe.cn:chainsql/chainsqld into feature/mergeBitrice
2 parents 423e298 + 04be99d commit fc464f3

File tree

5 files changed

+58
-27
lines changed

5 files changed

+58
-27
lines changed

src/peersafe/consensus/Adaptor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ class Adaptor
321321
bool haveCorrectLCL);
322322

323323
virtual void
324-
InitAnnounce(STInitAnnounce const& initAnnounce);
324+
InitAnnounce(
325+
STInitAnnounce const& initAnnounce,
326+
boost::optional<PublicKey> pubKey = boost::none);
325327

326328
void
327329
signMessage(protocol::TMConsensus& consensus);

src/peersafe/consensus/impl/Adaptor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Adaptor::notify(
162162
}
163163

164164
void
165-
Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce)
165+
Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce, boost::optional<PublicKey> pubKey /* = boost::none */)
166166
{
167167
Blob v = initAnnounce.getSerialized();
168168

@@ -172,7 +172,10 @@ Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce)
172172
consensus.set_msgtype(ConsensusMessageType::mtINITANNOUNCE);
173173
consensus.set_schemaid(app_.schemaId().begin(), uint256::size());
174174

175-
signAndSendMessage(consensus);
175+
if (pubKey)
176+
signAndSendMessage(*pubKey, consensus);
177+
else
178+
signAndSendMessage(consensus);
176179
}
177180

178181
void

src/peersafe/consensus/pop/PopConsensus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class PopConsensus : public ConsensusBase
181181

182182
void
183183
initAnnounce();
184+
void
185+
initAnnounceToPeer(PublicKey const& pubKey);
184186

185187
void
186188
startRoundInternal(

src/peersafe/consensus/pop/impl/PopConsensus.cpp

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,20 @@ PopConsensus::initAnnounce()
449449
adaptor_.InitAnnounce(*initAnnounce);
450450
}
451451

452+
void
453+
PopConsensus::initAnnounceToPeer(PublicKey const& pubKey)
454+
{
455+
auto seq = adaptor_.app_.getLedgerMaster().getValidLedgerIndex();
456+
auto hash = adaptor_.app_.getLedgerMaster().getValidatedLedger()->info().hash;
457+
JLOG(j_.info()) << "Init announce to other peers prevSeq=" << seq
458+
<< ", prevHash=" << hash;
459+
auto initAnnounce = std::make_shared<STInitAnnounce>(
460+
seq, hash, adaptor_.valPublic(),
461+
adaptor_.closeTime());
462+
463+
adaptor_.InitAnnounce(*initAnnounce,pubKey);
464+
}
465+
452466
void
453467
PopConsensus::startRoundInternal(
454468
NetClock::time_point const& now,
@@ -901,6 +915,9 @@ PopConsensus::peerProposalInternal(
901915
NetClock::time_point const& now,
902916
PeerPosition_t const& newPeerPos)
903917
{
918+
if (waitingForInit())
919+
return false;
920+
904921
// Nothing to do for now if we are currently working on a ledger
905922
if (phase_ == ConsensusPhase::accepted)
906923
{
@@ -1160,6 +1177,9 @@ PopConsensus::peerViewChange(
11601177
bool
11611178
PopConsensus::peerViewChangeInternal(STViewChange::ref viewChange)
11621179
{
1180+
if (waitingForInit())
1181+
return false;
1182+
11631183
JLOG(j_.info()) << "Processing peer ViewChange toView="
11641184
<< viewChange->toView() << ", PublicKey index="
11651185
<< adaptor_.getPubIndex(viewChange->nodePublic())
@@ -1175,27 +1195,27 @@ PopConsensus::peerViewChangeInternal(STViewChange::ref viewChange)
11751195

11761196
checkChangeView(viewChange->toView());
11771197

1178-
if (waitingForInit() && mode_.get() != ConsensusMode::wrongLedger)
1179-
{
1180-
if (viewChange->prevSeq() > prevLedgerSeq_)
1181-
{
1182-
JLOG(j_.warn())
1183-
<< "Init time switch to netLedger " << viewChange->prevSeq()
1184-
<< ":" << viewChange->prevHash();
1185-
prevLedgerID_ = viewChange->prevHash();
1186-
prevLedgerSeq_ = viewChange->prevSeq();
1187-
//view_ = viewChange->toView() - 1;
1188-
//checkLedger();
1189-
}
1190-
else if (
1191-
viewChange->prevSeq() == previousLedger_.seq() &&
1192-
viewChange->toView() > view_ + 1)
1193-
{
1194-
JLOG(j_.warn())
1195-
<< "Init time switch to view " << viewChange->toView() - 1;
1196-
view_ = viewChange->toView() - 1;
1197-
}
1198-
}
1198+
// if (waitingForInit() && mode_.get() != ConsensusMode::wrongLedger)
1199+
// {
1200+
// if (viewChange->prevSeq() > prevLedgerSeq_)
1201+
// {
1202+
// JLOG(j_.warn())
1203+
// << "Init time switch to netLedger " << viewChange->prevSeq()
1204+
// << ":" << viewChange->prevHash();
1205+
// prevLedgerID_ = viewChange->prevHash();
1206+
// prevLedgerSeq_ = viewChange->prevSeq();
1207+
// //view_ = viewChange->toView() - 1;
1208+
// //checkLedger();
1209+
// }
1210+
// else if (
1211+
// viewChange->prevSeq() == previousLedger_.seq() &&
1212+
// viewChange->toView() > view_ + 1)
1213+
// {
1214+
// JLOG(j_.warn())
1215+
// << "Init time switch to view " << viewChange->toView() - 1;
1216+
// view_ = viewChange->toView() - 1;
1217+
// }
1218+
// }
11991219
}
12001220

12011221
adaptor_.touchAcquringLedger(viewChange->prevHash());
@@ -1300,6 +1320,9 @@ PopConsensus::peerValidation(
13001320
bool isTrusted,
13011321
std::shared_ptr<protocol::TMConsensus> const& m)
13021322
{
1323+
if (waitingForInit())
1324+
return false;
1325+
13031326
if (m->msg().size() < 50)
13041327
{
13051328
JLOG(j_.warn()) << "Validation: Too small";
@@ -1372,7 +1395,8 @@ PopConsensus::peerInitAnnounceInternal(STInitAnnounce::ref initAnnounce)
13721395
{
13731396
if (!waitingForInit())
13741397
{
1375-
JLOG(j_.info()) << "Ignored InitAnnounce, I'm initialized";
1398+
initAnnounceToPeer(initAnnounce->nodePublic());
1399+
//JLOG(j_.info()) << "Ignored InitAnnounce, I'm initialized";
13761400
return false;
13771401
}
13781402

src/ripple/app/main/Tuning.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
namespace ripple {
2424

25-
constexpr std::size_t fullBelowTargetSize = 524288;
26-
constexpr std::chrono::seconds fullBelowExpiration = std::chrono::minutes{10};
25+
constexpr std::size_t fullBelowTargetSize = 5242880;
26+
constexpr std::chrono::seconds fullBelowExpiration = std::chrono::minutes{30};
2727

2828
} // namespace ripple
2929

0 commit comments

Comments
 (0)