Switch over more files to use the new Log functions

This commit is contained in:
Vinnie Falco
2013-05-22 11:04:11 -07:00
parent 8c880d9275
commit a5ab694e48
10 changed files with 396 additions and 400 deletions

View File

@@ -24,7 +24,8 @@
typedef std::map<uint160, LedgerProposal::pointer>::value_type u160_prop_pair;
typedef std::map<uint256, LCTransaction::pointer>::value_type u256_lct_pair;
SETUP_LOG();
class LedgerConensus;
DECLARE_INSTANCE(LedgerConsensus);
void LCTransaction::setVote(const uint160& peer, bool votesYes)
@@ -36,25 +37,25 @@ void LCTransaction::setVote(const uint160& peer, bool votesYes)
{ // new vote
if (votesYes)
{
cLog(lsDEBUG) << "Peer " << peer << " votes YES on " << mTransactionID;
WriteLog (lsDEBUG, LedgerConensus) << "Peer " << peer << " votes YES on " << mTransactionID;
++mYays;
}
else
{
cLog(lsDEBUG) << "Peer " << peer << " votes NO on " << mTransactionID;
WriteLog (lsDEBUG, LedgerConensus) << "Peer " << peer << " votes NO on " << mTransactionID;
++mNays;
}
}
else if (votesYes && !res.first->second)
{ // changes vote to yes
cLog(lsDEBUG) << "Peer " << peer << " now votes YES on " << mTransactionID;
WriteLog (lsDEBUG, LedgerConensus) << "Peer " << peer << " now votes YES on " << mTransactionID;
--mNays;
++mYays;
res.first->second = true;
}
else if (!votesYes && res.first->second)
{ // changes vote to no
cLog(lsDEBUG) << "Peer " << peer << " now votes NO on " << mTransactionID;
WriteLog (lsDEBUG, LedgerConensus) << "Peer " << peer << " now votes NO on " << mTransactionID;
++mNays;
--mYays;
res.first->second = false;
@@ -106,15 +107,15 @@ bool LCTransaction::updateVote(int percentTime, bool proposing)
if (newPosition == mOurVote)
{
cLog(lsINFO) <<
WriteLog (lsINFO, LedgerConensus) <<
"No change (" << (mOurVote ? "YES" : "NO") << ") : weight " << weight << ", percent " << percentTime;
cLog(lsDEBUG) << getJson();
WriteLog (lsDEBUG, LedgerConensus) << getJson();
return false;
}
mOurVote = newPosition;
cLog(lsDEBUG) << "We now vote " << (mOurVote ? "YES" : "NO") << " on " << mTransactionID;
cLog(lsDEBUG) << getJson();
WriteLog (lsDEBUG, LedgerConensus) << "We now vote " << (mOurVote ? "YES" : "NO") << " on " << mTransactionID;
WriteLog (lsDEBUG, LedgerConensus) << getJson();
return true;
}
@@ -144,8 +145,8 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
mCurrentMSeconds(0), mClosePercent(0), mHaveCloseTimeConsensus(false),
mConsensusStartTime(boost::posix_time::microsec_clock::universal_time())
{
cLog(lsDEBUG) << "Creating consensus object";
cLog(lsTRACE) << "LCL:" << previousLedger->getHash() <<", ct=" << closeTime;
WriteLog (lsDEBUG, LedgerConensus) << "Creating consensus object";
WriteLog (lsTRACE, LedgerConensus) << "LCL:" << previousLedger->getHash() <<", ct=" << closeTime;
mPreviousProposers = theApp->getOPs().getPreviousProposers();
mPreviousMSeconds = theApp->getOPs().getPreviousConvergeTime();
assert(mPreviousMSeconds);
@@ -155,13 +156,13 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
if (mValPublic.isSet() && mValPrivate.isSet() && !theApp->getOPs().isNeedNetworkLedger())
{
cLog(lsINFO) << "Entering consensus process, validating";
WriteLog (lsINFO, LedgerConensus) << "Entering consensus process, validating";
mValidating = true;
mProposing = theApp->getOPs().getOperatingMode() == NetworkOPs::omFULL;
}
else
{
cLog(lsINFO) << "Entering consensus process, watching";
WriteLog (lsINFO, LedgerConensus) << "Entering consensus process, watching";
mProposing = mValidating = false;
}
@@ -173,8 +174,8 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
if (!mHaveCorrectLCL)
{
// mProposing = mValidating = false;
cLog(lsINFO) << "Entering consensus with: " << previousLedger->getHash();
cLog(lsINFO) << "Correct LCL is: " << prevLCLHash;
WriteLog (lsINFO, LedgerConensus) << "Entering consensus with: " << previousLedger->getHash();
WriteLog (lsINFO, LedgerConensus) << "Correct LCL is: " << prevLCLHash;
}
}
else
@@ -210,7 +211,7 @@ void LedgerConsensus::checkOurValidation()
boost::make_shared<PackedMessage>(val, ripple::mtVALIDATION));
#endif
theApp->getOPs().setLastValidation(v);
cLog(lsWARNING) << "Sending partial validation";
WriteLog (lsWARNING, LedgerConensus) << "Sending partial validation";
}
void LedgerConsensus::checkLCL()
@@ -246,15 +247,15 @@ void LedgerConsensus::checkLCL()
default: status = "unknown";
}
cLog(lsWARNING) << "View of consensus changed during " << status << " (" << netLgrCount << ") status="
WriteLog (lsWARNING, LedgerConensus) << "View of consensus changed during " << status << " (" << netLgrCount << ") status="
<< status << ", " << (mHaveCorrectLCL ? "CorrectLCL" : "IncorrectLCL");
cLog(lsWARNING) << mPrevLedgerHash << " to " << netLgr;
cLog(lsWARNING) << mPreviousLedger->getJson(0);
WriteLog (lsWARNING, LedgerConensus) << mPrevLedgerHash << " to " << netLgr;
WriteLog (lsWARNING, LedgerConensus) << mPreviousLedger->getJson(0);
if (sLog(lsDEBUG))
if (ShouldLog (lsDEBUG, LedgerConensus))
{
BOOST_FOREACH(u256_cvc_pair& it, vals)
cLog(lsDEBUG) << "V: " << it.first << ", " << it.second.first;
WriteLog (lsDEBUG, LedgerConensus) << "V: " << it.first << ", " << it.second.first;
}
if (mHaveCorrectLCL)
@@ -274,7 +275,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
if (mHaveCorrectLCL && mProposing && mOurPosition)
{
cLog(lsINFO) << "Bowing out of consensus";
WriteLog (lsINFO, LedgerConensus) << "Bowing out of consensus";
mOurPosition->bowOut();
propose();
}
@@ -302,7 +303,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
}
else if (!mAcquiringLedger || (mAcquiringLedger->getHash() != mPrevLedgerHash))
{ // need to start acquiring the correct consensus LCL
cLog(lsWARNING) << "Need consensus ledger " << mPrevLedgerHash;
WriteLog (lsWARNING, LedgerConensus) << "Need consensus ledger " << mPrevLedgerHash;
if (mAcquiringLedger)
theApp->getMasterLedgerAcquire().dropLedger(mAcquiringLedger->getHash());
mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(mPrevLedgerHash, 0);
@@ -310,7 +311,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
return;
}
cLog(lsINFO) << "Have the consensus ledger " << mPrevLedgerHash;
WriteLog (lsINFO, LedgerConensus) << "Have the consensus ledger " << mPrevLedgerHash;
mHaveCorrectLCL = true;
mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution(
@@ -333,7 +334,7 @@ void LedgerConsensus::takeInitialPosition(Ledger& initialLedger)
else
initialSet = initialLedger.peekTransactionMap()->snapShot(false);
uint256 txSet = initialSet->getHash();
cLog(lsINFO) << "initial position " << txSet;
WriteLog (lsINFO, LedgerConensus) << "initial position " << txSet;
mapComplete(txSet, initialSet, false);
if (mValidating)
@@ -401,13 +402,13 @@ void LedgerConsensus::createDisputes(SHAMap::ref m1, SHAMap::ref m2)
void LedgerConsensus::mapComplete(const uint256& hash, SHAMap::ref map, bool acquired)
{
tLog(acquired, lsINFO) << "We have acquired TXS " << hash;
CondLog (acquired, lsINFO, LedgerConensus) << "We have acquired TXS " << hash;
if (!map)
{ // this is an invalid/corrupt map
mAcquired[hash] = map;
mAcquiring.erase(hash);
cLog(lsWARNING) << "A trusted node directed us to acquire an invalid TXN map";
WriteLog (lsWARNING, LedgerConensus) << "A trusted node directed us to acquire an invalid TXN map";
return;
}
assert(hash == map->getHash());
@@ -450,7 +451,7 @@ void LedgerConsensus::mapComplete(const uint256& hash, SHAMap::ref map, bool acq
adjustCount(map, peers);
else
{
tLog(acquired, lsWARNING) << "By the time we got the map " << hash << " no peers were proposing it";
CondLog (acquired, lsWARNING, LedgerConensus) << "By the time we got the map " << hash << " no peers were proposing it";
}
sendHaveTxSet(hash, true);
@@ -496,7 +497,7 @@ void LedgerConsensus::statusChange(ripple::NodeEvent event, Ledger& ledger)
PackedMessage::pointer packet = boost::make_shared<PackedMessage>(s, ripple::mtSTATUS_CHANGE);
theApp->getConnectionPool().relayMessage(NULL, packet);
cLog(lsTRACE) << "send status change to peer";
WriteLog (lsTRACE, LedgerConensus) << "send status change to peer";
}
int LedgerConsensus::startup()
@@ -552,11 +553,11 @@ void LedgerConsensus::stateEstablish()
updateOurPositions();
if (!mHaveCloseTimeConsensus)
{
tLog(haveConsensus(false), lsINFO) << "We have TX consensus but not CT consensus";
CondLog (haveConsensus(false), lsINFO, LedgerConensus) << "We have TX consensus but not CT consensus";
}
else if (haveConsensus(true))
{
cLog(lsINFO) << "Converge cutoff (" << mPeerPositions.size() << " participants)";
WriteLog (lsINFO, LedgerConensus) << "Converge cutoff (" << mPeerPositions.size() << " participants)";
mState = lcsFINISHED;
beginAccept(false);
}
@@ -579,7 +580,7 @@ void LedgerConsensus::timerEntry()
{
if (doShutdown)
{
cLog(lsFATAL) << "Shutdown requested";
WriteLog (lsFATAL, LedgerConensus) << "Shutdown requested";
theApp->stop();
}
@@ -618,7 +619,7 @@ void LedgerConsensus::updateOurPositions()
if (it->second->isStale(peerCutoff))
{ // proposal is stale
uint160 peerID = it->second->getPeerID();
cLog(lsWARNING) << "Removing stale proposal from " << peerID;
WriteLog (lsWARNING, LedgerConensus) << "Removing stale proposal from " << peerID;
BOOST_FOREACH(u256_lct_pair& it, mDisputes)
it.second->unVote(peerID);
it = mPeerPositions.erase(it);
@@ -690,23 +691,23 @@ void LedgerConsensus::updateOurPositions()
threshVote = 1;
if (threshConsensus == 0)
threshConsensus = 1;
cLog(lsINFO) << "Proposers:" << mPeerPositions.size() << " nw:" << neededWeight
WriteLog (lsINFO, LedgerConensus) << "Proposers:" << mPeerPositions.size() << " nw:" << neededWeight
<< " thrV:" << threshVote << " thrC:" << threshConsensus;
for (std::map<uint32, int>::iterator it = closeTimes.begin(), end = closeTimes.end(); it != end; ++it)
{
cLog(lsDEBUG) << "CCTime: seq" << mPreviousLedger->getLedgerSeq() + 1 << ": " <<
WriteLog (lsDEBUG, LedgerConensus) << "CCTime: seq" << mPreviousLedger->getLedgerSeq() + 1 << ": " <<
it->first << " has " << it->second << ", " << threshVote << " required";
if (it->second >= threshVote)
{
cLog(lsDEBUG) << "Close time consensus reached: " << it->first;
WriteLog (lsDEBUG, LedgerConensus) << "Close time consensus reached: " << it->first;
closeTime = it->first;
threshVote = it->second;
if (threshVote >= threshConsensus)
mHaveCloseTimeConsensus = true;
}
}
tLog(!mHaveCloseTimeConsensus, lsDEBUG) << "No CT consensus: Proposers:" << mPeerPositions.size()
CondLog (!mHaveCloseTimeConsensus, lsDEBUG, LedgerConensus) << "No CT consensus: Proposers:" << mPeerPositions.size()
<< " Proposing:" << (mProposing ? "yes" : "no") << " Thresh:" << threshConsensus << " Pos:" << closeTime;
}
@@ -722,7 +723,7 @@ void LedgerConsensus::updateOurPositions()
if (changes)
{
uint256 newHash = ourPosition->getHash();
cLog(lsINFO) << "Position change: CTime " << closeTime << ", tx " << newHash;
WriteLog (lsINFO, LedgerConensus) << "Position change: CTime " << closeTime << ", tx " << newHash;
if (mOurPosition->changePosition(newHash, closeTime))
{
if (mProposing)
@@ -744,14 +745,14 @@ bool LedgerConsensus::haveConsensus(bool forReal)
++agree;
else
{
cLog(lsDEBUG) << it.first.GetHex() << " has " << it.second->getCurrentHash().GetHex();
WriteLog (lsDEBUG, LedgerConensus) << it.first.GetHex() << " has " << it.second->getCurrentHash().GetHex();
++disagree;
}
}
}
int currentValidations = theApp->getValidations().getNodesAfter(mPrevLedgerHash);
cLog(lsDEBUG) << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree;
WriteLog (lsDEBUG, LedgerConensus) << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree;
return ContinuousLedgerTiming::haveConsensus(mPreviousProposers, agree + disagree, agree, currentValidations,
mPreviousMSeconds, mCurrentMSeconds, forReal, mConsensusFail);
@@ -826,7 +827,7 @@ void LedgerConsensus::startAcquiring(TransactionAcquire::pointer acquire)
void LedgerConsensus::propose()
{
cLog(lsTRACE) << "We propose: " <<
WriteLog (lsTRACE, LedgerConensus) << "We propose: " <<
(mOurPosition->isBowOut() ? std::string("bowOut") : mOurPosition->getCurrentHash().GetHex());
ripple::TMProposeSet prop;
@@ -847,7 +848,7 @@ void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vec
{
if (mDisputes.find(txID) != mDisputes.end())
return;
cLog(lsDEBUG) << "Transaction " << txID << " is disputed";
WriteLog (lsDEBUG, LedgerConensus) << "Transaction " << txID << " is disputed";
bool ourVote = false;
if (mOurPosition)
@@ -886,7 +887,7 @@ bool LedgerConsensus::peerPosition(LedgerProposal::ref newPosition)
uint160 peerID = newPosition->getPeerID();
if (mDeadNodes.find(peerID) != mDeadNodes.end())
{
cLog(lsINFO) << "Position from dead node: " << peerID.GetHex();
WriteLog (lsINFO, LedgerConensus) << "Position from dead node: " << peerID.GetHex();
return false;
}
@@ -901,12 +902,12 @@ bool LedgerConsensus::peerPosition(LedgerProposal::ref newPosition)
if (newPosition->getProposeSeq() == 0)
{ // new initial close time estimate
cLog(lsTRACE) << "Peer reports close time as " << newPosition->getCloseTime();
WriteLog (lsTRACE, LedgerConensus) << "Peer reports close time as " << newPosition->getCloseTime();
++mCloseTimes[newPosition->getCloseTime()];
}
else if (newPosition->getProposeSeq() == LedgerProposal::seqLeave)
{ // peer bows out
cLog(lsINFO) << "Peer bows out: " << peerID.GetHex();
WriteLog (lsINFO, LedgerConensus) << "Peer bows out: " << peerID.GetHex();
BOOST_FOREACH(u256_lct_pair& it, mDisputes)
it.second->unVote(peerID);
mPeerPositions.erase(peerID);
@@ -915,7 +916,7 @@ bool LedgerConsensus::peerPosition(LedgerProposal::ref newPosition)
}
cLog(lsTRACE) << "Processing peer proposal "
WriteLog (lsTRACE, LedgerConensus) << "Processing peer proposal "
<< newPosition->getProposeSeq() << "/" << newPosition->getCurrentHash();
currentPosition = newPosition;
@@ -927,7 +928,7 @@ bool LedgerConsensus::peerPosition(LedgerProposal::ref newPosition)
}
else
{
cLog(lsDEBUG) << "Don't have tx set for peer";
WriteLog (lsDEBUG, LedgerConensus) << "Don't have tx set for peer";
// BOOST_FOREACH(u256_lct_pair& it, mDisputes)
// it.second->unVote(peerID);
}
@@ -961,7 +962,7 @@ SMAddNode LedgerConsensus::peerGaveNodes(Peer::ref peer, const uint256& setHash,
boost::unordered_map<uint256, TransactionAcquire::pointer>::iterator acq = mAcquiring.find(setHash);
if (acq == mAcquiring.end())
{
cLog(lsDEBUG) << "Got TX data for set no longer acquiring: " << setHash;
WriteLog (lsDEBUG, LedgerConensus) << "Got TX data for set no longer acquiring: " << setHash;
return SMAddNode();
}
TransactionAcquire::pointer set = acq->second; // We must keep the set around during the function
@@ -973,7 +974,7 @@ void LedgerConsensus::beginAccept(bool synchronous)
SHAMap::pointer consensusSet = mAcquired[mOurPosition->getCurrentHash()];
if (!consensusSet)
{
cLog(lsFATAL) << "We don't have a consensus set";
WriteLog (lsFATAL, LedgerConensus) << "We don't have a consensus set";
abort();
return;
}
@@ -1003,7 +1004,7 @@ void LedgerConsensus::playbackProposals()
proposal->setPrevLedger(mPrevLedgerHash);
if (proposal->checkSign())
{
cLog(lsINFO) << "Applying stored proposal";
WriteLog (lsINFO, LedgerConensus) << "Applying stored proposal";
relay = peerPosition(proposal);
}
}
@@ -1012,13 +1013,13 @@ void LedgerConsensus::playbackProposals()
if (relay)
{
cLog(lsWARNING) << "We should do delayed relay of this proposal, but we cannot";
WriteLog (lsWARNING, LedgerConensus) << "We should do delayed relay of this proposal, but we cannot";
}
#if 0 // FIXME: We can't do delayed relay because we don't have the signature
std::set<uint64> peers
if (relay && theApp->getSuppression().swapSet(proposal.getSuppress(), set, SF_RELAYED))
{
cLog(lsDEBUG) << "Stored proposal delayed relay";
WriteLog (lsDEBUG, LedgerConensus) << "Stored proposal delayed relay";
ripple::TMProposeSet set;
set.set_proposeseq
set.set_currenttxhash(, 256 / 8);
@@ -1047,10 +1048,10 @@ int LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTrans
if (theApp->isNewFlag(txn->getTransactionID(), SF_SIGGOOD))
parms = static_cast<TransactionEngineParams>(parms | tapNO_CHECK_SIGN);
cLog(lsDEBUG) << "TXN " << txn->getTransactionID()
WriteLog (lsDEBUG, LedgerConensus) << "TXN " << txn->getTransactionID()
<< (openLedger ? " open" : " closed")
<< (retryAssured ? "/retry" : "/final");
cLog(lsTRACE) << txn->getJson(0);
WriteLog (lsTRACE, LedgerConensus) << txn->getJson(0);
#ifndef TRUST_NETWORK
try
@@ -1061,17 +1062,17 @@ int LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTrans
TER result = engine.applyTransaction(*txn, parms, didApply);
if (didApply)
{
cLog(lsDEBUG) << "Transaction success: " << transHuman(result);
WriteLog (lsDEBUG, LedgerConensus) << "Transaction success: " << transHuman(result);
return LCAT_SUCCESS;
}
if (isTefFailure(result) || isTemMalformed(result) || isTelLocal(result))
{ // failure
cLog(lsDEBUG) << "Transaction failure: " << transHuman(result);
WriteLog (lsDEBUG, LedgerConensus) << "Transaction failure: " << transHuman(result);
return LCAT_FAIL;
}
cLog(lsDEBUG) << "Transaction retry: " << transHuman(result);
WriteLog (lsDEBUG, LedgerConensus) << "Transaction retry: " << transHuman(result);
assert(!ledger->hasTransaction(txn->getTransactionID()));
return LCAT_RETRY;
@@ -1079,7 +1080,7 @@ int LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTrans
}
catch (...)
{
cLog(lsWARNING) << "Throws";
WriteLog (lsWARNING, LedgerConensus) << "Throws";
return false;
}
#endif
@@ -1093,7 +1094,7 @@ void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger
for (SHAMapItem::pointer item = set->peekFirstItem(); !!item; item = set->peekNextItem(item->getTag()))
if (!checkLedger->hasTransaction(item->getTag()))
{
cLog(lsINFO) << "Processing candidate transaction: " << item->getTag();
WriteLog (lsINFO, LedgerConensus) << "Processing candidate transaction: " << item->getTag();
#ifndef TRUST_NETWORK
try
{
@@ -1106,7 +1107,7 @@ void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger
}
catch (...)
{
cLog(lsWARNING) << " Throws";
WriteLog (lsWARNING, LedgerConensus) << " Throws";
}
#endif
}
@@ -1116,7 +1117,7 @@ void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger
for (int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
{
cLog(lsDEBUG) << "Pass: " << pass << " Txns: " << failedTransactions.size()
WriteLog (lsDEBUG, LedgerConensus) << "Pass: " << pass << " Txns: " << failedTransactions.size()
<< (certainRetry ? " retriable" : " final");
changes = 0;
@@ -1142,11 +1143,11 @@ void LedgerConsensus::applyTransactions(SHAMap::ref set, Ledger::ref applyLedger
}
catch (...)
{
cLog(lsWARNING) << "Transaction throws";
WriteLog (lsWARNING, LedgerConensus) << "Transaction throws";
it = failedTransactions.erase(it);
}
}
cLog(lsDEBUG) << "Pass: " << pass << " finished " << changes << " changes";
WriteLog (lsDEBUG, LedgerConensus) << "Pass: " << pass << " finished " << changes << " changes";
// A non-retry pass made no changes
if (!changes && !certainRetry)
@@ -1179,10 +1180,10 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
closeTime = mPreviousLedger->getCloseTimeNC() + 1;
}
cLog(lsDEBUG) << "Report: Prop=" << (mProposing ? "yes" : "no") << " val=" << (mValidating ? "yes" : "no") <<
WriteLog (lsDEBUG, LedgerConensus) << "Report: Prop=" << (mProposing ? "yes" : "no") << " val=" << (mValidating ? "yes" : "no") <<
" corLCL=" << (mHaveCorrectLCL ? "yes" : "no") << " fail="<< (mConsensusFail ? "yes" : "no");
cLog(lsDEBUG) << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->getLedgerSeq();
cLog(lsDEBUG) << "Report: TxSt = " << set->getHash() << ", close " << closeTime << (closeTimeCorrect ? "" : "X");
WriteLog (lsDEBUG, LedgerConensus) << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->getLedgerSeq();
WriteLog (lsDEBUG, LedgerConensus) << "Report: TxSt = " << set->getHash() << ", close " << closeTime << (closeTimeCorrect ? "" : "X");
CanonicalTXSet failedTransactions(set->getHash());
@@ -1190,7 +1191,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
newLCL->peekTransactionMap()->armDirty();
newLCL->peekAccountStateMap()->armDirty();
cLog(lsDEBUG) << "Applying consensus set transactions to the last closed ledger";
WriteLog (lsDEBUG, LedgerConensus) << "Applying consensus set transactions to the last closed ledger";
applyTransactions(set, newLCL, newLCL, failedTransactions, false);
newLCL->updateSkipList();
newLCL->setClosed();
@@ -1200,23 +1201,23 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
// write out dirty nodes (temporarily done here) Most come before setAccepted
int fc;
while ((fc = SHAMap::flushDirty(*acctNodes, 256, hotACCOUNT_NODE, newLCL->getLedgerSeq())) > 0)
{ cLog(lsTRACE) << "Flushed " << fc << " dirty state nodes"; }
{ WriteLog (lsTRACE, LedgerConensus) << "Flushed " << fc << " dirty state nodes"; }
while ((fc = SHAMap::flushDirty(*txnNodes, 256, hotTRANSACTION_NODE, newLCL->getLedgerSeq())) > 0)
{ cLog(lsTRACE) << "Flushed " << fc << " dirty transaction nodes"; }
{ WriteLog (lsTRACE, LedgerConensus) << "Flushed " << fc << " dirty transaction nodes"; }
newLCL->setAccepted(closeTime, mCloseResolution, closeTimeCorrect);
newLCL->updateHash();
newLCL->setImmutable();
cLog(lsDEBUG) << "Report: NewL = " << newLCL->getHash() << ":" << newLCL->getLedgerSeq();
WriteLog (lsDEBUG, LedgerConensus) << "Report: NewL = " << newLCL->getHash() << ":" << newLCL->getLedgerSeq();
uint256 newLCLHash = newLCL->getHash();
if (sLog(lsTRACE))
if (ShouldLog (lsTRACE, LedgerConensus))
{
cLog(lsTRACE) << "newLCL";
WriteLog (lsTRACE, LedgerConensus) << "newLCL";
Json::Value p;
newLCL->addJson(p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
cLog(lsTRACE) << p;
WriteLog (lsTRACE, LedgerConensus) << p;
}
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
@@ -1241,10 +1242,10 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
val.set_validation(&validation[0], validation.size());
int j = theApp->getConnectionPool().relayMessage(NULL,
boost::make_shared<PackedMessage>(val, ripple::mtVALIDATION));
cLog(lsINFO) << "CNF Val " << newLCLHash << " to " << j << " peers";
WriteLog (lsINFO, LedgerConensus) << "CNF Val " << newLCLHash << " to " << j << " peers";
}
else
cLog(lsINFO) << "CNF newLCL " << newLCLHash;
WriteLog (lsINFO, LedgerConensus) << "CNF newLCL " << newLCLHash;
Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL));
ScopedLock sl( theApp->getLedgerMaster().getLock());
@@ -1257,7 +1258,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
{ // we voted NO
try
{
cLog(lsDEBUG) << "Test applying disputed transaction that did not get in";
WriteLog (lsDEBUG, LedgerConensus) << "Test applying disputed transaction that did not get in";
SerializerIterator sit(it.second->peekTransaction());
SerializedTransaction::pointer txn = boost::make_shared<SerializedTransaction>(boost::ref(sit));
if (applyTransaction(engine, txn, newOL, true, false))
@@ -1265,12 +1266,12 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
}
catch (...)
{
cLog(lsDEBUG) << "Failed to apply transaction we voted NO on";
WriteLog (lsDEBUG, LedgerConensus) << "Failed to apply transaction we voted NO on";
}
}
}
cLog(lsDEBUG) << "Applying transactions from current open ledger";
WriteLog (lsDEBUG, LedgerConensus) << "Applying transactions from current open ledger";
applyTransactions(theApp->getLedgerMaster().getCurrentLedger()->peekTransactionMap(), newOL, newLCL,
failedTransactions, true);
theApp->getLedgerMaster().pushLedger(newLCL, newOL, !mConsensusFail);
@@ -1280,12 +1281,12 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
if (mValidating)
{ // see how close our close time is to other node's close time reports
cLog(lsINFO) << "We closed at " << boost::lexical_cast<std::string>(mCloseTime);
WriteLog (lsINFO, LedgerConensus) << "We closed at " << boost::lexical_cast<std::string>(mCloseTime);
uint64 closeTotal = mCloseTime;
int closeCount = 1;
for (std::map<uint32, int>::iterator it = mCloseTimes.begin(), end = mCloseTimes.end(); it != end; ++it)
{ // FIXME: Use median, not average
cLog(lsINFO) << boost::lexical_cast<std::string>(it->second) << " time votes for "
WriteLog (lsINFO, LedgerConensus) << boost::lexical_cast<std::string>(it->second) << " time votes for "
<< boost::lexical_cast<std::string>(it->first);
closeCount += it->second;
closeTotal += static_cast<uint64>(it->first) * static_cast<uint64>(it->second);
@@ -1293,7 +1294,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
closeTotal += (closeCount / 2);
closeTotal /= closeCount;
int offset = static_cast<int>(closeTotal) - static_cast<int>(mCloseTime);
cLog(lsINFO) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
WriteLog (lsINFO, LedgerConensus) << "Our close offset is estimated at " << offset << " (" << closeCount << ")";
theApp->getOPs().closeTimeOffset(offset);
}
@@ -1306,12 +1307,12 @@ void LedgerConsensus::endConsensus()
void LedgerConsensus::simulate()
{
cLog(lsINFO) << "Simulating consensus";
WriteLog (lsINFO, LedgerConensus) << "Simulating consensus";
closeLedger();
mCurrentMSeconds = 100;
beginAccept(true);
endConsensus();
cLog(lsINFO) << "Simulation complete";
WriteLog (lsINFO, LedgerConensus) << "Simulation complete";
}
Json::Value LedgerConsensus::getJson(bool full)