From d98a931b8e5ee19f3b9ffbbb13faf2c084313aec Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 3 Aug 2012 04:40:16 -0700 Subject: [PATCH] Compute our clock offset. (We don't actually set it yet though.) --- src/LedgerConsensus.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 2e57baea9..f3243a76b 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -917,6 +917,23 @@ void LedgerConsensus::accept(SHAMap::pointer set) mState = lcsACCEPTED; sl.unlock(); + { + Log(lsINFO) << "We closed at " << boost::lexical_cast(mCloseTime); + uint64 closeTotal = mCloseTime; + int closeCount = 1; + for(std::map::iterator it = mCloseTimes.begin(), end = mCloseTimes.end(); it != end; ++it) + { + Log(lsINFO) << boost::lexical_cast(it->second) << " time votes for " + << boost::lexical_cast(it->first); + closeCount += it->second; + closeTotal += static_cast(it->first) * static_cast(it->second); + } + closeTotal += (closeCount / 2); + closeTotal /= closeCount; + int offset = static_cast(closeTotal) - static_cast(mCloseTime); + Log(lsINFO) << "Our clock offset is estimated at " << offset; + } + #ifdef DEBUG Json::StyledStreamWriter ssw; if (1)