Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.h
Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | class Processor { | ||||
/** Event loop machinery. */ | /** Event loop machinery. */ | ||||
EventLoop eventLoop; | EventLoop eventLoop; | ||||
/** Registered interfaces::Chain::Notifications handler. */ | /** Registered interfaces::Chain::Notifications handler. */ | ||||
class NotificationsHandler; | class NotificationsHandler; | ||||
std::unique_ptr<interfaces::Handler> chainNotificationsHandler; | std::unique_ptr<interfaces::Handler> chainNotificationsHandler; | ||||
/** | /** | ||||
* Flag indicating that the proof must be registered at first new block | * Flag indicating that this node's proof must be registered at first | ||||
* after IBD | * new block after IBD | ||||
*/ | */ | ||||
bool mustRegisterProof = false; | bool mustRegisterProof = false; | ||||
/** | |||||
* Avalanche nodes met via peer-discovery waiting for IBD to end. | |||||
*/ | |||||
std::map<NodeId, std::tuple<Proof, Delegation>> nodesQueue; | |||||
public: | public: | ||||
Processor(interfaces::Chain &chain, CConnman *connmanIn, | Processor(interfaces::Chain &chain, CConnman *connmanIn, | ||||
NodePeerManager *nodePeerManagerIn); | NodePeerManager *nodePeerManagerIn); | ||||
~Processor(); | ~Processor(); | ||||
void setQueryTimeoutDuration(std::chrono::milliseconds d) { | void setQueryTimeoutDuration(std::chrono::milliseconds d) { | ||||
queryTimeoutDuration = d; | queryTimeoutDuration = d; | ||||
} | } | ||||
bool addBlockToReconcile(const CBlockIndex *pindex); | bool addBlockToReconcile(const CBlockIndex *pindex); | ||||
bool isAccepted(const CBlockIndex *pindex) const; | bool isAccepted(const CBlockIndex *pindex) const; | ||||
int getConfidence(const CBlockIndex *pindex) const; | int getConfidence(const CBlockIndex *pindex) const; | ||||
// 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 Proof &proof, | bool addNode(NodeId nodeid, const Proof &proof, | ||||
const Delegation &delegation); | const Delegation &delegation); | ||||
bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | bool forNode(NodeId nodeid, std::function<bool(const Node &n)> func) const; | ||||
/** | |||||
* Queue a node and its proof for registration after IBD | |||||
* @returns true if node was queued successfully, else false | |||||
*/ | |||||
bool queueNode(NodeId nodeId, Proof proof, Delegation delegation); | |||||
/** Get all queued nodes */ | |||||
const std::map<NodeId, std::tuple<Proof, Delegation>> &getNodesQueue(); | |||||
bool removeNodeFromQueue(NodeId nodeId); | |||||
void clearNodesQueue(); | |||||
CPubKey getSessionPubKey() const; | CPubKey getSessionPubKey() const; | ||||
bool sendHello(CNode *pfrom) const; | bool sendHello(CNode *pfrom) const; | ||||
/** | /** | ||||
* Build and return the challenge whose signature we expect a peer to | * Build and return the challenge whose signature we expect a peer to | ||||
* include in his AVAHELLO message. | * include in his AVAHELLO message. | ||||
*/ | */ | ||||
Show All 39 Lines |