mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use simple logging system to timestamp/filter log messages.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "NetworkOPs.h"
|
||||
#include "LedgerTiming.h"
|
||||
#include "SerializedValidation.h"
|
||||
#include "Log.h"
|
||||
|
||||
TransactionAcquire::TransactionAcquire(const uint256& hash) : PeerSet(hash, 1), mHaveRoot(false)
|
||||
{
|
||||
@@ -151,8 +152,8 @@ int LCTransaction::getAgreeLevel()
|
||||
LedgerConsensus::LedgerConsensus(Ledger::pointer previousLedger, uint32 closeTime)
|
||||
: mState(lcsPRE_CLOSE), mCloseTime(closeTime), mPreviousLedger(previousLedger)
|
||||
{
|
||||
std::cerr << "Creating consensus object" << std::endl;
|
||||
std::cerr << "LCL:" << previousLedger->getHash().GetHex() <<", ct=" << closeTime << std::endl;
|
||||
Log(lsDEBUG) << "Creating consensus object";
|
||||
Log(lsTRACE) << "LCL:" << previousLedger->getHash().GetHex() <<", ct=" << closeTime;
|
||||
}
|
||||
|
||||
void LedgerConsensus::takeInitialPosition(Ledger::pointer initialLedger)
|
||||
@@ -251,7 +252,7 @@ void LedgerConsensus::statusChange(newcoin::NodeEvent event, Ledger::pointer led
|
||||
|
||||
void LedgerConsensus::abort()
|
||||
{
|
||||
std::cerr << "consensus aborted" << std::endl;
|
||||
Log(lsWARNING) << "consensus aborted";
|
||||
mState = lcsABORTED;
|
||||
}
|
||||
|
||||
@@ -274,7 +275,7 @@ int LedgerConsensus::statePostClose(int secondsSinceClose)
|
||||
{ // we are in the transaction wobble time
|
||||
if (secondsSinceClose > LEDGER_WOBBLE_TIME)
|
||||
{
|
||||
std::cerr << "Wobble is over, it's consensus time" << std::endl;
|
||||
Log(lsINFO) << "Wobble is over, it's consensus time";
|
||||
mState = lcsESTABLISH;
|
||||
}
|
||||
return 1;
|
||||
@@ -285,7 +286,7 @@ int LedgerConsensus::stateEstablish(int secondsSinceClose)
|
||||
updateOurPositions(secondsSinceClose);
|
||||
if (secondsSinceClose > LEDGER_CONVERGE)
|
||||
{
|
||||
std::cerr << "Converge cutoff" << std::endl;
|
||||
Log(lsINFO) << "Converge cutoff";
|
||||
mState = lcsCUTOFF;
|
||||
}
|
||||
return 1;
|
||||
@@ -296,7 +297,7 @@ int LedgerConsensus::stateCutoff(int secondsSinceClose)
|
||||
bool haveConsensus = updateOurPositions(secondsSinceClose);
|
||||
if (haveConsensus || (secondsSinceClose > LEDGER_FORCE_CONVERGE))
|
||||
{
|
||||
std::cerr << "Consensus complete (" << haveConsensus << ")" << std::endl;
|
||||
Log(lsINFO) << "Consensus complete (" << haveConsensus << ")";
|
||||
mState = lcsFINISHED;
|
||||
beginAccept();
|
||||
}
|
||||
@@ -369,7 +370,7 @@ bool LedgerConsensus::updateOurPositions(int sinceClose)
|
||||
|
||||
if (changes)
|
||||
{
|
||||
std::cerr << "We change our position" << std::endl;
|
||||
Log(lsINFO) << "We change our position";
|
||||
uint256 newHash = ourPosition->getHash();
|
||||
mOurPosition->changePosition(newHash);
|
||||
propose(addedTx, removedTx);
|
||||
@@ -402,7 +403,7 @@ SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool do
|
||||
|
||||
void LedgerConsensus::closeLedger()
|
||||
{
|
||||
std::cerr << "Closing ledger" << std::endl;
|
||||
Log(lsINFO) << "Closing ledger";
|
||||
Ledger::pointer initial = theApp->getMasterLedger().getCurrentLedger();
|
||||
statusChange(newcoin::neCLOSING_LEDGER, initial);
|
||||
takeInitialPosition(initial);
|
||||
@@ -435,7 +436,7 @@ void LedgerConsensus::startAcquiring(TransactionAcquire::pointer acquire)
|
||||
|
||||
void LedgerConsensus::propose(const std::vector<uint256>& added, const std::vector<uint256>& removed)
|
||||
{
|
||||
std::cerr << "We propose: " << mOurPosition->getCurrentHash().GetHex() << std::endl;
|
||||
Log(lsDEBUG) << "We propose: " << mOurPosition->getCurrentHash().GetHex();
|
||||
newcoin::TMProposeSet prop;
|
||||
prop.set_currenttxhash(mOurPosition->getCurrentHash().begin(), 256 / 8);
|
||||
prop.set_prevclosedhash(mOurPosition->getPrevLedger().begin(), 256 / 8);
|
||||
@@ -479,9 +480,7 @@ bool LedgerConsensus::peerPosition(LedgerProposal::pointer newPosition)
|
||||
{
|
||||
if (newPosition->getPrevLedger() != mPreviousLedger->getHash())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Peer sends proposal with wrong previous ledger" << std::endl;
|
||||
#endif
|
||||
Log(lsWARNING) << "Peer sends proposal with wrong previous ledger";
|
||||
return false;
|
||||
}
|
||||
LedgerProposal::pointer& currentPosition = mPeerPositions[newPosition->getPeerID()];
|
||||
@@ -496,7 +495,7 @@ bool LedgerConsensus::peerPosition(LedgerProposal::pointer newPosition)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
std::cerr << "Peer changes position" << std::endl;
|
||||
Log(lsINFO) << "Peer changes position";
|
||||
currentPosition = newPosition;
|
||||
SHAMap::pointer set = getTransactionTree(newPosition->getCurrentHash(), true);
|
||||
if (set)
|
||||
@@ -542,7 +541,7 @@ void LedgerConsensus::beginAccept()
|
||||
SHAMap::pointer consensusSet = mComplete[mOurPosition->getCurrentHash()];
|
||||
if (!consensusSet)
|
||||
{
|
||||
std::cerr << "We don't have our own set" << std::endl;
|
||||
Log(lsFATAL) << "We don't have our own set";
|
||||
assert(false);
|
||||
abort();
|
||||
return;
|
||||
@@ -565,7 +564,7 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led
|
||||
SHAMapItem::pointer item = set->peekFirstItem();
|
||||
while (item)
|
||||
{
|
||||
std::cerr << "Processing candidate transaction: " << item->getTag().GetHex() << std::endl;
|
||||
Log(lsINFO) << "Processing candidate transaction: " << item->getTag().GetHex();
|
||||
try
|
||||
{
|
||||
SerializerIterator sit(item->peekSerializer());
|
||||
@@ -573,24 +572,24 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led
|
||||
TransactionEngineResult result = engine.applyTransaction(*txn, tepNO_CHECK_FEE);
|
||||
if (result > 0)
|
||||
{
|
||||
std::cerr << " retry" << std::endl;
|
||||
Log(lsINFO) << " retry";
|
||||
assert(!ledger->hasTransaction(item->getTag()));
|
||||
failedTransactions.push_back(txn);
|
||||
}
|
||||
else if (result == 0)
|
||||
{
|
||||
std::cerr << " success" << std::endl;
|
||||
Log(lsDEBUG) << " success";
|
||||
assert(ledger->hasTransaction(item->getTag()));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << " hard fail" << std::endl;
|
||||
Log(lsINFO) << " hard fail";
|
||||
assert(!ledger->hasTransaction(item->getTag()));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << " Throws" << std::endl;
|
||||
Log(lsWARNING) << " Throws";
|
||||
}
|
||||
item = set->peekNextItem(item->getTag());
|
||||
}
|
||||
@@ -617,7 +616,7 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << " Throws" << std::endl;
|
||||
Log(lsWARNING) << " Throws";
|
||||
failedTransactions.erase(it++);
|
||||
}
|
||||
}
|
||||
@@ -626,7 +625,7 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led
|
||||
|
||||
void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
{
|
||||
std::cerr << "Computing new LCL based on network consensus" << std::endl;
|
||||
Log(lsINFO) << "Computing new LCL based on network consensus";
|
||||
Ledger::pointer newLCL = boost::make_shared<Ledger>(mPreviousLedger);
|
||||
|
||||
std::deque<SerializedTransaction::pointer> failedTransactions;
|
||||
@@ -651,7 +650,7 @@ void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
newcoin::TMValidation val;
|
||||
val.set_validation(&validation[0], validation.size());
|
||||
theApp->getConnectionPool().relayMessage(NULL, boost::make_shared<PackedMessage>(val, newcoin::mtVALIDATION));
|
||||
std::cerr << "Validation sent" << std::endl;
|
||||
Log(lsINFO) << "Validation sent";
|
||||
}
|
||||
|
||||
void LedgerConsensus::endConsensus()
|
||||
|
||||
Reference in New Issue
Block a user