5#ifndef BITCOIN_AVALANCHE_PROOFPOOL_H
6#define BITCOIN_AVALANCHE_PROOFPOOL_H
14#include <boost/multi_index/hashed_index.hpp>
15#include <boost/multi_index/mem_fun.hpp>
16#include <boost/multi_index/member.hpp>
17#include <boost/multi_index/ordered_index.hpp>
18#include <boost/multi_index_container.hpp>
21#include <unordered_set>
46 return entry.
proof->getId();
50namespace bmi = boost::multi_index;
52using ProofIdSet = std::unordered_set<ProofId, SaltedProofIdHasher>;
58 boost::multi_index_container<
68 bmi::hashed_non_unique<bmi::tag<by_proofid>,
72 bmi::ordered_non_unique<
73 bmi::tag<by_proof_score>,
74 bmi::member<ProofPoolEntry, ProofRef, &ProofPoolEntry::proof>,
115 std::unordered_set<ProofRef, SaltedProofHasher>
An outpoint - a combination of a transaction hash and an index n into its vout.
Map a proof to each utxo.
@ DUPLICATED
Already in pool.
@ REJECTED
Rejected due to conflicts.
@ SUCCEED
Added successfully.
AddProofStatus addProofIfNoConflict(const ProofRef &proof)
AddProofStatus addProofIfPreferred(const ProofRef &proof, ConflictingProofSet &conflictingProofs)
Attempt to add a proof to the pool.
AddProofStatus addProofIfNoConflict(const ProofRef &proof, ConflictingProofSet &conflictingProofs)
Attempt to add a proof to the pool, and fail if there is a conflict on any UTXO.
size_t countProofs() const
bool removeProof(ProofId proofid)
void forEachProof(Callable &&func) const
ProofRef getProof(const ProofId &proofid) const
std::set< ProofRef, ConflictingProofComparator > ConflictingProofSet
AddProofStatus addProofIfPreferred(const ProofRef &proof)
ProofRef getLowestScoreProof() const
boost::multi_index_container< ProofPoolEntry, bmi::indexed_by< bmi::hashed_unique< bmi::tag< by_utxo >, bmi::const_mem_fun< ProofPoolEntry, const COutPoint &, &ProofPoolEntry::getUTXO >, SaltedOutpointHasher >, bmi::hashed_non_unique< bmi::tag< by_proofid >, ProofPoolEntryProofIdKeyExtractor, SaltedProofIdHasher >, bmi::ordered_non_unique< bmi::tag< by_proof_score >, bmi::member< ProofPoolEntry, ProofRef, &ProofPoolEntry::proof >, ProofComparatorByScore > > > pool
std::unordered_set< ProofRef, SaltedProofHasher > rescan(PeerManager &peerManager)
ProofIdSet getProofIds() const
std::unordered_set< ProofId, SaltedProofIdHasher > ProofIdSet
Implement std::hash so RCUPtr can be used as a key for maps or sets.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Compare proofs by score, then by id in case of equality.
const COutPoint & getUTXO() const
ProofPoolEntry(size_t _utxoIndex, ProofRef _proof)