From e458a2e3c7b82e072d4fa212c8826475685b9d64 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 18 Jun 2012 17:01:54 -0700 Subject: [PATCH] Use validations. --- src/NetworkOPs.cpp | 18 +++++++++++++++--- src/NetworkOPs.h | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 479cbb35ab..60d5b226a4 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -308,11 +308,18 @@ void NetworkOPs::checkState(const boost::system::error_code& result) if (!!peerLedger) { // FIXME: If we have this ledger, don't count it if it's too far past its close time + bool isNew = ledgers.find(peerLedger) == ledgers.end(); ValidationCount& vc = ledgers[peerLedger]; + if (isNew) + { + theApp->getValidations().getValidationCount(peerLedger, + vc.trustedValidations, vc.untrustedValidations); + Log(lsTRACE) << peerLedger.GetHex() << " has " << vc.trustedValidations << + " trusted validations and " << vc.untrustedValidations << " untrusted"; + } if ((vc.nodesUsing == 0) || ((*it)->getNodePublic() > vc.highNode)) vc.highNode = (*it)->getNodePublic(); ++vc.nodesUsing; - // WRITEME: Validations, trusted peers } } } @@ -533,8 +540,8 @@ void NetworkOPs::setMode(OperatingMode om) if (mMode == om) return; Log l((om < mMode) ? lsWARNING : lsINFO); if (om == omDISCONNECTED) l << "STATE->Disonnected"; - else if (om==omCONNECTED) l << "STATE->Connected"; - else if (om==omTRACKING) l << "STATE->Tracking"; + else if (om == omCONNECTED) l << "STATE->Connected"; + else if (om == omTRACKING) l << "STATE->Tracking"; else l << "STATE->Full"; mMode = om; } @@ -562,4 +569,9 @@ std::vector< std::pair > return affectedAccounts; } +bool NetworkOPs::recvValidation(SerializedValidation::pointer val) +{ + return theApp->getValidations().addValidation(val); +} + // vim:ts=4 diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 0514a0902a..5fdea311ed 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -5,6 +5,7 @@ #include "AccountState.h" #include "RippleState.h" #include "NicknameState.h" +#include "SerializedValidation.h" // #include @@ -115,6 +116,7 @@ public: const std::string& pubKey, const std::string& signature); bool gotTXData(boost::shared_ptr peer, const uint256& hash, const std::list& nodeIDs, const std::list< std::vector >& nodeData); + bool recvValidation(SerializedValidation::pointer val); SHAMap::pointer getTXMap(const uint256& hash); bool hasTXSet(boost::shared_ptr peer, const uint256& set, newcoin::TxSetStatus status); void mapComplete(const uint256& hash, SHAMap::pointer map);