mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
1) Change return from getCurrentValidations 2) Log tiebreaker logic to aid debugging 3) Change checkLastClosedLedger to use the new tie-breaker logic 4) Log when we refuse to switch to our own previous ledger 5) Track node ID in the serialized validation object 6) Simplify getCurrentValidations ledger suppression logic
49 lines
1.3 KiB
C++
49 lines
1.3 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;
|
|
|
|
typedef std::pair<int, uint160> currentValidationCount; // nodes validating and highest node ID validating
|
|
|
|
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, currentValidationCount> getCurrentValidations(uint256 currentLedger);
|
|
|
|
void flush();
|
|
};
|
|
|
|
#endif
|