diff --git a/src/cpp/ripple/ValidationCollection.cpp b/src/cpp/ripple/ValidationCollection.cpp index f4c7b941b..eded830c6 100644 --- a/src/cpp/ripple/ValidationCollection.cpp +++ b/src/cpp/ripple/ValidationCollection.cpp @@ -97,12 +97,12 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren uint32 now = theApp->getOPs().getNetworkTimeNC(); if (set) { - for (ValidationSet::iterator vit = set->begin(), end = set->end(); vit != end; ++vit) + BOOST_FOREACH(u160_val_pair& it, *set) { - bool isTrusted = vit->second->isTrusted(); + bool isTrusted = it.second->isTrusted(); if (isTrusted && currentOnly) { - uint32 closeTime = vit->second->getSignTime(); + uint32 closeTime = it.second->getSignTime(); if ((now < (closeTime - LEDGER_EARLY_INTERVAL)) || (now > (closeTime + LEDGER_VAL_INTERVAL))) isTrusted = false; else @@ -119,6 +119,28 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren cLog(lsTRACE) << "VC: " << ledger << "t:" << trusted << " u:" << untrusted; } +void ValidationCollection::getValidationTypes(const uint256& ledger, int& full, int& partial) +{ + full = partial = 0; + boost::mutex::scoped_lock sl(mValidationLock); + VSpointer set = findSet(ledger); + if (set) + { + BOOST_FOREACH(u160_val_pair& it, *set) + { + if (it.second->isTrusted()) + { + if (it.second->isFull()) + ++full; + else + ++partial; + } + } + } + cLog(lsTRACE) << "VC: " << ledger << "f:" << full << " p:" << partial; +} + + int ValidationCollection::getTrustedValidationCount(const uint256& ledger) { int trusted = 0; @@ -126,9 +148,9 @@ int ValidationCollection::getTrustedValidationCount(const uint256& ledger) VSpointer set = findSet(ledger); if (set) { - for (ValidationSet::iterator vit = set->begin(), end = set->end(); vit != end; ++vit) + BOOST_FOREACH(u160_val_pair& it, *set) { - if (vit->second->isTrusted()) + if (it.second->isTrusted()) ++trusted; } } diff --git a/src/cpp/ripple/ValidationCollection.h b/src/cpp/ripple/ValidationCollection.h index e4a22ec4f..51f60a5a9 100644 --- a/src/cpp/ripple/ValidationCollection.h +++ b/src/cpp/ripple/ValidationCollection.h @@ -38,6 +38,7 @@ public: bool addValidation(const SerializedValidation::pointer&); ValidationSet getValidations(const uint256& ledger); void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted); + void getValidationTypes(const uint256& ledger, int& full, int& partial); int getTrustedValidationCount(const uint256& ledger);