From 5b431ea4f629a702a0bb145f023c043357fc24b5 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 10 Aug 2012 10:51:35 -0700 Subject: [PATCH] Fix the bug Jed reported where our second closed ledger has a close time in the past which crashes the CLC timing code. --- src/Ledger.cpp | 2 +- src/LedgerTiming.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Ledger.cpp b/src/Ledger.cpp index e94c6dc5b1..131e7d3b91 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -71,7 +71,7 @@ Ledger::Ledger(bool dummy, Ledger& prevLedger) : prevLedger.getCloseAgree(), mLedgerSeq); if (prevLedger.mCloseTime == 0) { - mCloseTime = theApp->getOPs().getCloseTimeNC(); + mCloseTime = theApp->getOPs().getCloseTimeNC() - mCloseResolution; mCloseTime -= (mCloseTime % mCloseResolution); } else diff --git a/src/LedgerTiming.cpp b/src/LedgerTiming.cpp index 0585abd47a..ecff1f441a 100644 --- a/src/LedgerTiming.cpp +++ b/src/LedgerTiming.cpp @@ -19,13 +19,15 @@ int ContinuousLedgerTiming::shouldClose( int previousMSeconds, // seconds the previous ledger took to reach consensus int currentMSeconds) // seconds since the previous ledger closed { - assert((previousMSeconds > -1000) && (previousMSeconds < 600000)); - assert((currentMSeconds >= -1000) && (currentMSeconds < 600000)); - -#if 0 - Log(lsTRACE) << boost::str(boost::format("CLC::shouldClose Trans=%s, Prop: %d/%d, Secs: %d (last:%d)") % - (anyTransactions ? "yes" : "no") % previousProposers % proposersClosed % currentMSeconds % previousMSeconds); -#endif + if ((previousMSeconds < -1000) || (previousMSeconds > 600000) || + (currentMSeconds < -1000) || (currentMSeconds > 600000)) + { + Log(lsFATAL) << + boost::str(boost::format("CLC::shouldClose range error Trans=%s, Prop: %d/%d, Secs: %d (last:%d)") + % (anyTransactions ? "yes" : "no") % previousProposers % proposersClosed + % currentMSeconds % previousMSeconds); + return currentMSeconds; + } if (!anyTransactions) { // no transactions so far this interval