Bugfix. Don't use rounded ledger timing to decide when to close an idle ledger.

This commit is contained in:
JoelKatz
2012-07-16 00:06:00 -07:00
parent 3bc0f78b0c
commit d9d1d72556
3 changed files with 10 additions and 5 deletions

View File

@@ -142,6 +142,7 @@ void Application::run()
secondLedger->setAccepted();
mMasterLedger.pushLedger(secondLedger, boost::make_shared<Ledger>(true, boost::ref(*secondLedger)));
assert(!!secondLedger->getAccountState(rootAddress));
mNetOps.setLastCloseNetTime(secondLedger->getCloseTimeNC());
}
mNetOps.setStateTimer();

View File

@@ -374,16 +374,17 @@ int LedgerConsensus::statePreClose()
bool anyTransactions = theApp->getMasterLedger().getCurrentLedger()->peekTransactionMap()->getHash().isNonZero();
int proposersClosed = mPeerPositions.size();
int sinceClose = theApp->getOPs().getNetworkTimeNC() - mPreviousLedger->getCloseTimeNC();
int sinceClose = theApp->getOPs().getNetworkTimeNC() - theApp->getOPs().getLastCloseNetTime();
if (ContinuousLedgerTiming::shouldClose(anyTransactions, mPreviousProposers, proposersClosed,
mPreviousSeconds, sinceClose) <= sinceClose)
if (sinceClose >= ContinuousLedgerTiming::shouldClose(anyTransactions, mPreviousProposers, proposersClosed,
mPreviousSeconds, sinceClose))
{ // it is time to close the ledger (swap default and wobble ledgers)
Log(lsINFO) << "CLC:: closing ledger";
mState = lcsESTABLISH;
mConsensusStartTime = boost::posix_time::second_clock::universal_time();
theApp->getMasterLedger().closeTime();
mCloseTime = theApp->getOPs().getNetworkTimeNC();
theApp->getOPs().setLastCloseNetTime(mCloseTime);
statusChange(newcoin::neCLOSING_LEDGER, mPreviousLedger);
Ledger::pointer initial = theApp->getMasterLedger().endWobble();
assert (initial->getParentHash() == mPreviousLedger->getHash());

View File

@@ -63,6 +63,7 @@ protected:
// last ledger close
int mLastCloseProposers, mLastCloseConvergeTime;
uint256 mLastCloseHash;
uint32 mLastCloseNetTime;
// XXX Split into more locks.
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
@@ -170,8 +171,10 @@ public:
void endConsensus();
void setStateTimer();
void newLCL(int proposers, int convergeTime, const uint256& ledgerHash);
int getPreviousProposers() { return mLastCloseProposers; }
int getPreviousSeconds() { return mLastCloseConvergeTime; }
int getPreviousProposers() { return mLastCloseProposers; }
int getPreviousSeconds() { return mLastCloseConvergeTime; }
uint32 getLastCloseNetTime() { return mLastCloseNetTime; }
void setLastCloseNetTime(uint32 t) { mLastCloseNetTime = t; }
Json::Value getServerInfo();
// client information retrieval functions