Files
rippled/src/ValidationCollection.h
2012-09-11 11:56:41 -07:00

47 lines
1.2 KiB
C++

#ifndef __VALIDATION_COLLECTION__
#define __VALIDATION_COLLECTION__
#include <vector>
#include <boost/unordered_map.hpp>
#include <boost/thread/mutex.hpp>
#include "uint256.h"
#include "types.h"
#include "SerializedValidation.h"
typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationSet;
class ValidationCollection
{
protected:
boost::mutex mValidationLock;
boost::unordered_map<uint256, ValidationSet> mValidations;
boost::unordered_map<uint160, SerializedValidation::pointer> mCurrentValidations;
std::vector<SerializedValidation::pointer> 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<uint256, int> getCurrentValidations(uint256 currentLedger = uint256());
void flush();
};
#endif