Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.h
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 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_PEERMANAGER_H | #ifndef BITCOIN_AVALANCHE_PEERMANAGER_H | ||||
#define BITCOIN_AVALANCHE_PEERMANAGER_H | #define BITCOIN_AVALANCHE_PEERMANAGER_H | ||||
#include <avalanche/node.h> | #include <avalanche/node.h> | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <avalanche/proofpool.h> | #include <avalanche/proofpool.h> | ||||
#include <avalanche/proofradixtreeadapter.h> | #include <avalanche/proofradixtreeadapter.h> | ||||
#include <bloom.h> | |||||
#include <coins.h> | #include <coins.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <radix.h> | #include <radix.h> | ||||
#include <salteduint256hasher.h> | #include <salteduint256hasher.h> | ||||
#include <util/time.h> | #include <util/time.h> | ||||
#include <boost/multi_index/composite_key.hpp> | #include <boost/multi_index/composite_key.hpp> | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
enum class ProofRegistrationResult { | enum class ProofRegistrationResult { | ||||
NONE = 0, | NONE = 0, | ||||
ALREADY_REGISTERED, | ALREADY_REGISTERED, | ||||
ORPHAN, | ORPHAN, | ||||
INVALID, | INVALID, | ||||
CONFLICTING, | CONFLICTING, | ||||
REJECTED, | REJECTED, | ||||
COOLDOWN_NOT_ELAPSED, | COOLDOWN_NOT_ELAPSED, | ||||
DANGLING, | |||||
}; | }; | ||||
class ProofRegistrationState : public ValidationState<ProofRegistrationResult> { | class ProofRegistrationState : public ValidationState<ProofRegistrationResult> { | ||||
}; | }; | ||||
namespace bmi = boost::multi_index; | namespace bmi = boost::multi_index; | ||||
class PeerManager { | class PeerManager { | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | class PeerManager { | ||||
static constexpr int SELECT_NODE_MAX_RETRY = 3; | static constexpr int SELECT_NODE_MAX_RETRY = 3; | ||||
/** | /** | ||||
* 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; | ||||
/** | /** | ||||
* Remember the last proofs that have been evicted because they had no node | |||||
* attached. | |||||
* A false positive would cause the proof to fail to register if there is | |||||
* no previously known node that is claiming it, which is acceptable | |||||
* intended the low expected false positive rate. | |||||
*/ | |||||
CRollingBloomFilter danglingProofIds{10000, 0.00001}; | |||||
/** | |||||
* Quorum management. | * Quorum management. | ||||
*/ | */ | ||||
uint32_t totalPeersScore = 0; | uint32_t totalPeersScore = 0; | ||||
uint32_t connectedPeersScore = 0; | uint32_t connectedPeersScore = 0; | ||||
public: | public: | ||||
/** | /** | ||||
* Node API. | * Node API. | ||||
▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines |