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/orphanproofpool.h> | #include <avalanche/orphanproofpool.h> | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <interfaces/handler.h> | |||||
#include <pubkey.h> | #include <pubkey.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> | ||||
#include <boost/multi_index/hashed_index.hpp> | #include <boost/multi_index/hashed_index.hpp> | ||||
#include <boost/multi_index/member.hpp> | #include <boost/multi_index/member.hpp> | ||||
#include <boost/multi_index/ordered_index.hpp> | #include <boost/multi_index/ordered_index.hpp> | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | class PeerManager { | ||||
OrphanProofPool orphanProofs{AVALANCHE_ORPHANPROOFPOOL_SIZE}; | 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: | ||||
class ConflictingProofHandler { | |||||
public: | |||||
virtual void onConflictingProof(const std::shared_ptr<Proof> &proof, | |||||
bool accepted) {} | |||||
virtual ~ConflictingProofHandler() {} | |||||
}; | |||||
std::unordered_set<std::shared_ptr<ConflictingProofHandler>> | |||||
conflictingProofHandlers; | |||||
/** Conflicting proof callback */ | |||||
std::unique_ptr<interfaces::Handler> | |||||
handleConflictingProof(std::shared_ptr<ConflictingProofHandler> handler); | |||||
/** | /** | ||||
* 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); | ||||
// Update when a node is to be polled next. | // Update when a node is to be polled next. | ||||
bool updateNextRequestTime(NodeId nodeid, TimePoint timeout); | bool updateNextRequestTime(NodeId nodeid, TimePoint timeout); | ||||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |