diff --git a/src/Application.cpp b/src/Application.cpp index 42be550c15..532618bcaf 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -142,6 +142,7 @@ void Application::run() secondLedger->setAccepted(); mMasterLedger.pushLedger(secondLedger, boost::make_shared(true, boost::ref(*secondLedger))); assert(!!secondLedger->getAccountState(rootAddress)); + mNetOps.setLastCloseNetTime(secondLedger->getCloseTimeNC()); } mNetOps.setStateTimer(); diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index ecedbbdef9..ae3fc096f5 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -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()); diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 3a1387460a..78f9136f9f 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -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