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.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::Logger log = logger::log("PostgresBlockQuery"));
33 
35  std::unique_ptr<soci::session> sql,
36  KeyValueStorage &file_store,
37  std::shared_ptr<shared_model::interface::BlockJsonDeserializer>
38  converter,
39  logger::Logger log = logger::log("PostgresBlockQuery"));
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>,
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::Logger 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:62
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:41
std::vector< wBlock > getBlocks(shared_model::interface::types::HeightType height, uint32_t count) override
Definition: postgres_block_query.cpp:40
Definition: hash.hpp:18
Definition: block_query.hpp:22
uint32_t getTopBlockHeight() override
Definition: postgres_block_query.cpp:101
string(REPLACE".""/"CMAKE_SWIG_OUTDIR ${SWIG_JAVA_PKG}) else() set(CMAKE_SWIG_FLAGS"") endif() myswig_add_library(irohajava LANGUAGE java SOURCES bindings.i) unset(CMAKE_SWIG_FLAGS) swig_link_libraries(irohajava $
Definition: CMakeLists.txt:54
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
boost::optional< TxCacheStatusType > checkTxPresence(const shared_model::crypto::Hash &hash) override
Definition: postgres_block_query.cpp:74
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:67
Logger log(const std::string &tag)
Definition: logger.cpp:48
expected::Result< wBlock, std::string > getTopBlock() override
Definition: postgres_block_query.cpp:106
Definition: key_value_storage.hpp:20
PostgresBlockQuery(soci::session &sql, KeyValueStorage &file_store, std::shared_ptr< shared_model::interface::BlockJsonDeserializer > converter, logger::Logger log=logger::log("PostgresBlockQuery"))
Definition: postgres_block_query.cpp:17