Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofpool.h
Show All 9 Lines | |||||
#include <avalanche/proofid.h> | #include <avalanche/proofid.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <boost/multi_index/hashed_index.hpp> | #include <boost/multi_index/hashed_index.hpp> | ||||
#include <boost/multi_index/mem_fun.hpp> | #include <boost/multi_index/mem_fun.hpp> | ||||
#include <boost/multi_index_container.hpp> | #include <boost/multi_index_container.hpp> | ||||
#include <chrono> | |||||
#include <cstdint> | #include <cstdint> | ||||
namespace avalanche { | namespace avalanche { | ||||
class PeerManager; | class PeerManager; | ||||
struct ProofPoolEntry { | struct ProofPoolEntry { | ||||
size_t utxoIndex; | size_t utxoIndex; | ||||
Show All 33 Lines | boost::multi_index_container< | ||||
&ProofPoolEntry::getUTXO>, | &ProofPoolEntry::getUTXO>, | ||||
SaltedOutpointHasher>, | SaltedOutpointHasher>, | ||||
// index by proofid | // index by proofid | ||||
bmi::hashed_non_unique<bmi::tag<by_proofid>, | bmi::hashed_non_unique<bmi::tag<by_proofid>, | ||||
ProofPoolEntryProofIdKeyExtractor, | ProofPoolEntryProofIdKeyExtractor, | ||||
SaltedProofIdHasher>>> | SaltedProofIdHasher>>> | ||||
pool; | pool; | ||||
std::unordered_map<ProofId, std::chrono::seconds, SaltedProofIdHasher> | |||||
registrationTime; | |||||
public: | public: | ||||
enum AddProofStatus { | enum AddProofStatus { | ||||
REJECTED = 0, //!< Rejected due to conflicts | REJECTED = 0, //!< Rejected due to conflicts | ||||
SUCCEED = 1, //!< Added successfully | SUCCEED = 1, //!< Added successfully | ||||
DUPLICATED = 2, //!< Already in pool | DUPLICATED = 2, //!< Already in pool | ||||
}; | }; | ||||
using ConflictingProofSet = std::set<ProofRef, ConflictingProofComparator>; | using ConflictingProofSet = std::set<ProofRef, ConflictingProofComparator>; | ||||
Show All 22 Lines | public: | ||||
bool removeProof(ProofRef proof); | bool removeProof(ProofRef proof); | ||||
void rescan(PeerManager &peerManager); | void rescan(PeerManager &peerManager); | ||||
ProofRef getProof(const ProofId &proofid) const; | ProofRef getProof(const ProofId &proofid) const; | ||||
ProofRef getProof(const COutPoint &outpoint) const; | ProofRef getProof(const COutPoint &outpoint) const; | ||||
std::chrono::seconds getRegistrationTime(const ProofId &proofid) const; | |||||
size_t size() const { return pool.size(); } | size_t size() const { return pool.size(); } | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOFPOOL_H | #endif // BITCOIN_AVALANCHE_PROOFPOOL_H |