Efficiently save validations.

This commit is contained in:
JoelKatz
2012-07-17 03:10:05 -07:00
parent e89af2f784
commit d83d8080fd
6 changed files with 99 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
#ifndef __VALIDATION_COLLECTION__
#define __VALIDATION_COLLECTION__
#include <vector>
#include <boost/unordered_map.hpp>
#include <boost/thread/mutex.hpp>
@@ -12,14 +14,19 @@ typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationS
class ValidationCollection
{
protected:
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() { ; }
ValidationCollection() : mWriting(false) { ; }
bool addValidation(SerializedValidation::pointer);
ValidationSet getValidations(const uint256& ledger);
@@ -27,6 +34,7 @@ public:
int getTrustedValidationCount(const uint256& ledger);
int getCurrentValidationCount(uint32 afterTime);
boost::unordered_map<uint256, int> getCurrentValidations();
void flush();
};
#endif