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; | |||||
| bool quorumAvailable; | |||||
| std::chrono::seconds quorumCheckTimeoutDuration; | |||||
| std::chrono::time_point<std::chrono::steady_clock> nextQuorumCheckAt; | |||||
| /** 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 minQuorumPeerScoreIn, | ||||
| double minQuorumNodeScoreRatioIn); | |||||
| 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 isQuorumAvailable(); | |||||
| 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 | |||||