Cleanups and simplfications.

This commit is contained in:
JoelKatz
2012-09-03 01:47:03 -07:00
parent b950877758
commit d5fe3261ab
10 changed files with 76 additions and 73 deletions

View File

@@ -23,7 +23,7 @@ bool HashedObjectStore::store(HashedObjectType type, uint32 index,
if (mCache.touch(hash)) if (mCache.touch(hash))
{ {
#ifdef HS_DEBUG #ifdef HS_DEBUG
Log(lsTRACE) << "HOS: " << hash.GetHex() << " store: incache"; Log(lsTRACE) << "HOS: " << hash << " store: incache";
#endif #endif
return false; return false;
} }
@@ -94,7 +94,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
obj = mCache.fetch(hash); obj = mCache.fetch(hash);
if (obj) if (obj)
{ {
Log(lsTRACE) << "HOS: " << hash.GetHex() << " fetch: incache"; Log(lsTRACE) << "HOS: " << hash << " fetch: incache";
return obj; return obj;
} }
} }
@@ -113,7 +113,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
if (!db->executeSQL(sql) || !db->startIterRows()) if (!db->executeSQL(sql) || !db->startIterRows())
{ {
Log(lsTRACE) << "HOS: " << hash.GetHex() << " fetch: not in db"; Log(lsTRACE) << "HOS: " << hash << " fetch: not in db";
return HashedObject::pointer(); return HashedObject::pointer();
} }
@@ -145,7 +145,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
obj = boost::make_shared<HashedObject>(htype, index, data, hash); obj = boost::make_shared<HashedObject>(htype, index, data, hash);
mCache.canonicalize(hash, obj); mCache.canonicalize(hash, obj);
} }
Log(lsTRACE) << "HOS: " << hash.GetHex() << " fetch: in db"; Log(lsTRACE) << "HOS: " << hash << " fetch: in db";
return obj; return obj;
} }

View File

@@ -72,7 +72,7 @@ void PeerSet::invokeOnTimer()
if (!mProgress) if (!mProgress)
{ {
++mTimeouts; ++mTimeouts;
Log(lsWARNING) << "Timeout " << mTimeouts << " acquiring " << mHash.GetHex(); Log(lsWARNING) << "Timeout " << mTimeouts << " acquiring " << mHash;
} }
else else
mProgress = false; mProgress = false;
@@ -93,7 +93,7 @@ LedgerAcquire::LedgerAcquire(const uint256& hash) : PeerSet(hash, LEDGER_ACQUIRE
mHaveBase(false), mHaveState(false), mHaveTransactions(false), mAborted(false), mSignaled(false) mHaveBase(false), mHaveState(false), mHaveTransactions(false), mAborted(false), mSignaled(false)
{ {
#ifdef LA_DEBUG #ifdef LA_DEBUG
Log(lsTRACE) << "Acquiring ledger " << mHash.GetHex(); Log(lsTRACE) << "Acquiring ledger " << mHash;
#endif #endif
} }
@@ -118,7 +118,7 @@ void LedgerAcquire::done()
return; return;
mSignaled = true; mSignaled = true;
#ifdef LA_DEBUG #ifdef LA_DEBUG
Log(lsTRACE) << "Done acquiring ledger " << mHash.GetHex(); Log(lsTRACE) << "Done acquiring ledger " << mHash;
#endif #endif
std::vector< boost::function<void (LedgerAcquire::pointer)> > triggers; std::vector< boost::function<void (LedgerAcquire::pointer)> > triggers;
@@ -147,8 +147,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer)
if (mAborted || mComplete || mFailed) if (mAborted || mComplete || mFailed)
return; return;
#ifdef LA_DEBUG #ifdef LA_DEBUG
if(peer) Log(lsTRACE) << "Trigger acquiring ledger " << mHash.GetHex() << " from " << peer->getIP(); if(peer) Log(lsTRACE) << "Trigger acquiring ledger " << mHash << " from " << peer->getIP();
else Log(lsTRACE) << "Trigger acquiring ledger " << mHash.GetHex(); else Log(lsTRACE) << "Trigger acquiring ledger " << mHash;
if (mComplete || mFailed) if (mComplete || mFailed)
Log(lsTRACE) << "complete=" << mComplete << " failed=" << mFailed; Log(lsTRACE) << "complete=" << mComplete << " failed=" << mFailed;
else else
@@ -290,7 +290,7 @@ void PeerSet::sendRequest(const newcoin::TMGetLedger& tmGL)
bool LedgerAcquire::takeBase(const std::string& data) bool LedgerAcquire::takeBase(const std::string& data)
{ // Return value: true=normal, false=bad data { // Return value: true=normal, false=bad data
#ifdef LA_DEBUG #ifdef LA_DEBUG
Log(lsTRACE) << "got base acquiring ledger " << mHash.GetHex(); Log(lsTRACE) << "got base acquiring ledger " << mHash;
#endif #endif
boost::recursive_mutex::scoped_lock sl(mLock); boost::recursive_mutex::scoped_lock sl(mLock);
if (mHaveBase) return true; if (mHaveBase) return true;
@@ -298,7 +298,7 @@ bool LedgerAcquire::takeBase(const std::string& data)
if (mLedger->getHash() != mHash) if (mLedger->getHash() != mHash)
{ {
Log(lsWARNING) << "Acquire hash mismatch"; Log(lsWARNING) << "Acquire hash mismatch";
Log(lsWARNING) << mLedger->getHash().GetHex() << "!=" << mHash.GetHex(); Log(lsWARNING) << mLedger->getHash() << "!=" << mHash;
mLedger = Ledger::pointer(); mLedger = Ledger::pointer();
#ifdef TRUST_NETWORK #ifdef TRUST_NETWORK
assert(false); assert(false);
@@ -357,7 +357,7 @@ bool LedgerAcquire::takeAsNode(const std::list<SHAMapNode>& nodeIDs,
const std::list< std::vector<unsigned char> >& data) const std::list< std::vector<unsigned char> >& data)
{ {
#ifdef LA_DEBUG #ifdef LA_DEBUG
Log(lsTRACE) << "got ASdata acquiring ledger " << mHash.GetHex(); Log(lsTRACE) << "got ASdata acquiring ledger " << mHash;
#endif #endif
if (!mHaveBase) return false; if (!mHaveBase) return false;
std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin(); std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin();
@@ -448,7 +448,7 @@ bool LedgerAcquireMaster::gotLedgerData(newcoin::TMLedgerData& packet, Peer::ref
} }
memcpy(hash.begin(), packet.ledgerhash().data(), 32); memcpy(hash.begin(), packet.ledgerhash().data(), 32);
#ifdef LA_DEBUG #ifdef LA_DEBUG
Log(lsTRACE) << hash.GetHex(); Log(lsTRACE) << hash;
#endif #endif
LedgerAcquire::pointer ledger = find(hash); LedgerAcquire::pointer ledger = find(hash);

View File

@@ -33,7 +33,7 @@ void TransactionAcquire::done()
{ {
if (mFailed) if (mFailed)
{ {
Log(lsWARNING) << "Failed to acqiure TXs " << mHash.GetHex(); Log(lsWARNING) << "Failed to acqiure TXs " << mHash;
theApp->getOPs().mapComplete(mHash, SHAMap::pointer()); theApp->getOPs().mapComplete(mHash, SHAMap::pointer());
} }
else else
@@ -136,25 +136,25 @@ void LCTransaction::setVote(const uint160& peer, bool votesYes)
{ // new vote { // new vote
if (votesYes) if (votesYes)
{ {
Log(lsTRACE) << "Peer " << peer.GetHex() << " votes YES on " << mTransactionID.GetHex(); Log(lsTRACE) << "Peer " << peer << " votes YES on " << mTransactionID;
++mYays; ++mYays;
} }
else else
{ {
Log(lsTRACE) << "Peer " << peer.GetHex() << " votes NO on " << mTransactionID.GetHex(); Log(lsTRACE) << "Peer " << peer << " votes NO on " << mTransactionID;
++mNays; ++mNays;
} }
} }
else if (votesYes && !res.first->second) else if (votesYes && !res.first->second)
{ // changes vote to yes { // changes vote to yes
Log(lsTRACE) << "Peer " << peer.GetHex() << " now votes YES on " << mTransactionID.GetHex(); Log(lsTRACE) << "Peer " << peer << " now votes YES on " << mTransactionID;
--mNays; --mNays;
++mYays; ++mYays;
res.first->second = true; res.first->second = true;
} }
else if (!votesYes && res.first->second) else if (!votesYes && res.first->second)
{ // changes vote to no { // changes vote to no
Log(lsTRACE) << "Peer " << peer.GetHex() << " now votes NO on " << mTransactionID.GetHex(); Log(lsTRACE) << "Peer " << peer << " now votes NO on " << mTransactionID;
++mNays; ++mNays;
--mYays; --mYays;
res.first->second = false; res.first->second = false;
@@ -203,7 +203,7 @@ bool LCTransaction::updatePosition(int percentTime, bool proposing)
return false; return false;
} }
mOurPosition = newPosition; mOurPosition = newPosition;
Log(lsTRACE) << "We now vote " << (mOurPosition ? "YES" : "NO") << " on " << mTransactionID.GetHex(); Log(lsTRACE) << "We now vote " << (mOurPosition ? "YES" : "NO") << " on " << mTransactionID;
return true; return true;
} }
@@ -215,7 +215,7 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
mConsensusStartTime = boost::posix_time::microsec_clock::universal_time(); mConsensusStartTime = boost::posix_time::microsec_clock::universal_time();
Log(lsDEBUG) << "Creating consensus object"; Log(lsDEBUG) << "Creating consensus object";
Log(lsTRACE) << "LCL:" << previousLedger->getHash().GetHex() <<", ct=" << closeTime; Log(lsTRACE) << "LCL:" << previousLedger->getHash() <<", ct=" << closeTime;
mPreviousProposers = theApp->getOPs().getPreviousProposers(); mPreviousProposers = theApp->getOPs().getPreviousProposers();
mPreviousMSeconds = theApp->getOPs().getPreviousConvergeTime(); mPreviousMSeconds = theApp->getOPs().getPreviousConvergeTime();
assert(mPreviousMSeconds); assert(mPreviousMSeconds);
@@ -238,8 +238,8 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
handleLCL(prevLCLHash); handleLCL(prevLCLHash);
if (!mHaveCorrectLCL) if (!mHaveCorrectLCL)
{ {
Log(lsINFO) << "Entering consensus with: " << previousLedger->getHash().GetHex(); Log(lsINFO) << "Entering consensus with: " << previousLedger->getHash();
Log(lsINFO) << "Correct LCL is: " << prevLCLHash.GetHex(); Log(lsINFO) << "Correct LCL is: " << prevLCLHash;
} }
} }
@@ -282,7 +282,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
return; return;
else else
{ {
Log(lsWARNING) << "Need consensus ledger " << mPrevLedgerHash.GetHex(); Log(lsWARNING) << "Need consensus ledger " << mPrevLedgerHash;
mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(mPrevLedgerHash); mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(mPrevLedgerHash);
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector(); std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
bool found = false; bool found = false;
@@ -305,7 +305,7 @@ void LedgerConsensus::handleLCL(const uint256& lclHash)
return; return;
} }
Log(lsINFO) << "Acquired the consensus ledger " << mPrevLedgerHash.GetHex(); Log(lsINFO) << "Acquired the consensus ledger " << mPrevLedgerHash;
mHaveCorrectLCL = true; mHaveCorrectLCL = true;
mAcquiringLedger = LedgerAcquire::pointer(); mAcquiringLedger = LedgerAcquire::pointer();
mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution( mCloseResolution = ContinuousLedgerTiming::getNextLedgerTimeResolution(
@@ -365,7 +365,7 @@ void LedgerConsensus::createDisputes(const SHAMap::pointer& m1, const SHAMap::po
void LedgerConsensus::mapComplete(const uint256& hash, const SHAMap::pointer& map, bool acquired) void LedgerConsensus::mapComplete(const uint256& hash, const SHAMap::pointer& map, bool acquired)
{ {
if (acquired) if (acquired)
Log(lsINFO) << "We have acquired TXS " << hash.GetHex(); Log(lsINFO) << "We have acquired TXS " << hash;
mAcquiring.erase(hash); mAcquiring.erase(hash);
if (!map) if (!map)
@@ -400,7 +400,7 @@ void LedgerConsensus::mapComplete(const uint256& hash, const SHAMap::pointer& ma
if (!peers.empty()) if (!peers.empty())
adjustCount(map, peers); adjustCount(map, peers);
else if (acquired) else if (acquired)
Log(lsWARNING) << "By the time we got the map " << hash.GetHex() << " no peers were proposing it"; Log(lsWARNING) << "By the time we got the map " << hash << " no peers were proposing it";
sendHaveTxSet(hash, true); sendHaveTxSet(hash, true);
} }
@@ -551,7 +551,7 @@ void LedgerConsensus::updateOurPositions()
if (it->second->isStale(peerCutoff)) if (it->second->isStale(peerCutoff))
{ // proposal is stale { // proposal is stale
uint160 peerID = it->second->getPeerID(); uint160 peerID = it->second->getPeerID();
Log(lsWARNING) << "Removing stale proposal from " << peerID.GetHex(); Log(lsWARNING) << "Removing stale proposal from " << peerID;
BOOST_FOREACH(u256_lct_pair& it, mDisputes) BOOST_FOREACH(u256_lct_pair& it, mDisputes)
it.second->unVote(peerID); it.second->unVote(peerID);
mPeerPositions.erase(it++); mPeerPositions.erase(it++);
@@ -641,7 +641,7 @@ void LedgerConsensus::updateOurPositions()
if (mProposing) if (mProposing)
propose(addedTx, removedTx); propose(addedTx, removedTx);
mapComplete(newHash, ourPosition, false); mapComplete(newHash, ourPosition, false);
Log(lsINFO) << "Position change: CTime " << closeTime << ", tx " << newHash.GetHex(); Log(lsINFO) << "Position change: CTime " << closeTime << ", tx " << newHash;
} }
} }
@@ -725,7 +725,7 @@ void LedgerConsensus::startAcquiring(const TransactionAcquire::pointer& acquire)
void LedgerConsensus::propose(const std::vector<uint256>& added, const std::vector<uint256>& removed) void LedgerConsensus::propose(const std::vector<uint256>& added, const std::vector<uint256>& removed)
{ {
Log(lsTRACE) << "We propose: " << mOurPosition->getCurrentHash().GetHex(); Log(lsTRACE) << "We propose: " << mOurPosition->getCurrentHash();
newcoin::TMProposeSet prop; newcoin::TMProposeSet prop;
prop.set_currenttxhash(mOurPosition->getCurrentHash().begin(), 256 / 8); prop.set_currenttxhash(mOurPosition->getCurrentHash().begin(), 256 / 8);
prop.set_proposeseq(mOurPosition->getProposeSeq()); prop.set_proposeseq(mOurPosition->getProposeSeq());
@@ -741,7 +741,7 @@ void LedgerConsensus::propose(const std::vector<uint256>& added, const std::vect
void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vector<unsigned char>& tx) void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vector<unsigned char>& tx)
{ {
Log(lsTRACE) << "Transaction " << txID.GetHex() << " is disputed"; Log(lsTRACE) << "Transaction " << txID << " is disputed";
boost::unordered_map<uint256, LCTransaction::pointer>::iterator it = mDisputes.find(txID); boost::unordered_map<uint256, LCTransaction::pointer>::iterator it = mDisputes.find(txID);
if (it != mDisputes.end()) return; if (it != mDisputes.end()) return;
@@ -783,8 +783,7 @@ bool LedgerConsensus::peerPosition(const LedgerProposal::pointer& newPosition)
++mCloseTimes[newPosition->getCloseTime()]; ++mCloseTimes[newPosition->getCloseTime()];
} }
Log(lsINFO) << "Processing peer proposal " << newPosition->getProposeSeq() << "/" Log(lsINFO) << "Processing peer proposal " << newPosition->getProposeSeq() << "/" << newPosition->getCurrentHash();
<< newPosition->getCurrentHash().GetHex();
currentPosition = newPosition; currentPosition = newPosition;
SHAMap::pointer set = getTransactionTree(newPosition->getCurrentHash(), true); SHAMap::pointer set = getTransactionTree(newPosition->getCurrentHash(), true);
if (set) if (set)
@@ -911,7 +910,7 @@ void LedgerConsensus::applyTransactions(const SHAMap::pointer& set, Ledger::ref
{ {
if (!checkLedger->hasTransaction(item->getTag())) if (!checkLedger->hasTransaction(item->getTag()))
{ {
Log(lsINFO) << "Processing candidate transaction: " << item->getTag().GetHex(); Log(lsINFO) << "Processing candidate transaction: " << item->getTag();
#ifndef TRUST_NETWORK #ifndef TRUST_NETWORK
try try
{ {
@@ -967,9 +966,8 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
Log(lsINFO) << "Computing new LCL based on network consensus"; Log(lsINFO) << "Computing new LCL based on network consensus";
if (mHaveCorrectLCL) if (mHaveCorrectLCL)
{ {
Log(lsINFO) << "CNF tx " << mOurPosition->getCurrentHash().GetHex() << ", close " << closeTime; Log(lsINFO) << "CNF tx " << mOurPosition->getCurrentHash() << ", close " << closeTime;
Log(lsINFO) << "CNF mode " << theApp->getOPs().getOperatingMode() Log(lsINFO) << "CNF mode " << theApp->getOPs().getOperatingMode() << ", oldLCL " << mPrevLedgerHash;
<< ", oldLCL " << mPrevLedgerHash.GetHex();
} }
Ledger::pointer newLCL = boost::make_shared<Ledger>(false, boost::ref(*mPreviousLedger)); Ledger::pointer newLCL = boost::make_shared<Ledger>(false, boost::ref(*mPreviousLedger));
@@ -996,7 +994,7 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
SerializedValidation::pointer v = boost::make_shared<SerializedValidation> SerializedValidation::pointer v = boost::make_shared<SerializedValidation>
(newLCLHash, newLCL->getCloseTimeNC(), mValSeed, mProposing); (newLCLHash, newLCL->getCloseTimeNC(), mValSeed, mProposing);
v->setTrusted(); v->setTrusted();
Log(lsINFO) << "CNF Val " << newLCLHash.GetHex(); Log(lsINFO) << "CNF Val " << newLCLHash;
theApp->getValidations().addValidation(v); theApp->getValidations().addValidation(v);
std::vector<unsigned char> validation = v->getSigned(); std::vector<unsigned char> validation = v->getSigned();
newcoin::TMValidation val; newcoin::TMValidation val;
@@ -1004,7 +1002,7 @@ void LedgerConsensus::accept(const SHAMap::pointer& set)
theApp->getConnectionPool().relayMessage(NULL, boost::make_shared<PackedMessage>(val, newcoin::mtVALIDATION)); theApp->getConnectionPool().relayMessage(NULL, boost::make_shared<PackedMessage>(val, newcoin::mtVALIDATION));
} }
else else
Log(lsINFO) << "CNF newLCL " << newLCLHash.GetHex(); Log(lsINFO) << "CNF newLCL " << newLCLHash;
Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL)); Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL));
ScopedLock sl = theApp->getMasterLedger().getLock(); ScopedLock sl = theApp->getMasterLedger().getLock();

View File

@@ -23,12 +23,12 @@ void LedgerMaster::pushLedger(Ledger::ref newLedger)
{ {
// Caller should already have properly assembled this ledger into "ready-to-close" form -- // Caller should already have properly assembled this ledger into "ready-to-close" form --
// all candidate transactions must already be appled // all candidate transactions must already be appled
Log(lsINFO) << "PushLedger: " << newLedger->getHash().GetHex(); Log(lsINFO) << "PushLedger: " << newLedger->getHash();
ScopedLock sl(mLock); ScopedLock sl(mLock);
if (!!mFinalizedLedger) if (!!mFinalizedLedger)
{ {
mFinalizedLedger->setClosed(); mFinalizedLedger->setClosed();
Log(lsTRACE) << "Finalizes: " << mFinalizedLedger->getHash().GetHex(); Log(lsTRACE) << "Finalizes: " << mFinalizedLedger->getHash();
} }
mFinalizedLedger = mCurrentLedger; mFinalizedLedger = mCurrentLedger;
mCurrentLedger = newLedger; mCurrentLedger = newLedger;
@@ -45,7 +45,7 @@ void LedgerMaster::pushLedger(Ledger::ref newLCL, Ledger::ref newOL)
assert(newLCL->isClosed()); assert(newLCL->isClosed());
assert(newLCL->isImmutable()); assert(newLCL->isImmutable());
mLedgerHistory.addAcceptedLedger(newLCL); mLedgerHistory.addAcceptedLedger(newLCL);
Log(lsINFO) << "StashAccepted: " << newLCL->getHash().GetHex(); Log(lsINFO) << "StashAccepted: " << newLCL->getHash();
} }
mFinalizedLedger = newLCL; mFinalizedLedger = newLCL;

View File

@@ -472,7 +472,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
it != end; ++it) it != end; ++it)
{ {
bool isDead = theApp->getValidations().isDeadLedger(it->first); bool isDead = theApp->getValidations().isDeadLedger(it->first);
Log(lsTRACE) << "L: " << it->first.GetHex() << ((isDead) ? " dead" : " live") << Log(lsTRACE) << "L: " << it->first << ((isDead) ? " dead" : " live") <<
" t=" << it->second.trustedValidations << ", n=" << it->second.nodesUsing; " t=" << it->second.trustedValidations << ", n=" << it->second.nodesUsing;
if ((it->second > bestVC) && !isDead) if ((it->second > bestVC) && !isDead)
{ {
@@ -502,15 +502,15 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
} }
Log(lsWARNING) << "We are not running on the consensus ledger"; Log(lsWARNING) << "We are not running on the consensus ledger";
Log(lsINFO) << "Our LCL " << ourClosed->getHash().GetHex(); Log(lsINFO) << "Our LCL " << ourClosed->getHash();
Log(lsINFO) << "Net LCL " << closedLedger.GetHex(); Log(lsINFO) << "Net LCL " << closedLedger;
if ((mMode == omTRACKING) || (mMode == omFULL)) if ((mMode == omTRACKING) || (mMode == omFULL))
setMode(omCONNECTED); setMode(omCONNECTED);
Ledger::pointer consensus = mLedgerMaster->getLedgerByHash(closedLedger); Ledger::pointer consensus = mLedgerMaster->getLedgerByHash(closedLedger);
if (!consensus) if (!consensus)
{ {
Log(lsINFO) << "Acquiring consensus ledger " << closedLedger.GetHex(); Log(lsINFO) << "Acquiring consensus ledger " << closedLedger;
LedgerAcquire::pointer mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(closedLedger); LedgerAcquire::pointer mAcquiringLedger = theApp->getMasterLedgerAcquire().findCreate(closedLedger);
if (!mAcquiringLedger || mAcquiringLedger->isFailed()) if (!mAcquiringLedger || mAcquiringLedger->isFailed())
{ {
@@ -552,9 +552,9 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
{ // set the newledger as our last closed ledger -- this is abnormal code { // set the newledger as our last closed ledger -- this is abnormal code
if (duringConsensus) if (duringConsensus)
Log(lsERROR) << "JUMPdc last closed ledger to " << newLedger->getHash().GetHex(); Log(lsERROR) << "JUMPdc last closed ledger to " << newLedger->getHash();
else else
Log(lsERROR) << "JUMP last closed ledger to " << newLedger->getHash().GetHex(); Log(lsERROR) << "JUMP last closed ledger to " << newLedger->getHash();
newLedger->setClosed(); newLedger->setClosed();
Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*newLedger)); Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*newLedger));
@@ -575,7 +575,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger) int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger)
{ {
Log(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq(); Log(lsINFO) << "Consensus time for ledger " << closingLedger->getLedgerSeq();
Log(lsINFO) << " LCL is " << closingLedger->getParentHash().GetHex(); Log(lsINFO) << " LCL is " << closingLedger->getParentHash();
Ledger::pointer prevLedger = mLedgerMaster->getLedgerByHash(closingLedger->getParentHash()); Ledger::pointer prevLedger = mLedgerMaster->getLedgerByHash(closingLedger->getParentHash());
if (!prevLedger) if (!prevLedger)
@@ -638,7 +638,7 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint
// Is this node on our UNL? // Is this node on our UNL?
if (!theApp->getUNL().nodeInUNL(naPeerPublic)) if (!theApp->getUNL().nodeInUNL(naPeerPublic))
{ {
Log(lsINFO) << "Untrusted proposal: " << naPeerPublic.humanNodePublic() << " " << proposeHash.GetHex(); Log(lsINFO) << "Untrusted proposal: " << naPeerPublic.humanNodePublic() << " " << proposeHash;
return true; return true;
} }
@@ -686,7 +686,7 @@ void NetworkOPs::mapComplete(const uint256& hash, const SHAMap::pointer& map)
void NetworkOPs::endConsensus(bool correctLCL) void NetworkOPs::endConsensus(bool correctLCL)
{ {
uint256 deadLedger = theApp->getMasterLedger().getClosedLedger()->getParentHash(); uint256 deadLedger = theApp->getMasterLedger().getClosedLedger()->getParentHash();
Log(lsTRACE) << "Ledger " << deadLedger.GetHex() << " is now dead"; Log(lsTRACE) << "Ledger " << deadLedger << " is now dead";
theApp->getValidations().addDeadLedger(deadLedger); theApp->getValidations().addDeadLedger(deadLedger);
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector(); std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
BOOST_FOREACH(Peer::ref it, peerList) BOOST_FOREACH(Peer::ref it, peerList)
@@ -766,7 +766,7 @@ std::vector<NewcoinAddress>
bool NetworkOPs::recvValidation(const SerializedValidation::pointer& val) bool NetworkOPs::recvValidation(const SerializedValidation::pointer& val)
{ {
Log(lsINFO) << "recvValidation " << val->getLedgerHash().GetHex(); Log(lsINFO) << "recvValidation " << val->getLedgerHash();
return theApp->getValidations().addValidation(val); return theApp->getValidations().addValidation(val);
} }

View File

@@ -906,7 +906,7 @@ void Peer::recvStatus(newcoin::TMStatusChange& packet)
if (packet.has_ledgerhash() && (packet.ledgerhash().size() == (256 / 8))) if (packet.has_ledgerhash() && (packet.ledgerhash().size() == (256 / 8)))
{ // a peer has changed ledgers { // a peer has changed ledgers
memcpy(mClosedLedgerHash.begin(), packet.ledgerhash().data(), 256 / 8); memcpy(mClosedLedgerHash.begin(), packet.ledgerhash().data(), 256 / 8);
Log(lsTRACE) << "peer LCL is " << mClosedLedgerHash.GetHex() << " " << getIP(); Log(lsTRACE) << "peer LCL is " << mClosedLedgerHash << " " << getIP();
} }
else else
{ {

View File

@@ -125,7 +125,7 @@ void SHAMap::dirtyUp(std::stack<SHAMapTreeNode::pointer>& stack, const uint256&
return; return;
} }
#ifdef ST_DEBUG #ifdef ST_DEBUG
std::cerr << "dirtyUp sets branch " << branch << " to " << prevHash.GetHex() << std::endl; std::cerr << "dirtyUp sets branch " << branch << " to " << prevHash << std::endl;
#endif #endif
prevHash = node->getNodeHash(); prevHash = node->getNodeHash();
assert(prevHash.isNonZero()); assert(prevHash.isNonZero());
@@ -188,8 +188,8 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& id, const uint256& has
{ {
std::cerr << "Attempt to get node, hash not in tree" << std::endl; std::cerr << "Attempt to get node, hash not in tree" << std::endl;
std::cerr << "ID: " << id.getString() << std::endl; std::cerr << "ID: " << id.getString() << std::endl;
std::cerr << "TgtHash " << hash.GetHex() << std::endl; std::cerr << "TgtHash " << hash << std::endl;
std::cerr << "NodHash " << node->getNodeHash().GetHex() << std::endl; std::cerr << "NodHash " << node->getNodeHash() << std::endl;
dump(); dump();
throw std::runtime_error("invalid node"); throw std::runtime_error("invalid node");
} }
@@ -255,7 +255,7 @@ SHAMapItem::pointer SHAMap::firstBelow(SHAMapTreeNode* node)
#ifdef ST_DEBUG #ifdef ST_DEBUG
std::cerr << " FB: node " << node->getString() << std::endl; std::cerr << " FB: node " << node->getString() << std::endl;
std::cerr << " has non-empty branch " << i << " : " << std::cerr << " has non-empty branch " << i << " : " <<
node->getChildNodeID(i).getString() << ", " << node->getChildHash(i).GetHex() << std::endl; node->getChildNodeID(i).getString() << ", " << node->getChildHash(i) << std::endl;
#endif #endif
node = getNodePointer(node->getChildNodeID(i), node->getChildHash(i)); node = getNodePointer(node->getChildNodeID(i), node->getChildHash(i));
foundNode = true; foundNode = true;
@@ -501,7 +501,7 @@ bool SHAMap::delItem(const uint256& id)
bool SHAMap::addGiveItem(const SHAMapItem::pointer& item, bool isTransaction, bool hasMeta) bool SHAMap::addGiveItem(const SHAMapItem::pointer& item, bool isTransaction, bool hasMeta)
{ // add the specified item, does not update { // add the specified item, does not update
#ifdef ST_DEBUG #ifdef ST_DEBUG
std::cerr << "aGI " << item->getTag().GetHex() << std::endl; std::cerr << "aGI " << item->getTag() << std::endl;
#endif #endif
uint256 tag = item->getTag(); uint256 tag = item->getTag();
@@ -547,7 +547,7 @@ bool SHAMap::addGiveItem(const SHAMapItem::pointer& item, bool isTransaction, bo
{ // this is a leaf node that has to be made an inner node holding two items { // this is a leaf node that has to be made an inner node holding two items
#ifdef ST_DEBUG #ifdef ST_DEBUG
std::cerr << "aGI leaf " << node->getString() << std::endl; std::cerr << "aGI leaf " << node->getString() << std::endl;
std::cerr << "Existing: " << node->peekItem()->getTag().GetHex() << std::endl; std::cerr << "Existing: " << node->peekItem()->getTag() << std::endl;
#endif #endif
SHAMapItem::pointer otherItem = node->peekItem(); SHAMapItem::pointer otherItem = node->peekItem();
assert(otherItem && (tag != otherItem->getTag())); assert(otherItem && (tag != otherItem->getTag()));
@@ -629,7 +629,7 @@ bool SHAMap::updateGiveItem(const SHAMapItem::pointer& item, bool isTransaction,
void SHAMapItem::dump() void SHAMapItem::dump()
{ {
std::cerr << "SHAMapItem(" << mTag.GetHex() << ") " << mData.size() << "bytes" << std::endl; std::cerr << "SHAMapItem(" << mTag << ") " << mData.size() << "bytes" << std::endl;
} }
SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const uint256& hash) SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const uint256& hash)
@@ -652,7 +652,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
} }
catch (...) catch (...)
{ {
Log(lsWARNING) << "fetchNodeExternal gets an invalid node: " << hash.GetHex(); Log(lsWARNING) << "fetchNodeExternal gets an invalid node: " << hash;
throw SHAMapMissingNode(id, hash); throw SHAMapMissingNode(id, hash);
} }
} }
@@ -719,7 +719,7 @@ void SHAMap::dump(bool hash)
SHAMapItem::pointer i=peekFirstItem(); SHAMapItem::pointer i=peekFirstItem();
while (i) while (i)
{ {
std::cerr << "Item: id=" << i->getTag().GetHex() << std::endl; std::cerr << "Item: id=" << i->getTag() << std::endl;
i = peekNextItem(i->getTag()); i = peekNextItem(i->getTag());
} }
std::cerr << "SHAMap::dump done" << std::endl; std::cerr << "SHAMap::dump done" << std::endl;
@@ -732,7 +732,7 @@ void SHAMap::dump(bool hash)
{ {
std::cerr << it->second->getString() << std::endl; std::cerr << it->second->getString() << std::endl;
if (hash) if (hash)
std::cerr << " " << it->second->getNodeHash().GetHex() << std::endl; std::cerr << " " << it->second->getNodeHash() << std::endl;
} }
} }

View File

@@ -73,7 +73,7 @@ bool SHAMapNode::operator!=(const uint256 &s) const
return s != mNodeID; return s != mNodeID;
} }
static bool j = SHAMapNode::ClassInit(); bool SMN_j = SHAMapNode::ClassInit();
bool SHAMapNode::ClassInit() bool SHAMapNode::ClassInit()
{ // set up the depth masks { // set up the depth masks
@@ -147,7 +147,7 @@ int SHAMapNode::selectBranch(const uint256& hash) const
if ((hash & smMasks[mDepth]) != mNodeID) if ((hash & smMasks[mDepth]) != mNodeID)
{ {
std::cerr << "selectBranch(" << getString() << std::endl; std::cerr << "selectBranch(" << getString() << std::endl;
std::cerr << " " << hash.GetHex() << " off branch" << std::endl; std::cerr << " " << hash << " off branch" << std::endl;
assert(false); assert(false);
return -1; // does not go under this node return -1; // does not go under this node
} }
@@ -464,7 +464,7 @@ void SHAMapTreeNode::makeInner()
void SHAMapTreeNode::dump() void SHAMapTreeNode::dump()
{ {
Log(lsDEBUG) << "SHAMapTreeNode(" << getNodeID().GetHex() << ")"; Log(lsDEBUG) << "SHAMapTreeNode(" << getNodeID() << ")";
} }
std::string SHAMapTreeNode::getString() const std::string SHAMapTreeNode::getString() const

View File

@@ -54,7 +54,7 @@ bool ValidationCollection::addValidation(const SerializedValidation::pointer& va
} }
} }
Log(lsINFO) << "Val for " << hash.GetHex() << " from " << signer.humanNodePublic() Log(lsINFO) << "Val for " << hash << " from " << signer.humanNodePublic()
<< " added " << (val->isTrusted() ? "trusted/" : "UNtrusted/") << (isCurrent ? "current" : "stale"); << " added " << (val->isTrusted() ? "trusted/" : "UNtrusted/") << (isCurrent ? "current" : "stale");
return isCurrent; return isCurrent;
} }
@@ -90,7 +90,7 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren
else else
{ {
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsINFO) << "VC: Untrusted due to time " << ledger.GetHex(); Log(lsINFO) << "VC: Untrusted due to time " << ledger;
#endif #endif
} }
} }
@@ -101,7 +101,7 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren
} }
} }
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsINFO) << "VC: " << ledger.GetHex() << "t:" << trusted << " u:" << untrusted; Log(lsINFO) << "VC: " << ledger << "t:" << trusted << " u:" << untrusted;
#endif #endif
} }
@@ -149,7 +149,7 @@ boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations()
if (pair.oldest && (now > (pair.oldest->getCloseTime() + LEDGER_VAL_INTERVAL))) if (pair.oldest && (now > (pair.oldest->getCloseTime() + LEDGER_VAL_INTERVAL)))
{ {
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsINFO) << "VC: " << it->first.GetHex() << " removeOldestStale"; Log(lsINFO) << "VC: " << it->first << " removeOldestStale";
#endif #endif
mStaleValidations.push_back(pair.oldest); mStaleValidations.push_back(pair.oldest);
pair.oldest = SerializedValidation::pointer(); pair.oldest = SerializedValidation::pointer();
@@ -158,7 +158,7 @@ boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations()
if (pair.newest && (now > (pair.newest->getCloseTime() + LEDGER_VAL_INTERVAL))) if (pair.newest && (now > (pair.newest->getCloseTime() + LEDGER_VAL_INTERVAL)))
{ {
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsINFO) << "VC: " << it->first.GetHex() << " removeNewestStale"; Log(lsINFO) << "VC: " << it->first << " removeNewestStale";
#endif #endif
mStaleValidations.push_back(pair.newest); mStaleValidations.push_back(pair.newest);
pair.newest = SerializedValidation::pointer(); pair.newest = SerializedValidation::pointer();
@@ -171,7 +171,7 @@ boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations()
if (pair.oldest) if (pair.oldest)
{ {
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsTRACE) << "VC: OLD " << pair.oldest->getLedgerHash().GetHex() << " " << Log(lsTRACE) << "VC: OLD " << pair.oldest->getLedgerHash() << " " <<
boost::lexical_cast<std::string>(pair.oldest->getCloseTime()); boost::lexical_cast<std::string>(pair.oldest->getCloseTime());
#endif #endif
++ret[pair.oldest->getLedgerHash()]; ++ret[pair.oldest->getLedgerHash()];
@@ -179,7 +179,7 @@ boost::unordered_map<uint256, int> ValidationCollection::getCurrentValidations()
if (pair.newest) if (pair.newest)
{ {
#ifdef VC_DEBUG #ifdef VC_DEBUG
Log(lsTRACE) << "VC: NEW " << pair.newest->getLedgerHash().GetHex() << " " << Log(lsTRACE) << "VC: NEW " << pair.newest->getLedgerHash() << " " <<
boost::lexical_cast<std::string>(pair.newest->getCloseTime()); boost::lexical_cast<std::string>(pair.newest->getCloseTime());
#endif #endif
++ret[pair.newest->getLedgerHash()]; ++ret[pair.newest->getLedgerHash()];

View File

@@ -278,7 +278,7 @@ public:
std::string ToString() const std::string ToString() const
{ {
return (GetHex()); return GetHex();
} }
unsigned char* begin() unsigned char* begin()
@@ -559,6 +559,11 @@ inline const uint256 operator&(const uint256& a, const uint256& b) { return (b
inline const uint256 operator|(const uint256& a, const uint256& b) { return (base_uint256)a | (base_uint256)b; } inline const uint256 operator|(const uint256& a, const uint256& b) { return (base_uint256)a | (base_uint256)b; }
extern std::size_t hash_value(const uint256&); extern std::size_t hash_value(const uint256&);
template<unsigned int BITS> inline std::ostream& operator<<(std::ostream& out, const base_uint<BITS>& u)
{
return out << u.GetHex();
}
inline int Testuint256AdHoc(std::vector<std::string> vArg) inline int Testuint256AdHoc(std::vector<std::string> vArg)
{ {
uint256 g(0); uint256 g(0);