hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
chain_validator_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_CHAIN_VALIDATOR_IMPL_HPP
7 #define IROHA_CHAIN_VALIDATOR_IMPL_HPP
8 
10 
11 #include <memory>
12 
14 #include "logger/logger.hpp"
15 
16 namespace shared_model {
17  namespace interface {
18  class Peer;
19  } // namespace interface
20 } // namespace shared_model
21 
22 namespace iroha {
23 
24  namespace consensus {
25  namespace yac {
26  class SupermajorityChecker;
27  } // namespace yac
28  } // namespace consensus
29 
30  namespace ametsuchi {
31  class PeerQuery;
32  } // namespace ametsuchi
33 
34  namespace validation {
36  public:
37  explicit ChainValidatorImpl(
38  std::shared_ptr<consensus::yac::SupermajorityChecker>
39  supermajority_checker,
40  logger::Logger log = logger::log("ChainValidator"));
41 
42  bool validateAndApply(
43  rxcpp::observable<std::shared_ptr<shared_model::interface::Block>>
44  blocks,
45  ametsuchi::MutableStorage &storage) const override;
46 
47  private:
49  bool validatePreviousHash(
50  const shared_model::interface::Block &block,
51  const shared_model::interface::types::HashType &top_hash) const;
52 
54  bool validatePeerSupermajority(
55  const shared_model::interface::Block &block,
56  const std::vector<std::shared_ptr<shared_model::interface::Peer>>
57  &peers) const;
58 
63  bool validateBlock(
64  const shared_model::interface::Block &block,
65  ametsuchi::PeerQuery &queries,
66  const shared_model::interface::types::HashType &top_hash) const;
67 
71  std::shared_ptr<consensus::yac::SupermajorityChecker>
72  supermajority_checker_;
73 
74  logger::Logger log_;
75  };
76  } // namespace validation
77 } // namespace iroha
78 
79 #endif // IROHA_CHAIN_VALIDATOR_IMPL_HPP
Definition: hash.hpp:18
Definition: peer_query.hpp:25
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block.hpp:15
Definition: chain_validator.hpp:28
Definition: block_query.hpp:16
Definition: chain_validator_impl.hpp:35
Definition: mutable_storage.hpp:30
Logger log(const std::string &tag)
Definition: logger.cpp:48
Definition: command_executor.hpp:12