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_fwd.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  struct LedgerState;
31 
32  namespace validation {
34  public:
35  ChainValidatorImpl(std::shared_ptr<consensus::yac::SupermajorityChecker>
36  supermajority_checker,
37  logger::LoggerPtr log);
38 
39  bool validateAndApply(
40  rxcpp::observable<std::shared_ptr<shared_model::interface::Block>>
41  blocks,
42  ametsuchi::MutableStorage &storage) const override;
43 
44  private:
46  bool validatePreviousHash(
47  const shared_model::interface::Block &block,
48  const shared_model::interface::types::HashType &top_hash) const;
49 
51  bool validateHeight(
52  const shared_model::interface::Block &block,
53  const shared_model::interface::types::HeightType &top_height) const;
54 
56  bool validatePeerSupermajority(
57  const shared_model::interface::Block &block,
58  const std::vector<std::shared_ptr<shared_model::interface::Peer>>
59  &peers) const;
60 
65  bool validateBlock(
66  std::shared_ptr<const shared_model::interface::Block> block,
67  const iroha::LedgerState &ledger_state) const;
68 
72  std::shared_ptr<consensus::yac::SupermajorityChecker>
73  supermajority_checker_;
74 
75  logger::LoggerPtr log_;
76  };
77  } // namespace validation
78 } // namespace iroha
79 
80 #endif // IROHA_CHAIN_VALIDATOR_IMPL_HPP
uint64_t HeightType
Type of height (for Block, Proposal etc)
Definition: types.hpp:43
Definition: hash.hpp:18
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
Definition: block.hpp:16
Definition: chain_validator.hpp:30
Definition: block_query.hpp:14
Definition: chain_validator_impl.hpp:33
Definition: mutable_storage.hpp:30
Definition: ledger_state.hpp:23
Definition: command_executor.hpp:12