hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
block_loader_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_BLOCK_LOADER_IMPL_HPP
7 #define IROHA_BLOCK_LOADER_IMPL_HPP
8 
10 
11 #include <unordered_map>
12 
15 #include "loader.grpc.pb.h"
16 #include "logger/logger.hpp"
17 
18 namespace iroha {
19  namespace network {
20  class BlockLoaderImpl : public BlockLoader {
21  public:
23  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory,
25  logger::Logger log = logger::log("BlockLoaderImpl"));
26 
27  rxcpp::observable<std::shared_ptr<shared_model::interface::Block>>
30  const shared_model::crypto::PublicKey &peer_pubkey) override;
31 
32  boost::optional<std::shared_ptr<shared_model::interface::Block>>
34  const shared_model::crypto::PublicKey &peer_pubkey,
35  const shared_model::interface::types::HashType &block_hash) override;
36 
37  private:
44  boost::optional<std::shared_ptr<shared_model::interface::Peer>> findPeer(
45  const shared_model::crypto::PublicKey &pubkey);
51  proto::Loader::Stub &getPeerStub(
52  const shared_model::interface::Peer &peer);
53 
55  std::unique_ptr<proto::Loader::Stub>>
56  peer_connections_;
57  std::shared_ptr<ametsuchi::PeerQueryFactory> peer_query_factory_;
59 
60  logger::Logger log_;
61  };
62  } // namespace network
63 } // namespace iroha
64 
65 #endif // IROHA_BLOCK_LOADER_IMPL_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:41
Definition: hash.hpp:18
std::string AddressType
Type of peer address.
Definition: types.hpp:43
Definition: peer.hpp:18
BlockLoaderImpl(std::shared_ptr< ametsuchi::PeerQueryFactory > peer_query_factory, shared_model::proto::ProtoBlockFactory factory, logger::Logger log=logger::log("BlockLoaderImpl"))
Definition: block_loader_impl.cpp:27
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_loader.hpp:21
Definition: block_query.hpp:16
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: public_key.hpp:16
rxcpp::observable< std::shared_ptr< shared_model::interface::Block > > retrieveBlocks(const shared_model::interface::types::HeightType height, const shared_model::crypto::PublicKey &peer_pubkey) override
Definition: block_loader_impl.cpp:35
boost::optional< std::shared_ptr< shared_model::interface::Block > > retrieveBlock(const shared_model::crypto::PublicKey &peer_pubkey, const shared_model::interface::types::HashType &block_hash) override
Definition: block_loader_impl.cpp:74
Definition: block_loader_impl.hpp:20
Definition: proto_block_factory.hpp:20