Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche.h
Show All 24 Lines | |||||
#include <vector> | #include <vector> | ||||
class Config; | class Config; | ||||
class CBlockIndex; | class CBlockIndex; | ||||
class CScheduler; | class CScheduler; | ||||
namespace { | namespace { | ||||
/** | /** | ||||
* Is avalanche enabled by default. | |||||
*/ | |||||
static const bool AVALANCHE_DEFAULT_ENABLED = false; | |||||
/** | |||||
* Finalization score. | * Finalization score. | ||||
*/ | */ | ||||
static const int AVALANCHE_FINALIZATION_SCORE = 128; | static const int AVALANCHE_FINALIZATION_SCORE = 128; | ||||
/** | /** | ||||
* Maximum item that can be polled at once. | |||||
*/ | |||||
static const size_t AVALANCHE_MAX_ELEMENT_POLL = 16; | |||||
/** | |||||
* Avalanche default cooldown in milliseconds. | |||||
*/ | |||||
static const size_t AVALANCHE_DEFAULT_COOLDOWN = 100; | |||||
/** | |||||
* How long before we consider that a query timed out. | * How long before we consider that a query timed out. | ||||
*/ | */ | ||||
static const int AVALANCHE_DEFAULT_QUERY_TIMEOUT_DURATION_MILLISECONDS = 10000; | static const int AVALANCHE_DEFAULT_QUERY_TIMEOUT_DURATION_MILLISECONDS = 10000; | ||||
/** | /** | ||||
* How many inflight requests can exist for one item. | * How many inflight requests can exist for one item. | ||||
*/ | */ | ||||
static const int AVALANCHE_MAX_INFLIGHT_POLL = 10; | static const int AVALANCHE_MAX_INFLIGHT_POLL = 10; | ||||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | private: | ||||
*/ | */ | ||||
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; | ||||
public: | public: | ||||
AvalancheProcessor(CConnman *connmanIn) | AvalancheProcessor(CConnman *connmanIn); | ||||
: connman(connmanIn), | ~AvalancheProcessor(); | ||||
queryTimeoutDuration( | |||||
AVALANCHE_DEFAULT_QUERY_TIMEOUT_DURATION_MILLISECONDS), | |||||
round(0), stopRequest(false), running(false) {} | |||||
~AvalancheProcessor() { stopEventLoop(); } | |||||
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; | |||||
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); | ||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
Show All 15 Lines |