Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.h
// Copyright (c) 2018-2019 The Bitcoin developers | // Copyright (c) 2018-2019 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_PROCESSOR_H | #ifndef BITCOIN_AVALANCHE_PROCESSOR_H | ||||
#define BITCOIN_AVALANCHE_PROCESSOR_H | #define BITCOIN_AVALANCHE_PROCESSOR_H | ||||
#include <avalanche/node.h> | #include <avalanche/node.h> | ||||
#include <avalanche/peermanager.h> | |||||
#include <avalanche/protocol.h> | #include <avalanche/protocol.h> | ||||
#include <blockindexworkcomparator.h> | #include <blockindexworkcomparator.h> | ||||
#include <eventloop.h> | #include <eventloop.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <interfaces/handler.h> | #include <interfaces/handler.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <rwcollection.h> | #include <rwcollection.h> | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | public: | ||||
// TDOD: Refactor the API to remove the dependency on avalanche/protocol.h | // TDOD: Refactor the API to remove the dependency on avalanche/protocol.h | ||||
void sendResponse(CNode *pfrom, Response response) const; | void sendResponse(CNode *pfrom, Response response) const; | ||||
bool registerVotes(NodeId nodeid, const Response &response, | bool registerVotes(NodeId nodeid, const Response &response, | ||||
std::vector<BlockUpdate> &updates); | std::vector<BlockUpdate> &updates); | ||||
bool addNode(NodeId nodeid, const ProofId &proofid); | bool addNode(NodeId nodeid, const ProofId &proofid); | ||||
bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | ||||
template <typename Callable> auto withPeerManager(Callable &&func) const { | |||||
LOCK(cs_peerManager); | |||||
return func(*peerManager); | |||||
} | |||||
CPubKey getSessionPubKey() const; | CPubKey getSessionPubKey() const; | ||||
bool sendHello(CNode *pfrom) const; | bool sendHello(CNode *pfrom) const; | ||||
bool addProof(const std::shared_ptr<Proof> &proof); | bool addProof(const std::shared_ptr<Proof> &proof); | ||||
std::shared_ptr<Proof> getProof(const ProofId &proofid) const; | std::shared_ptr<Proof> getProof(const ProofId &proofid) const; | ||||
std::shared_ptr<Proof> getLocalProof() const; | std::shared_ptr<Proof> getLocalProof() const; | ||||
std::chrono::seconds getProofRegistrationTime(const ProofId &proofid) const; | std::chrono::seconds getProofRegistrationTime(const ProofId &proofid) const; | ||||
std::shared_ptr<Proof> getOrphan(const ProofId &proofid) const; | std::shared_ptr<Proof> getOrphan(const ProofId &proofid) const; | ||||
/* | /* | ||||
* Return whether the avalanche service flag should be set. | * Return whether the avalanche service flag should be set. | ||||
*/ | */ | ||||
bool isAvalancheServiceAvailable() { return !!peerData; } | bool isAvalancheServiceAvailable() { return !!peerData; } | ||||
std::vector<avalanche::Peer> getPeers() const; | |||||
std::vector<NodeId> getNodeIdsForPeer(PeerId peerId) const; | |||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
void addUnbroadcastProof(const ProofId &proofid); | void addUnbroadcastProof(const ProofId &proofid); | ||||
void removeUnbroadcastProof(const ProofId &proofid); | void removeUnbroadcastProof(const ProofId &proofid); | ||||
void broadcastProofs(); | void broadcastProofs(); | ||||
private: | private: | ||||
Show All 17 Lines |