mirror of
https://github.com/Xahau/xahaud.git
synced 2026-09-27 23:48:05 +00:00
fix(consensus): serialize consensus phase publication
This commit is contained in:
@@ -383,6 +383,11 @@ public:
|
||||
reportFeeChange() override;
|
||||
void
|
||||
reportConsensusStateChange(ConsensusPhase phase);
|
||||
void
|
||||
reportConsensusStateChangeIfNeeded(
|
||||
ConsensusPhase phase,
|
||||
std::unique_ptr<std::stringstream> const& clog,
|
||||
bool logPhase);
|
||||
|
||||
void
|
||||
updateLocalTx(ReadView const& view) override;
|
||||
@@ -674,7 +679,8 @@ private:
|
||||
|
||||
RCLConsensus mConsensus;
|
||||
|
||||
ConsensusPhase mLastConsensusPhase;
|
||||
std::mutex lastConsensusPhaseMutex_;
|
||||
ConsensusPhase mLastConsensusPhase{ConsensusPhase::open};
|
||||
|
||||
LedgerMaster& m_ledgerMaster;
|
||||
|
||||
@@ -1010,14 +1016,8 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
|
||||
mConsensus.timerEntry(app_.timeKeeper().closeTime(), clog.ss());
|
||||
|
||||
CLOG(clog.ss()) << "consensus phase " << to_string(mLastConsensusPhase);
|
||||
const ConsensusPhase currPhase = mConsensus.phase();
|
||||
if (mLastConsensusPhase != currPhase)
|
||||
{
|
||||
reportConsensusStateChange(currPhase);
|
||||
mLastConsensusPhase = currPhase;
|
||||
CLOG(clog.ss()) << " changed to " << to_string(mLastConsensusPhase);
|
||||
}
|
||||
reportConsensusStateChangeIfNeeded(currPhase, clog.ss(), true);
|
||||
CLOG(clog.ss()) << ". ";
|
||||
|
||||
setHeartbeatTimer();
|
||||
@@ -2094,11 +2094,7 @@ NetworkOPsImp::beginConsensus(
|
||||
clog);
|
||||
|
||||
const ConsensusPhase currPhase = mConsensus.phase();
|
||||
if (mLastConsensusPhase != currPhase)
|
||||
{
|
||||
reportConsensusStateChange(currPhase);
|
||||
mLastConsensusPhase = currPhase;
|
||||
}
|
||||
reportConsensusStateChangeIfNeeded(currPhase, clog, false);
|
||||
|
||||
JLOG(m_journal.debug()) << "Initiating consensus engine";
|
||||
return true;
|
||||
@@ -3225,6 +3221,24 @@ NetworkOPsImp::reportConsensusStateChange(ConsensusPhase phase)
|
||||
[this, phase]() { pubConsensus(phase); });
|
||||
}
|
||||
|
||||
void
|
||||
NetworkOPsImp::reportConsensusStateChangeIfNeeded(
|
||||
ConsensusPhase phase,
|
||||
std::unique_ptr<std::stringstream> const& clog,
|
||||
bool logPhase)
|
||||
{
|
||||
std::scoped_lock const lock(lastConsensusPhaseMutex_);
|
||||
if (logPhase)
|
||||
CLOG(clog) << "consensus phase " << to_string(mLastConsensusPhase);
|
||||
if (mLastConsensusPhase != phase)
|
||||
{
|
||||
reportConsensusStateChange(phase);
|
||||
mLastConsensusPhase = phase;
|
||||
if (logPhase)
|
||||
CLOG(clog) << " changed to " << to_string(mLastConsensusPhase);
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
NetworkOPsImp::updateLocalTx(ReadView const& view)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user