Kagome
Polkadot Runtime Engine in C++17
synchronizer.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_NETWORK_SYNCHRONIZER
7 #define KAGOME_NETWORK_SYNCHRONIZER
8 
9 #include <libp2p/peer/peer_id.hpp>
10 
12 #include "outcome/outcome.hpp"
14 #include "primitives/common.hpp"
15 
16 namespace kagome::network {
17 
18  class Synchronizer {
19  public:
20  using SyncResultHandler =
21  std::function<void(outcome::result<primitives::BlockInfo>)>;
22 
23  virtual ~Synchronizer() = default;
24 
30  virtual bool syncByBlockInfo(const primitives::BlockInfo &block_info,
31  const libp2p::peer::PeerId &peer_id,
32  SyncResultHandler &&handler,
33  bool subscribe_to_block) = 0;
34 
41  virtual bool syncByBlockHeader(const primitives::BlockHeader &header,
42  const libp2p::peer::PeerId &peer_id,
43  SyncResultHandler &&handler) = 0;
44 
48  virtual void syncMissingJustifications(const libp2p::peer::PeerId &peer_id,
49  primitives::BlockInfo target_block,
50  std::optional<uint32_t> limit,
51  SyncResultHandler &&handler) = 0;
52 
53  virtual void syncState(const libp2p::peer::PeerId &peer_id,
54  const primitives::BlockInfo &block,
55  SyncResultHandler &&handler) = 0;
56 
57  virtual bool hasIncompleteRequestOfStateSync() const = 0;
58  };
59 
60 } // namespace kagome::network
61 
62 #endif // KAGOME_NETWORK_SYNCHRONIZER
virtual ~Synchronizer()=default
virtual void syncState(const libp2p::peer::PeerId &peer_id, const primitives::BlockInfo &block, SyncResultHandler &&handler)=0
virtual void syncMissingJustifications(const libp2p::peer::PeerId &peer_id, primitives::BlockInfo target_block, std::optional< uint32_t > limit, SyncResultHandler &&handler)=0
libp2p::peer::PeerId PeerId
std::function< void(outcome::result< primitives::BlockInfo >)> SyncResultHandler
virtual bool syncByBlockHeader(const primitives::BlockHeader &header, const libp2p::peer::PeerId &peer_id, SyncResultHandler &&handler)=0
virtual bool hasIncompleteRequestOfStateSync() const =0
virtual bool syncByBlockInfo(const primitives::BlockInfo &block_info, const libp2p::peer::PeerId &peer_id, SyncResultHandler &&handler, bool subscribe_to_block)=0