More json information about consensus process.

Fix a bug where swithing ledgers during the consensus window caused us to use the wrong close resolution.
This commit is contained in:
JoelKatz
2012-08-06 03:57:01 -07:00
parent 7a5db15041
commit 241393410a
2 changed files with 27 additions and 2 deletions

View File

@@ -201,7 +201,7 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::pointer pre
assert(mPreviousMSeconds);
mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution(
previousLedger->getCloseResolution(), previousLedger->getCloseAgree(), previousLedger->getLedgerSeq() + 1);
mPreviousLedger->getCloseResolution(), mPreviousLedger->getCloseAgree(), previousLedger->getLedgerSeq() + 1);
mHaveCorrectLCL = previousLedger->getHash() == prevLCLHash;
@@ -464,6 +464,9 @@ void LedgerConsensus::timerEntry()
theApp->getOPs().switchLastClosedLedger(consensus, true);
mPreviousLedger = consensus;
mHaveCorrectLCL = true;
mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution(
mPreviousLedger->getCloseResolution(), mPreviousLedger->getCloseAgree(),
mPreviousLedger->getLedgerSeq() + 1);
}
else Log(lsINFO) << "We still don't have it";
}
@@ -962,9 +965,17 @@ Json::Value LedgerConsensus::getJson()
Json::Value ret(Json::objectValue);
ret["proposing"] = mProposing ? "yes" : "no";
ret["validating"] = mValidating ? "yes" : "no";
ret["synched"] = mHaveCorrectLCL ? "yes" : "no";
ret["proposers"] = static_cast<int>(mPeerPositions.size());
if (mHaveCorrectLCL)
{
ret["synched"] = "yes";
ret["ledger_seq"] = mPreviousLedger->getLedgerSeq() + 1;
ret["close_granularity"] = mCloseResolution;
}
else
ret["synched"] = "no";
switch (mState)
{
case lcsPRE_CLOSE: ret["state"] = "open"; break;

View File

@@ -72,4 +72,18 @@ std::vector<unsigned char> LedgerProposal::sign(void)
return ret;
}
Json::Value LedgerProposal::getJson() const
{
Json::Value ret = Json::objectValue;
ret["previous_ledger"] = mPreviousLedger.GetHex();
ret["transaction_hash"] = mCurrentHash.GetHex();
ret["close_time"] = mCloseTime;
ret["propose_seq"] = mProposeSeq;
if (mPublicKey.isValid())
ret["peer_id"] = mPublicKey.humanNodePublic();
return ret;
}
// vim:ts=4