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 
12 
13 namespace shared_model {
14  namespace validation {
19  template <typename FieldValidator>
21  : public AbstractValidator<interface::BlocksQuery> {
22  BlocksQueryValidator(FieldValidator field_validator)
23  : field_validator_(std::move(field_validator)) {}
24 
25  public:
26  BlocksQueryValidator(std::shared_ptr<ValidatorsConfig> config)
27  : BlocksQueryValidator(FieldValidator(std::move(config))) {}
28 
34  std::optional<ValidationError> validate(
35  const interface::BlocksQuery &qry) const {
36  ValidationErrorCreator error_creator;
37 
38  error_creator |=
40  error_creator |=
42  error_creator |= field_validator_.validateCounter(qry.queryCounter());
43 
44  return std::move(error_creator).getValidationError("Blocks query");
45  }
46 
47  protected:
49  };
50  } // namespace validation
51 } // namespace shared_model
52 
53 #endif // IROHA_SHARED_MODEL_BLOCKS_QUERY_VALIDATOR_HPP
FieldValidator field_validator_
Definition: blocks_query_validator.hpp:48
Definition: blocks_query.hpp:20
Definition: abstract_validator.hpp:17
Definition: peer.hpp:48
virtual const types::AccountIdType & creatorAccountId() const =0
std::optional< ValidationError > validate(const interface::BlocksQuery &qry) const
Definition: blocks_query_validator.hpp:34
BlocksQueryValidator(std::shared_ptr< ValidatorsConfig > config)
Definition: blocks_query_validator.hpp:26
virtual types::TimestampType createdTime() const =0
std::optional< ValidationError > validateCreatedTime(interface::types::TimestampType timestamp, interface::types::TimestampType now) const
Definition: field_validator.cpp:281
Definition: blocks_query_validator.hpp:20
std::optional< ValidationError > validateCounter(const interface::types::CounterType &counter) const
Definition: field_validator.cpp:302
std::optional< ValidationError > validateCreatorAccountId(const interface::types::AccountIdType &account_id) const
Definition: field_validator.cpp:267
Definition: field_validator.hpp:41
Helper class for ValidationError creation.
Definition: validation_error_helpers.hpp:16
Definition: command_executor.hpp:12
virtual types::CounterType queryCounter() const =0