hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
postgres_block_storage.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_POSTGRES_BLOCK_STORAGE_HPP
7 #define IROHA_POSTGRES_BLOCK_STORAGE_HPP
8 
10 
16 #include "logger/logger_fwd.hpp"
17 
18 namespace iroha {
19  namespace ametsuchi {
21  public:
23 
24  PostgresBlockStorage(std::shared_ptr<PoolWrapper> pool_wrapper,
25  std::shared_ptr<BlockTransportFactory> block_factory,
26  std::string table,
27  logger::LoggerPtr log);
28 
29  bool insert(
30  std::shared_ptr<const shared_model::interface::Block> block) override;
31 
32  boost::optional<std::shared_ptr<const shared_model::interface::Block>>
34 
35  size_t size() const override;
36 
37  void clear() override;
38 
39  void forEach(FunctionType function) const override;
40 
41  private:
42  struct HeightRange {
45  };
46 
48  boost::optional<HeightRange> getBlockHeightsRange() const;
49 
50  protected:
51  std::shared_ptr<PoolWrapper> pool_wrapper_;
52  std::shared_ptr<BlockTransportFactory> block_factory_;
53  std::string table_;
55  };
56 
58  public:
60  std::shared_ptr<PoolWrapper> pool_wrapper,
61  std::shared_ptr<BlockTransportFactory> block_factory,
62  std::string table,
63  logger::LoggerPtr log);
65  };
66  } // namespace ametsuchi
67 } // namespace iroha
68 
69 #endif // IROHA_POSTGRES_BLOCK_STORAGE_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
static const model::converters::PbBlockFactory block_factory
Definition: sha3_hash.cpp:15
PostgresBlockStorage(std::shared_ptr< PoolWrapper > pool_wrapper, std::shared_ptr< BlockTransportFactory > block_factory, std::string table, logger::LoggerPtr log)
Definition: postgres_block_storage.cpp:15
size_t size() const override
Definition: postgres_block_storage.cpp:99
Definition: block_storage.hpp:22
bool insert(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: postgres_block_storage.cpp:25
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block_query.hpp:14
std::string table_
Definition: postgres_block_storage.hpp:53
std::shared_ptr< PoolWrapper > pool_wrapper_
Definition: postgres_block_storage.hpp:51
Definition: postgres_block_storage.hpp:20
void clear() override
Definition: postgres_block_storage.cpp:107
std::function< void(std::shared_ptr< const shared_model::interface::Block >)> FunctionType
type of function which can be applied to the elements of the storage
Definition: block_storage.hpp:51
logger::LoggerPtr log_
Definition: postgres_block_storage.hpp:54
void forEach(FunctionType function) const override
Definition: postgres_block_storage.cpp:117
std::shared_ptr< BlockTransportFactory > block_factory_
Definition: postgres_block_storage.hpp:52
boost::optional< std::shared_ptr< const shared_model::interface::Block > > fetch(shared_model::interface::types::HeightType height) const override
Definition: postgres_block_storage.cpp:59
Definition: postgres_block_storage.hpp:57
Definition: proto_block_factory.hpp:20