Logging improvements.

This commit is contained in:
JoelKatz
2012-10-19 16:37:39 -07:00
parent 7ee9a20f40
commit 81170d7811
4 changed files with 20 additions and 16 deletions

View File

@@ -562,9 +562,9 @@ void LedgerConsensus::stateEstablish()
updateOurPositions();
if (!mHaveCloseTimeConsensus)
{
tLog(haveConsensus(), lsINFO) << "We have TX consensus but not CT consensus";
tLog(haveConsensus(false), lsINFO) << "We have TX consensus but not CT consensus";
}
else if (haveConsensus())
else if (haveConsensus(true))
{
cLog(lsINFO) << "Converge cutoff (" << mPeerPositions.size() << " participants)";
mState = lcsFINISHED;
@@ -721,7 +721,7 @@ void LedgerConsensus::updateOurPositions()
}
}
bool LedgerConsensus::haveConsensus()
bool LedgerConsensus::haveConsensus(bool forReal)
{ // FIXME: Should check for a supermajority on each disputed transaction
// counting unacquired TX sets as disagreeing
int agree = 0, disagree = 0;
@@ -743,7 +743,7 @@ bool LedgerConsensus::haveConsensus()
#endif
return ContinuousLedgerTiming::haveConsensus(mPreviousProposers, agree + disagree, agree, currentValidations,
mPreviousMSeconds, mCurrentMSeconds);
mPreviousMSeconds, mCurrentMSeconds, forReal);
}
SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool doAcquire)

View File

@@ -174,7 +174,7 @@ public:
void stateFinished();
void stateAccepted();
bool haveConsensus();
bool haveConsensus(bool forReal);
bool peerPosition(const LedgerProposal::pointer&);

View File

@@ -6,6 +6,7 @@
#include <boost/format.hpp>
#include "Log.h"
SETUP_LOG();
// NOTE: First and last times must be repeated
int ContinuousLedgerTiming::LedgerTimeResolution[] = { 10, 10, 20, 30, 60, 90, 120, 120 };
@@ -23,7 +24,7 @@ bool ContinuousLedgerTiming::shouldClose(
if ((previousMSeconds < -1000) || (previousMSeconds > 600000) ||
(currentMSeconds < -1000) || (currentMSeconds > 600000))
{
Log(lsWARNING) <<
cLog(lsWARNING) <<
boost::str(boost::format("CLC::shouldClose range Trans=%s, Prop: %d/%d, Secs: %d (last:%d)")
% (anyTransactions ? "yes" : "no") % previousProposers % proposersClosed
% currentMSeconds % previousMSeconds);
@@ -34,14 +35,14 @@ bool ContinuousLedgerTiming::shouldClose(
{ // no transactions so far this interval
if (proposersClosed > (previousProposers / 4)) // did we miss a transaction?
{
Log(lsTRACE) << "no transactions, many proposers: now (" << proposersClosed << " closed, "
cLog(lsTRACE) << "no transactions, many proposers: now (" << proposersClosed << " closed, "
<< previousProposers << " before)";
return true;
}
#if 0 // This false triggers on the genesis ledger
if (previousMSeconds > (1000 * (LEDGER_IDLE_INTERVAL + 2))) // the last ledger was very slow to close
{
Log(lsTRACE) << "was slow to converge (p=" << (previousMSeconds) << ")";
cLog(lsTRACE) << "was slow to converge (p=" << (previousMSeconds) << ")";
if (previousMSeconds < 2000)
return previousMSeconds;
return previousMSeconds - 1000;
@@ -61,10 +62,12 @@ bool ContinuousLedgerTiming::haveConsensus(
int currentAgree, // proposers who agree with us
int currentClosed, // proposers who have currently closed their ledgers
int previousAgreeTime, // how long it took to agree on the last ledger
int currentAgreeTime) // how long we've been trying to agree
int currentAgreeTime, // how long we've been trying to agree
bool forReal) // deciding whether to stop consensus process
{
Log(lsTRACE) << boost::str(boost::format("CLC::haveConsensus: prop=%d/%d agree=%d closed=%d time=%d/%d") %
currentProposers % previousProposers % currentAgree % currentClosed % currentAgreeTime % previousAgreeTime);
cLog(lsTRACE) << boost::str(boost::format("CLC::haveConsensus: prop=%d/%d agree=%d closed=%d time=%d/%d%s") %
currentProposers % previousProposers % currentAgree % currentClosed % currentAgreeTime % previousAgreeTime %
(forReal ? "" : "X"));
if (currentAgreeTime <= LEDGER_MIN_CONSENSUS)
return false;
@@ -73,7 +76,7 @@ bool ContinuousLedgerTiming::haveConsensus(
{ // Less than 3/4 of the last ledger's proposers are present, we may need more time
if (currentAgreeTime < (previousAgreeTime + LEDGER_MIN_CONSENSUS))
{
Log(lsTRACE) << "too fast, not enough proposers";
tLog(forReal, lsTRACE) << "too fast, not enough proposers";
return false;
}
}
@@ -81,19 +84,19 @@ bool ContinuousLedgerTiming::haveConsensus(
// If 80% of current proposers (plus us) agree on a set, we have consensus
if (((currentAgree * 100 + 100) / (currentProposers + 1)) > 80)
{
Log(lsTRACE) << "normal consensus";
tLog(forReal, lsTRACE) << "normal consensus";
return true;
}
// If 50% of the nodes on your UNL (minus us) have closed, you should close
if (((currentClosed * 100 - 100) / (currentProposers + 1)) > 50)
{
Log(lsTRACE) << "many closers";
tLog(forReal, lsTRACE) << "many closers";
return true;
}
// no consensus yet
Log(lsTRACE) << "no consensus";
tLog(forReal, lsTRACE) << "no consensus";
return false;
}

View File

@@ -65,7 +65,8 @@ public:
static bool haveConsensus(
int previousProposers, int currentProposers,
int currentAgree, int currentClosed,
int previousAgreeTime, int currentAgreeTime);
int previousAgreeTime, int currentAgreeTime,
bool forReal);
static int getNextLedgerTimeResolution(int previousResolution, bool previousAgree, int ledgerSeq);
};