Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.h
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | class Processor { | ||||
/** Data required to participate. */ | /** Data required to participate. */ | ||||
struct PeerData; | struct PeerData; | ||||
std::unique_ptr<PeerData> peerData; | std::unique_ptr<PeerData> peerData; | ||||
CKey sessionKey; | CKey sessionKey; | ||||
/** Event loop machinery. */ | /** Event loop machinery. */ | ||||
EventLoop eventLoop; | EventLoop eventLoop; | ||||
/** | |||||
* Quorum management. | |||||
*/ | |||||
uint32_t minQuorumScore; | |||||
double minQuorumConnectedScoreRatio; | |||||
std::atomic<bool> quorumIsEstablished{false}; | |||||
/** 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; | ||||
Processor(const ArgsManager &argsman, interfaces::Chain &chain, | Processor(const ArgsManager &argsman, interfaces::Chain &chain, | ||||
CConnman *connmanIn, std::unique_ptr<PeerData> peerDataIn, | CConnman *connmanIn, std::unique_ptr<PeerData> peerDataIn, | ||||
CKey sessionKeyIn); | CKey sessionKeyIn, uint32_t minQuorumTotalScoreIn, | ||||
double minQuorumConnectedScoreRatioIn); | |||||
public: | public: | ||||
~Processor(); | ~Processor(); | ||||
static std::unique_ptr<Processor> MakeProcessor(const ArgsManager &argsman, | static std::unique_ptr<Processor> MakeProcessor(const ArgsManager &argsman, | ||||
interfaces::Chain &chain, | interfaces::Chain &chain, | ||||
CConnman *connman, | CConnman *connman, | ||||
bilingual_str &error); | bilingual_str &error); | ||||
Show All 29 Lines | public: | ||||
/* | /* | ||||
* 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; } | ||||
bool startEventLoop(CScheduler &scheduler); | bool startEventLoop(CScheduler &scheduler); | ||||
bool stopEventLoop(); | bool stopEventLoop(); | ||||
bool isQuorumEstablished(); | |||||
private: | private: | ||||
void runEventLoop(); | void runEventLoop(); | ||||
void clearTimedoutRequests(); | void clearTimedoutRequests(); | ||||
std::vector<CInv> getInvsForNextPoll(bool forPoll = true); | std::vector<CInv> getInvsForNextPoll(bool forPoll = true); | ||||
NodeId getSuitableNodeToQuery(); | NodeId getSuitableNodeToQuery(); | ||||
/** | /** | ||||
* Build and return the challenge whose signature is included in the | * Build and return the challenge whose signature is included in the | ||||
Show All 10 Lines |