hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
postgres_block_query.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_POSTGRES_FLAT_BLOCK_QUERY_HPP
7 #define IROHA_POSTGRES_FLAT_BLOCK_QUERY_HPP
8 
10 
11 #include <soci/soci.h>
12 #include <boost/optional.hpp>
15 #include "logger/logger_fwd.hpp"
16 
17 namespace iroha {
18  namespace ametsuchi {
19 
20  class FlatFile;
21 
25  class PostgresBlockQuery : public BlockQuery {
26  public:
28  soci::session &sql,
29  KeyValueStorage &file_store,
30  std::shared_ptr<shared_model::interface::BlockJsonDeserializer>
31  converter,
32  logger::LoggerPtr log);
33 
35  std::unique_ptr<soci::session> sql,
36  KeyValueStorage &file_store,
37  std::shared_ptr<shared_model::interface::BlockJsonDeserializer>
38  converter,
39  logger::LoggerPtr log);
40 
41  std::vector<wBlock> getBlocks(
43  uint32_t count) override;
44 
45  std::vector<wBlock> getBlocksFrom(
47 
48  std::vector<wBlock> getTopBlocks(uint32_t count) override;
49 
50  uint32_t getTopBlockHeight() override;
51 
52  boost::optional<TxCacheStatusType> checkTxPresence(
53  const shared_model::crypto::Hash &hash) override;
54 
55  expected::Result<wBlock, std::string> getTopBlock() override;
56 
57  private:
63  expected::Result<std::unique_ptr<shared_model::interface::Block>,
64  std::string>
66 
67  std::unique_ptr<soci::session> psql_;
68  soci::session &sql_;
69 
70  KeyValueStorage &block_store_;
71  std::shared_ptr<shared_model::interface::BlockJsonDeserializer>
72  converter_;
73 
74  logger::LoggerPtr log_;
75  };
76  } // namespace ametsuchi
77 } // namespace iroha
78 
79 #endif // IROHA_POSTGRES_FLAT_BLOCK_QUERY_HPP
std::vector< wBlock > getBlocksFrom(shared_model::interface::types::HeightType height) override
Definition: postgres_block_query.cpp:63
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:39
std::vector< wBlock > getBlocks(shared_model::interface::types::HeightType height, uint32_t count) override
Definition: postgres_block_query.cpp:41
Definition: hash.hpp:18
Definition: block_query.hpp:22
uint32_t getTopBlockHeight() override
Definition: postgres_block_query.cpp:102
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
boost::optional< TxCacheStatusType > checkTxPresence(const shared_model::crypto::Hash &hash) override
Definition: postgres_block_query.cpp:75
Definition: postgres_block_query.hpp:25
Definition: block_query.hpp:16
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
std::vector< wBlock > getTopBlocks(uint32_t count) override
Definition: postgres_block_query.cpp:68
expected::Result< wBlock, std::string > getTopBlock() override
Definition: postgres_block_query.cpp:107
PostgresBlockQuery(soci::session &sql, KeyValueStorage &file_store, std::shared_ptr< shared_model::interface::BlockJsonDeserializer > converter, logger::LoggerPtr log)
Definition: postgres_block_query.cpp:18
Definition: key_value_storage.hpp:20