#ifndef __VALIDATION_COLLECTION__ #define __VALIDATION_COLLECTION__ #include #include #include #include "uint256.h" #include "types.h" #include "SerializedValidation.h" typedef boost::unordered_map ValidationSet; typedef std::pair currentValidationCount; // nodes validating and highest node ID validating class ValidationCollection { protected: boost::mutex mValidationLock; boost::unordered_map mValidations; boost::unordered_map mCurrentValidations; std::vector mStaleValidations; bool mWriting; void doWrite(); void condWrite(); public: ValidationCollection() : mWriting(false) { ; } bool addValidation(const SerializedValidation::pointer&); ValidationSet getValidations(const uint256& ledger); void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted); int getTrustedValidationCount(const uint256& ledger); int getNodesAfter(const uint256& ledger); int getLoadRatio(bool overLoaded); boost::unordered_map getCurrentValidations(uint256 currentLedger); void flush(); }; #endif