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 
14 #include "logger/logger_fwd.hpp"
15 
16 namespace iroha {
17  namespace ametsuchi {
19  public:
20  using BlockTransportFactory =
24 
25  PostgresBlockStorage(soci::session &sql,
26  std::shared_ptr<BlockTransportFactory> block_factory,
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:
46  template <typename T, typename F>
47  boost::optional<soci::rowset<T>> execute(F &&f) const;
48 
49  soci::session &sql_;
50  std::shared_ptr<BlockTransportFactory> block_factory_;
51  logger::LoggerPtr log_;
52  };
53  } // namespace ametsuchi
54 } // namespace iroha
55 
56 #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
size_t size() const override
Definition: postgres_block_storage.cpp:103
PostgresBlockStorage(soci::session &sql, std::shared_ptr< BlockTransportFactory > block_factory, logger::LoggerPtr log)
Definition: postgres_block_storage.cpp:13
Definition: block_storage.hpp:22
bool insert(std::shared_ptr< const shared_model::interface::Block > block) override
Definition: postgres_block_storage.cpp:21
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block.hpp:15
iroha::protocol::Block_v1 TransportType
Definition: block.hpp:18
Definition: block_query.hpp:14
Definition: postgres_block_storage.hpp:18
void clear() override
Definition: postgres_block_storage.cpp:113
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
void forEach(FunctionType function) const override
Definition: postgres_block_storage.cpp:122
boost::optional< std::shared_ptr< const shared_model::interface::Block > > fetch(shared_model::interface::types::HeightType height) const override
Definition: postgres_block_storage.cpp:64