@@ -544,14 +544,20 @@ PopConsensus::checkLedger()
544544
545545 if (netLgr != prevLedgerID_)
546546 {
547- JLOG (j_.warn ()) << " View of consensus changed during "
548- << to_string (phase_) << " status=" << to_string (phase_)
549- << " , "
550- << " mode=" << to_string (mode_.get ());
551- JLOG (j_.warn ()) << prevLedgerID_ << " to " << netLgr;
552- JLOG (j_.warn ()) << previousLedger_.getJson ();
553- JLOG (j_.debug ()) << " State on consensus change " << getJson (true );
547+ // if (adaptor_.proposersValidated(netLgr) < adaptor_.getQuorum())
548+ // return;
549+
554550 handleWrongLedger (netLgr);
551+ if (prevLedgerID_ == netLgr)
552+ {
553+ JLOG (j_.warn ())
554+ << " View of consensus changed during " << to_string (phase_)
555+ << " status=" << to_string (phase_) << " , "
556+ << " mode=" << to_string (mode_.get ());
557+ JLOG (j_.warn ()) << prevLedgerID_ << " to " << netLgr;
558+ JLOG (j_.warn ()) << previousLedger_.getJson ();
559+ JLOG (j_.debug ()) << " State on consensus change " << getJson (true );
560+ }
555561 }
556562 else if (previousLedger_.id () != prevLedgerID_)
557563 handleWrongLedger (netLgr);
@@ -563,6 +569,20 @@ PopConsensus::handleWrongLedger(typename Ledger_t::ID const& lgrId)
563569{
564570 assert (lgrId != prevLedgerID_ || previousLedger_.id () != lgrId);
565571
572+ auto newLedger = adaptor_.acquireLedger (lgrId);
573+ if (!newLedger)
574+ return ;
575+
576+ // check compatibility with newest valid ledger.
577+ if (!adaptor_.app_ .getLedgerMaster ().isCompatible (
578+ *(newLedger->ledger_ ),
579+ j_.warn (),
580+ " Not switching preferedLedger," ))
581+ {
582+ return ;
583+ }
584+
585+
566586 // Stop proposing because we are out of sync
567587 leaveConsensus ();
568588
@@ -578,8 +598,8 @@ PopConsensus::handleWrongLedger(typename Ledger_t::ID const& lgrId)
578598 return ;
579599
580600 // we need to switch the ledger we're working from
581- if (auto newLedger = adaptor_.acquireLedger (prevLedgerID_ ))
582- {
601+ // if (auto newLedger = adaptor_.acquireLedger(lgrId ))
602+ // {
583603 JLOG (j_.warn ()) << " Have the consensus ledger when handleWrongLedger " << newLedger->seq ()
584604 << " :" << prevLedgerID_;
585605
@@ -592,11 +612,11 @@ PopConsensus::handleWrongLedger(typename Ledger_t::ID const& lgrId)
592612
593613 startRoundInternal (
594614 now_, lgrId, *newLedger, ConsensusMode::switchedLedger);
595- }
596- else
597- {
598- mode_.set (ConsensusMode::wrongLedger , adaptor_);
599- }
615+ // }
616+ // else
617+ // {
618+ // mode_.set(ConsensusMode::wrongeLdger , adaptor_);
619+ // }
600620}
601621
602622void
0 commit comments