Logging improvements.

This commit is contained in:
JoelKatz
2012-11-05 02:05:51 -08:00
parent 17a911121d
commit e4b954c30c
3 changed files with 21 additions and 1 deletions

View File

@@ -35,11 +35,12 @@ void TransactionAcquire::done()
{ {
if (mFailed) if (mFailed)
{ {
cLog(lsWARNING) << "Failed to acquire TXs " << mHash; cLog(lsWARNING) << "Failed to acquire TX set " << mHash;
theApp->getOPs().mapComplete(mHash, SHAMap::pointer()); theApp->getOPs().mapComplete(mHash, SHAMap::pointer());
} }
else else
{ {
cLog(lsINFO) << "Acquired TX set " << mHash;
mMap->setImmutable(); mMap->setImmutable();
theApp->getOPs().mapComplete(mHash, mMap); theApp->getOPs().mapComplete(mHash, mMap);
} }
@@ -125,9 +126,15 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
const std::list< std::vector<unsigned char> >& data, Peer::ref peer) const std::list< std::vector<unsigned char> >& data, Peer::ref peer)
{ {
if (mComplete) if (mComplete)
{
cLog(lsTRACE) << "TX set complete";
return true; return true;
}
if (mFailed) if (mFailed)
{
cLog(lsTRACE) << "TX set failed";
return false; return false;
}
try try
{ {
std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin(); std::list<SHAMapNode>::const_iterator nodeIDit = nodeIDs.begin();
@@ -143,12 +150,18 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
return false; return false;
} }
if (!mMap->addRootNode(getHash(), *nodeDatait, snfWIRE, NULL)) if (!mMap->addRootNode(getHash(), *nodeDatait, snfWIRE, NULL))
{
cLog(lsWARNING) << "TX acquire got bad root node";
return false; return false;
}
else else
mHaveRoot = true; mHaveRoot = true;
} }
else if (!mMap->addKnownNode(*nodeIDit, *nodeDatait, &sf)) else if (!mMap->addKnownNode(*nodeIDit, *nodeDatait, &sf))
{
cLog(lsWARNING) << "TX acquire got bad non-root node";
return false; return false;
}
++nodeIDit; ++nodeIDit;
++nodeDatait; ++nodeDatait;
} }
@@ -953,7 +966,10 @@ bool LedgerConsensus::peerGaveNodes(Peer::ref peer, const uint256& setHash,
{ {
boost::unordered_map<uint256, TransactionAcquire::pointer>::iterator acq = mAcquiring.find(setHash); boost::unordered_map<uint256, TransactionAcquire::pointer>::iterator acq = mAcquiring.find(setHash);
if (acq == mAcquiring.end()) if (acq == mAcquiring.end())
{
cLog(lsINFO) << "Got TX data for set not acquiring: " << setHash;
return false; return false;
}
TransactionAcquire::pointer set = acq->second; // We must keep the set around during the function TransactionAcquire::pointer set = acq->second; // We must keep the set around during the function
return set->takeNodes(nodeIDs, nodeData, peer); return set->takeNodes(nodeIDs, nodeData, peer);
} }

View File

@@ -766,7 +766,10 @@ bool NetworkOPs::gotTXData(const boost::shared_ptr<Peer>& peer, const uint256& h
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData) const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData)
{ {
if (!haveConsensusObject()) if (!haveConsensusObject())
{
cLog(lsWARNING) << "Got TX data with no consensus object";
return false; return false;
}
return mConsensus->peerGaveNodes(peer, hash, nodeIDs, nodeData); return mConsensus->peerGaveNodes(peer, hash, nodeIDs, nodeData);
} }

View File

@@ -1331,6 +1331,7 @@ void Peer::recvLedger(ripple::TMLedgerData& packet)
uint256 hash; uint256 hash;
if(packet.ledgerhash().size() != 32) if(packet.ledgerhash().size() != 32)
{ {
cLog(lsWARNING) << "TX candidate reply with invalid hash size";
punishPeer(PP_INVALID_REQUEST); punishPeer(PP_INVALID_REQUEST);
return; return;
} }