6 #ifndef KAGOME_NETWORK_GRANDPAROTOCOL 7 #define KAGOME_NETWORK_GRANDPAROTOCOL 13 #include <libp2p/basic/scheduler.hpp> 14 #include <libp2p/connection/stream.hpp> 15 #include <libp2p/host/host.hpp> 37 public std::enable_shared_from_this<GrandpaProtocol>,
46 std::shared_ptr<boost::asio::io_context> io_context,
48 std::shared_ptr<consensus::grandpa::GrandpaObserver> grandpa_observer,
50 std::shared_ptr<StreamEngine> stream_engine,
51 std::shared_ptr<PeerManager> peer_manager,
53 std::shared_ptr<libp2p::basic::Scheduler> scheduler);
59 bool start()
override;
63 return kGrandpaProtocolName;
66 void onIncomingStream(std::shared_ptr<Stream> stream)
override;
67 void newOutgoingStream(
69 std::function<
void(outcome::result<std::shared_ptr<Stream>>)> &&cb)
73 std::optional<const libp2p::peer::PeerId> peer_id);
76 std::optional<const libp2p::peer::PeerId> peer_id);
83 const static inline auto kGrandpaProtocolName =
"GrandpaProtocol"s;
85 void readHandshake(std::shared_ptr<Stream> stream,
87 std::function<
void(outcome::result<void>)> &&cb);
89 void writeHandshake(std::shared_ptr<Stream> stream,
91 std::function<
void(outcome::result<void>)> &&cb);
93 void read(std::shared_ptr<Stream> stream);
96 std::shared_ptr<Stream> stream,
98 std::function<
void(outcome::result<std::shared_ptr<Stream>>)> &&cb);
103 static constexpr std::chrono::milliseconds kRecentnessDuration =
104 std::chrono::seconds(300);
124 #endif // KAGOME_NETWORK_GRANDPAROTOCOL boost::variant< GrandpaVote, FullCommitMessage, GrandpaNeighborMessage, CatchUpRequest, CatchUpResponse > GrandpaMessage
const std::string & protocolName() const override
std::shared_ptr< boost::asio::io_context > io_context_
#define KAGOME_CACHE_UNIT(type)
std::shared_ptr< PeerManager > peer_manager_
libp2p::peer::PeerInfo PeerInfo
std::set< libp2p::peer::PeerId > recent_catchup_requests_by_peer_
libp2p::peer::PeerId PeerId
const OwnPeerInfo & own_info_
std::shared_ptr< consensus::grandpa::GrandpaObserver > grandpa_observer_
std::set< std::tuple< consensus::grandpa::RoundNumber, consensus::grandpa::VoterSetId > > recent_catchup_requests_by_round_
#define KAGOME_DECLARE_CACHE(prefix,...)
const application::AppConfiguration & app_config_
std::shared_ptr< StreamEngine > stream_engine_
std::shared_ptr< libp2p::basic::Scheduler > scheduler_