diff --git a/src/ValidationCollection.cpp b/src/ValidationCollection.cpp index 1ff1f8224b..07f88cc38c 100644 --- a/src/ValidationCollection.cpp +++ b/src/ValidationCollection.cpp @@ -75,6 +75,21 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren } } +int ValidationCollection::getTrustedValidationCount(const uint256& ledger) +{ + int trusted = 0; + boost::mutex::scoped_lock sl(mValidationLock); + boost::unordered_map::iterator it = mValidations.find(ledger); + if (it != mValidations.end()) + { + for (ValidationSet::iterator vit = it->second.begin(), end = it->second.end(); vit != end; ++vit) + { + if (vit->second->isTrusted()) + ++trusted; + } + } +} + boost::unordered_map ValidationCollection::getCurrentValidations() { uint64 now = theApp->getOPs().getNetworkTimeNC(); diff --git a/src/ValidationCollection.h b/src/ValidationCollection.h index 7df9c91bb2..f381337830 100644 --- a/src/ValidationCollection.h +++ b/src/ValidationCollection.h @@ -24,6 +24,7 @@ public: bool addValidation(SerializedValidation::pointer); ValidationSet getValidations(const uint256& ledger); void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted); + int getTrustedValidationCount(const uint256& ledger); boost::unordered_map getCurrentValidations(); };