Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #ifndef IROHA_BLOCK_VALIDATOR_HPP
7 : #define IROHA_BLOCK_VALIDATOR_HPP
8 :
9 : #include <boost/format.hpp>
10 : #include "datetime/time.hpp"
11 : #include "interfaces/common_objects/types.hpp"
12 : #include "interfaces/iroha_internal/block.hpp"
13 : #include "validators/abstract_validator.hpp"
14 : #include "validators/answer.hpp"
15 : #include "validators/container_validator.hpp"
16 :
17 : namespace shared_model {
18 : namespace validation {
19 :
20 : /**
21 : * Class that validates block
22 : */
23 : template <typename FieldValidator, typename TransactionsCollectionValidator>
24 : class BlockValidator
25 : : public ContainerValidator<interface::Block,
26 : FieldValidator,
27 : TransactionsCollectionValidator>,
28 : public AbstractValidator<interface::Block> {
29 : public:
30 : using ContainerValidator<
31 : interface::Block,
32 : FieldValidator,
33 : TransactionsCollectionValidator>::ContainerValidator;
34 : /**
35 : * Applies validation on block
36 : * @param block
37 : * @return Answer containing found error if any
38 : */
39 : Answer validate(const interface::Block &block) const override {
40 264 : return ContainerValidator<interface::Block,
41 : FieldValidator,
42 : TransactionsCollectionValidator>::
43 : validate(block, "Block", [this](auto &reason, const auto &cont) {
44 264 : this->field_validator_.validateHash(reason, cont.prevHash());
45 264 : });
46 0 : }
47 : };
48 :
49 : } // namespace validation
50 : } // namespace shared_model
51 :
52 : #endif // IROHA_BLOCK_VALIDATOR_HPP
|