@@ -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+
452466void
453467PopConsensus::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(
11601177bool
11611178PopConsensus::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
0 commit comments