Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.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_H | #ifndef BITCOIN_AVALANCHE_H | ||||
#define BITCOIN_AVALANCHE_H | #define BITCOIN_AVALANCHE_H | ||||
#include <blockindexworkcomparator.h> | #include <blockindexworkcomparator.h> | ||||
#include <key.h> | |||||
#include <net.h> | #include <net.h> | ||||
#include <protocol.h> // for CInv | #include <protocol.h> // for CInv | ||||
#include <rwcollection.h> | #include <rwcollection.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <uint256.h> | #include <uint256.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> | ||||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | private: | ||||
* Start stop machinery. | * Start stop machinery. | ||||
*/ | */ | ||||
std::atomic<bool> stopRequest; | std::atomic<bool> stopRequest; | ||||
bool running GUARDED_BY(cs_running); | bool running GUARDED_BY(cs_running); | ||||
Mutex cs_running; | Mutex cs_running; | ||||
std::condition_variable cond_running; | std::condition_variable cond_running; | ||||
CKey sessionKey; | |||||
public: | public: | ||||
AvalancheProcessor(CConnman *connmanIn); | AvalancheProcessor(CConnman *connmanIn); | ||||
~AvalancheProcessor(); | ~AvalancheProcessor(); | ||||
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; | ||||
void sendResponse(CNode *pfrom, AvalancheResponse response) const; | void sendResponse(CNode *pfrom, AvalancheResponse response) const; | ||||
bool registerVotes(NodeId nodeid, const AvalancheResponse &response, | bool registerVotes(NodeId nodeid, const AvalancheResponse &response, | ||||
std::vector<AvalancheBlockUpdate> &updates); | std::vector<AvalancheBlockUpdate> &updates); | ||||
bool addPeer(NodeId nodeid, int64_t score); | bool addPeer(NodeId nodeid, int64_t score); | ||||
CPubKey getSessionPubKey() const { return sessionKey.GetPubKey(); } | |||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
private: | private: | ||||
void runEventLoop(); | void runEventLoop(); | ||||
void clearTimedoutRequests(); | void clearTimedoutRequests(); | ||||
std::vector<CInv> getInvsForNextPoll(bool forPoll = true) const; | std::vector<CInv> getInvsForNextPoll(bool forPoll = true) const; | ||||
NodeId getSuitableNodeToQuery(); | NodeId getSuitableNodeToQuery(); | ||||
Show All 10 Lines |