6 #ifndef IROHA_PROTO_BLOCKS_QUERY_BUILDER_TEMPLATE_HPP 7 #define IROHA_PROTO_BLOCKS_QUERY_BUILDER_TEMPLATE_HPP 14 #include "module/irohad/common/validators_config.hpp" 15 #include "queries.pb.h" 31 typename BT = UnsignedWrapper<BlocksQuery>>
34 template <
int,
typename,
typename>
47 using ProtoBlocksQuery = iroha::protocol::BlocksQuery;
52 : query_(o.query_), stateless_validator_(o.stateless_validator_) {}
60 template <
int Fields,
typename Transformation>
61 auto transform(Transformation t)
const {
68 : stateless_validator_(validator) {}
75 SV(
iroha::test::kTestsValidatorsConfig)) {}
78 return transform<CreatedTime>([&](
auto &qry) {
79 auto *meta = qry.mutable_meta();
80 meta->set_created_time(created_time);
86 return transform<CreatorAccountId>([&](
auto &qry) {
87 auto *meta = qry.mutable_meta();
88 meta->set_creator_account_id(creator_account_id);
93 return transform<QueryCounter>([&](
auto &qry) {
94 auto *meta = qry.mutable_meta();
95 meta->set_query_counter(query_counter);
100 static_assert(S == (1 << TOTAL) - 1,
"Required fields are not set");
101 auto result =
BlocksQuery(iroha::protocol::BlocksQuery(query_));
102 if (
auto error = stateless_validator_.validate(result)) {
103 throw std::invalid_argument(error->toString());
105 return BT(std::move(result));
108 static const int total = RequiredFields::TOTAL;
111 ProtoBlocksQuery query_;
112 SV stateless_validator_;
117 #endif // IROHA_PROTO_BLOCKS_QUERY_BUILDER_TEMPLATE_HPP BlocksQueryValidator< FieldValidator > DefaultUnsignedBlocksQueryValidator
Definition: default_validator.hpp:71
Definition: blocks_query_template.hpp:32
TemplateBlocksQueryBuilder()
Definition: blocks_query_template.hpp:73
auto createdTime(interface::types::TimestampType created_time) const
Definition: blocks_query_template.hpp:77
auto creatorAccountId(const interface::types::AccountIdType &creator_account_id) const
Definition: blocks_query_template.hpp:84
Definition: block_query.hpp:15
auto queryCounter(interface::types::CounterType query_counter) const
Definition: blocks_query_template.hpp:92
std::string AccountIdType
Type of account id.
Definition: types.hpp:38
uint64_t CounterType
Type of counter.
Definition: types.hpp:69
Definition: command_executor.hpp:12
Definition: proto_blocks_query.hpp:16
uint64_t TimestampType
Type of timestamp.
Definition: types.hpp:67
auto build() const
Definition: blocks_query_template.hpp:99