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  namespace ametsuchi {
31  class PeerQuery;
32  } // namespace ametsuchi
33 
34  namespace validation {
36  public:
37  ChainValidatorImpl(std::shared_ptr<consensus::yac::SupermajorityChecker>
38  supermajority_checker,
39  logger::LoggerPtr log);
40 
41  bool validateAndApply(
42  rxcpp::observable<std::shared_ptr<shared_model::interface::Block>>
43  blocks,
44  ametsuchi::MutableStorage &storage) const override;
45 
46  private:
48  bool validatePreviousHash(
49  const shared_model::interface::Block &block,
50  const shared_model::interface::types::HashType &top_hash) const;
51 
53  bool validatePeerSupermajority(
54  const shared_model::interface::Block &block,
55  const std::vector<std::shared_ptr<shared_model::interface::Peer>>
56  &peers) const;
57 
62  bool validateBlock(
63  std::shared_ptr<const shared_model::interface::Block> block,
64  // TODO 30.01.2019 lebdron: IR-265 Remove PeerQueryFactory
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::LoggerPtr 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< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
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
Definition: command_executor.hpp:12