TARAXA
Loading...
Searching...
No Matches
ext_votes_packet_handler.hpp
Go to the documentation of this file.
1#pragma once
2
6#include "packet_handler.hpp"
8#include "vote/pbft_vote.hpp"
11
13
19 public:
20 ExtVotesPacketHandler(const FullNodeConfig& conf, std::shared_ptr<PeersState> peers_state,
21 std::shared_ptr<TimePeriodPacketsStats> packets_stats, std::shared_ptr<PbftManager> pbft_mgr,
22 std::shared_ptr<PbftChain> pbft_chain, std::shared_ptr<VoteManager> vote_mgr,
23 std::shared_ptr<SlashingManager> slashing_manager, const std::string& log_channel_name);
24
25 virtual ~ExtVotesPacketHandler() = default;
30
40 bool processVote(const std::shared_ptr<PbftVote>& vote, const std::shared_ptr<PbftBlock>& pbft_block,
41 const std::shared_ptr<TaraxaPeer>& peer, bool validate_max_round_step);
42
48 bool isPbftRelevantVote(const std::shared_ptr<PbftVote>& vote) const;
49
50 void requestPbftNextVotesAtPeriodRound(const dev::p2p::NodeID& peerID, PbftPeriod pbft_period, PbftRound pbft_round);
51
52 private:
61 std::pair<bool, std::string> validateVotePeriodRoundStep(const std::shared_ptr<PbftVote>& vote,
62 const std::shared_ptr<TaraxaPeer>& peer,
63 bool validate_max_round_step);
64
72 bool validateVoteAndBlock(const std::shared_ptr<PbftVote>& vote, const std::shared_ptr<PbftBlock>& pbft_block) const;
73
74 protected:
75 constexpr static size_t kMaxVotesInBundleRlp{1000};
76 constexpr static std::chrono::seconds kSyncRequestInterval = std::chrono::seconds(10);
77
78 mutable std::chrono::system_clock::time_point last_votes_sync_request_time_;
79 mutable std::chrono::system_clock::time_point last_pbft_block_sync_request_time_;
80
81 std::shared_ptr<PbftManager> pbft_mgr_;
82 std::shared_ptr<PbftChain> pbft_chain_;
83 std::shared_ptr<VoteManager> vote_mgr_;
84 std::shared_ptr<SlashingManager> slashing_manager_;
85};
86
87} // namespace taraxa::network::tarcap
ExtVotesPacketHandler is extended abstract PacketHandler with added functions that are used in packet...
Definition ext_votes_packet_handler.hpp:18
std::chrono::system_clock::time_point last_pbft_block_sync_request_time_
Definition ext_votes_packet_handler.hpp:79
std::pair< bool, std::string > validateVotePeriodRoundStep(const std::shared_ptr< PbftVote > &vote, const std::shared_ptr< TaraxaPeer > &peer, bool validate_max_round_step)
Validates vote period, round and step against max values from config.
Definition ext_votes_packet_handler.cpp:71
bool validateVoteAndBlock(const std::shared_ptr< PbftVote > &vote, const std::shared_ptr< PbftBlock > &pbft_block) const
Validates provided vote if voted value == provided block.
Definition ext_votes_packet_handler.cpp:153
ExtVotesPacketHandler & operator=(const ExtVotesPacketHandler &)=delete
ExtVotesPacketHandler(const ExtVotesPacketHandler &)=delete
static constexpr std::chrono::seconds kSyncRequestInterval
Definition ext_votes_packet_handler.hpp:76
static constexpr size_t kMaxVotesInBundleRlp
Definition ext_votes_packet_handler.hpp:75
void requestPbftNextVotesAtPeriodRound(const dev::p2p::NodeID &peerID, PbftPeriod pbft_period, PbftRound pbft_round)
Definition ext_votes_packet_handler.cpp:188
ExtVotesPacketHandler(ExtVotesPacketHandler &&)=delete
std::chrono::system_clock::time_point last_votes_sync_request_time_
Definition ext_votes_packet_handler.hpp:78
bool isPbftRelevantVote(const std::shared_ptr< PbftVote > &vote) const
Checks is vote is relevant for current pbft state in terms of period, round and type.
Definition ext_votes_packet_handler.cpp:170
std::shared_ptr< PbftChain > pbft_chain_
Definition ext_votes_packet_handler.hpp:82
ExtVotesPacketHandler & operator=(ExtVotesPacketHandler &&)=delete
std::shared_ptr< PbftManager > pbft_mgr_
Definition ext_votes_packet_handler.hpp:81
bool processVote(const std::shared_ptr< PbftVote > &vote, const std::shared_ptr< PbftBlock > &pbft_block, const std::shared_ptr< TaraxaPeer > &peer, bool validate_max_round_step)
Process vote.
Definition ext_votes_packet_handler.cpp:27
std::shared_ptr< VoteManager > vote_mgr_
Definition ext_votes_packet_handler.hpp:83
std::shared_ptr< SlashingManager > slashing_manager_
Definition ext_votes_packet_handler.hpp:84
Packet handler base class that consists of shared state and some commonly used functions.
Definition packet_handler.hpp:33
Definition vote_manager.hpp:24
uint32_t PbftRound
Definition types.hpp:26
EthBlockNumber PbftPeriod
Definition types.hpp:25
Definition config.hpp:41