#ifndef __VALIDATION_COLLECTION__ #define __VALIDATION_COLLECTION__ #include "newcoin.pb.h" #include "uint256.h" #include "types.h" #include "Ledger.h" #include class ValidationCollection { // from ledger hash to the validation //std::map > mValidations; //std::map > mIgnoredValidations; // this maps ledgerIndex to an array of groups. Each group is a list of validations. // a validation can be in multiple groups since compatibility isn't transitive // class Group { public: std::vector mValidations; Ledger::pointer mSuperLedger; bool addIfCompatible(Ledger::pointer ledger,newcoin::Validation& valid); }; std::map > mIndexGroups; // all the groups at each index //std::map > mIndexValidations; // all the validations at each index bool hasValidation(uint32 ledgerIndex,uint160& hanko,uint32 seqnum); void addToGroup(newcoin::Validation& valid); void addToDB(newcoin::Validation& valid,int weCare); public: ValidationCollection(); void save(); void load(); void addValidation(newcoin::Validation& valid); void getValidations(uint32 ledgerIndex,std::vector& retVec); // It can miss some compatible ledgers of course if you don't know them // fills out retLedger if there is a consensusLedger you can check // fills out retHash if there isn't a consensusLedger to check. We need to fetch this ledger // returns false if there isn't a consensus yet or we are in the consensus bool getConsensusLedger(uint32 ledgerIndex, uint256& ourHash, Ledger::pointer& retLedger, uint256& retHash); int getSeqNum(uint32 ledgerIndex); }; #endif