hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
blocks_query_validator.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SHARED_MODEL_BLOCKS_QUERY_VALIDATOR_HPP
7 #define IROHA_SHARED_MODEL_BLOCKS_QUERY_VALIDATOR_HPP
8 
10 #include "validators/answer.hpp"
11 
12 namespace shared_model {
13  namespace validation {
18  template <typename FieldValidator>
20  : public AbstractValidator<interface::BlocksQuery> {
21  BlocksQueryValidator(FieldValidator field_validator)
22  : field_validator_(std::move(field_validator)) {}
23 
24  public:
25  BlocksQueryValidator(std::shared_ptr<ValidatorsConfig> config)
26  : BlocksQueryValidator(FieldValidator(std::move(config))) {}
27 
34  Answer answer;
35  std::string qry_reason_name = "Blocks query";
36  ReasonsGroupType qry_reason(qry_reason_name, GroupedReasons());
37 
39  qry.creatorAccountId());
42 
43  if (not qry_reason.second.empty()) {
44  answer.addReason(std::move(qry_reason));
45  }
46  return answer;
47  }
48 
49  protected:
52  };
53  } // namespace validation
54 } // namespace shared_model
55 
56 #endif // IROHA_SHARED_MODEL_BLOCKS_QUERY_VALIDATOR_HPP
Answer answer_
Definition: blocks_query_validator.hpp:50
FieldValidator field_validator_
Definition: blocks_query_validator.hpp:51
void validateCreatedTime(ReasonsGroupType &reason, interface::types::TimestampType timestamp, interface::types::TimestampType now) const
Definition: field_validator.cpp:281
Definition: blocks_query.hpp:20
void addReason(ReasonsGroupType &&reasons)
Definition: answer.hpp:64
Definition: abstract_validator.hpp:16
Definition: peer.hpp:48
virtual const types::AccountIdType & creatorAccountId() const =0
BlocksQueryValidator(std::shared_ptr< ValidatorsConfig > config)
Definition: blocks_query_validator.hpp:25
Answer validate(const interface::BlocksQuery &qry) const
Definition: blocks_query_validator.hpp:33
virtual types::TimestampType createdTime() const =0
Definition: blocks_query_validator.hpp:19
void validateCounter(ReasonsGroupType &reason, const interface::types::CounterType &counter) const
Definition: field_validator.cpp:308
Definition: field_validator.hpp:35
std::vector< ConcreteReasonType > GroupedReasons
Definition: answer.hpp:20
std::pair< ReasonsGroupName, GroupedReasons > ReasonsGroupType
Definition: answer.hpp:22
Definition: command_executor.hpp:12
void validateCreatorAccountId(ReasonsGroupType &reason, const interface::types::AccountIdType &account_id) const
Definition: field_validator.cpp:268
Definition: answer.hpp:28
virtual types::CounterType queryCounter() const =0