Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
Show All 31 Lines | |||||
static constexpr bool AVALANCHE_DEFAULT_PROOF_REPLACEMENT_ENABLED = false; | static constexpr bool AVALANCHE_DEFAULT_PROOF_REPLACEMENT_ENABLED = false; | ||||
namespace avalanche { | namespace avalanche { | ||||
/** | /** | ||||
* Maximum number of proofs to store per utxo. This will allow for conflict | * Maximum number of proofs to store per utxo. This will allow for conflict | ||||
* resolution when several proofs claim the same utxo. | * resolution when several proofs claim the same utxo. | ||||
*/ | */ | ||||
static constexpr size_t AVALANCHE_MAXPROOF_PER_UTXO = 1; | static constexpr size_t AVALANCHE_MAXPROOF_PER_UTXO = 2; | ||||
/** | |||||
* Maximum number of stakes in the orphanProofs. | |||||
* Benchmarking on a consumer grade computer shows that 10000 stakes can be | |||||
* verified in less than 1 second. | |||||
*/ | |||||
static constexpr size_t AVALANCHE_ORPHANPROOFPOOL_SIZE = 10000; | |||||
class Delegation; | class Delegation; | ||||
namespace { | namespace { | ||||
struct TestPeerManager; | struct TestPeerManager; | ||||
} | } | ||||
struct Slot { | struct Slot { | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | using PendingNodeSet = boost::multi_index_container< | ||||
bmi::tag<by_nodeid>, | bmi::tag<by_nodeid>, | ||||
bmi::member<PendingNode, NodeId, &PendingNode::nodeid>>>>; | bmi::member<PendingNode, NodeId, &PendingNode::nodeid>>>>; | ||||
PendingNodeSet pendingNodes; | PendingNodeSet pendingNodes; | ||||
static constexpr int SELECT_PEER_MAX_RETRY = 3; | static constexpr int SELECT_PEER_MAX_RETRY = 3; | ||||
static constexpr int SELECT_NODE_MAX_RETRY = 3; | static constexpr int SELECT_NODE_MAX_RETRY = 3; | ||||
/** | /** | ||||
* Tracks proof which for which the UTXO are unavailable. | |||||
*/ | |||||
OrphanProofPool orphanProofs{AVALANCHE_ORPHANPROOFPOOL_SIZE}; | |||||
/** | |||||
* Track proof ids to broadcast | * Track proof ids to broadcast | ||||
*/ | */ | ||||
std::unordered_set<ProofId, SaltedProofIdHasher> m_unbroadcast_proofids; | std::unordered_set<ProofId, SaltedProofIdHasher> m_unbroadcast_proofids; | ||||
public: | public: | ||||
// Limit the pool to a depth to a single proof per utxo | |||||
PeerManager(size_t maxProofsPerUtxo = AVALANCHE_MAXPROOF_PER_UTXO) | PeerManager(size_t maxProofsPerUtxo = AVALANCHE_MAXPROOF_PER_UTXO) | ||||
: pool(maxProofsPerUtxo) {} | : pool(maxProofsPerUtxo) {} | ||||
/** | /** | ||||
* Node API. | * Node API. | ||||
*/ | */ | ||||
bool addNode(NodeId nodeid, const ProofId &proofid); | bool addNode(NodeId nodeid, const ProofId &proofid); | ||||
bool removeNode(NodeId nodeid); | bool removeNode(NodeId nodeid); | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |