diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 5b3744484a..021bdb1ea3 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -447,7 +447,8 @@ void LedgerConsensus::propose(const std::vector& added, const std::vect std::vector sig = mOurPosition->sign(); prop.set_nodepubkey(&pubKey[0], pubKey.size()); prop.set_signature(&sig[0], sig.size()); - theApp->getConnectionPool().relayMessage(NULL, boost::make_shared(prop, newcoin::mtPROPOSE_LEDGER)); + theApp->getConnectionPool().relayMessage(NULL, + boost::make_shared(prop, newcoin::mtPROPOSE_LEDGER)); } void LedgerConsensus::addDisputedTransaction(const uint256& txID, const std::vector& tx) @@ -489,9 +490,13 @@ bool LedgerConsensus::peerPosition(LedgerProposal::pointer newPosition) { assert(newPosition->getPeerID() == currentPosition->getPeerID()); if (newPosition->getProposeSeq() <= currentPosition->getProposeSeq()) + { + Log(lsINFO) << "Redundant/stale positon"; return false; + } if (newPosition->getCurrentHash() == currentPosition->getCurrentHash()) { // we missed an intermediary change + Log(lsINFO) << "We missed an intermediary position"; currentPosition = newPosition; return true; } diff --git a/src/Peer.cpp b/src/Peer.cpp index 52d5182a27..0587ea6a09 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -15,6 +15,10 @@ #include "Conversion.h" #include "SerializedTransaction.h" #include "utils.h" +#include "Log.h" + +// Don't try to run past receiving nonsense from a peer +#define TRUST_NETWORK // Node has this long to verify its identity from connection accepted or connection attempt. #define NODE_VERIFY_SECONDS 15 @@ -426,8 +430,6 @@ void Peer::processReadBuffer() } break; - - case newcoin::mtGET_LEDGER: { newcoin::TMGetLedger msg; @@ -571,8 +573,10 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) #endif Transaction::pointer tx; +#ifndef TRUST_NETWORK try { +#endif std::string rawTx = packet.rawtransaction(); Serializer s(std::vector(rawTx.begin(), rawTx.end())); SerializerIterator sit(s); @@ -580,6 +584,7 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) tx = boost::make_shared(stx, true); if (tx->getStatus() == INVALID) throw(0); +#ifndef TRUST_NETWORK } catch (...) { @@ -590,6 +595,7 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) #endif return; } +#endif tx = theApp->getOPs().processTransaction(tx, this); @@ -603,6 +609,7 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) void Peer::recvPropose(newcoin::TMProposeSet& packet) { + Log(lsINFO) << "Received proposal from peer"; if ((packet.currenttxhash().size() != 32) || (packet.prevclosedhash().size() != 32) || (packet.nodepubkey().size() < 28) || (packet.signature().size() < 56)) return; @@ -686,9 +693,7 @@ void Peer::recvAccount(newcoin::TMAccount& packet) void Peer::recvStatus(newcoin::TMStatusChange& packet) { -#ifdef DEBUG - std::cerr << "Received status change from peer" << std::endl; -#endif + Log(lsTRACE) << "Received status change from peer"; if (!packet.has_networktime()) packet.set_networktime(theApp->getOPs().getNetworkTimeNC()); mLastStatus = packet; @@ -701,9 +706,7 @@ void Peer::recvStatus(newcoin::TMStatusChange& packet) mPreviousLedgerHash = mClosedLedgerHash; memcpy(mClosedLedgerHash.begin(), packet.ledgerhash().data(), 256 / 8); mClosedLedgerTime = ptFromSeconds(packet.networktime()); -#ifdef DEBUG - std::cerr << "peer LCL is " << mClosedLedgerHash.GetHex() << std::endl; -#endif + Log(lsTRACE) << "peer LCL is " << mClosedLedgerHash.GetHex(); } }