#ifndef __VALIDATION_COLLECTION__ #define __VALIDATION_COLLECTION__ #include #include #include #include "uint256.h" #include "types.h" #include "SerializedValidation.h" #include "TaggedCache.h" #include "JobQueue.h" typedef boost::unordered_map ValidationSet; typedef std::pair currentValidationCount; // nodes validating and highest node ID validating // VFALCO: TODO, Rename this to "Validations" class ValidationCollection { protected: boost::mutex mValidationLock; TaggedCache mValidations; boost::unordered_map mCurrentValidations; std::vector mStaleValidations; bool mWriting; void doWrite(Job&); void condWrite(); boost::shared_ptr findCreateSet(const uint256& ledgerHash); boost::shared_ptr findSet(const uint256& ledgerHash); public: ValidationCollection() : mValidations("Validations", 128, 600), mWriting(false) { mStaleValidations.reserve(512); } bool addValidation(SerializedValidation::ref, const std::string& source); 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); int getNodesAfter(const uint256& ledger); int getLoadRatio(bool overLoaded); boost::unordered_map getCurrentValidations( uint256 currentLedger, uint256 previousLedger); std::list getCurrentTrustedValidations(); void tune(int size, int age); void flush(); void sweep(); }; #endif