Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/orphanproofpool.h
// Copyright (c) 2021 The Bitcoin developers | // Copyright (c) 2021 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H | #ifndef BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H | ||||
#define BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H | #define BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <boost/multi_index/hashed_index.hpp> | #include <boost/multi_index/hashed_index.hpp> | ||||
#include <boost/multi_index/sequenced_index.hpp> | #include <boost/multi_index/sequenced_index.hpp> | ||||
#include <boost/multi_index_container.hpp> | #include <boost/multi_index_container.hpp> | ||||
#include <memory> | #include <memory> | ||||
namespace avalanche { | namespace avalanche { | ||||
class PeerManager; | |||||
// Extracts a ProofId from a Proof | // Extracts a ProofId from a Proof | ||||
struct proofid_extractor { | struct proofid_extractor { | ||||
using result_type = ProofId; | using result_type = ProofId; | ||||
result_type operator()(const std::shared_ptr<Proof> &proof) const { | result_type operator()(const std::shared_ptr<Proof> &proof) const { | ||||
return proof->getId(); | return proof->getId(); | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public: | ||||
bool removeProof(const ProofId &proofId); | bool removeProof(const ProofId &proofId); | ||||
/** | /** | ||||
* Get a pointer to a proof by id, or nullptr if the proof is not in the | * Get a pointer to a proof by id, or nullptr if the proof is not in the | ||||
* pool. | * pool. | ||||
*/ | */ | ||||
std::shared_ptr<Proof> getProof(const ProofId &proofId) const; | std::shared_ptr<Proof> getProof(const ProofId &proofId) const; | ||||
/** | |||||
* Rescan the pool to remove previously orphaned proofs that have become | |||||
* good or permanently bad. | |||||
*/ | |||||
void rescan(PeerManager &peerManager); | |||||
// For testing | // For testing | ||||
size_t getNProofs() const; | size_t getNProofs() const; | ||||
size_t getNStakes() const; | size_t getNStakes() const; | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H | #endif // BITCOIN_AVALANCHE_ORPHANPROOFPOOL_H |