Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #include "interfaces/iroha_internal/transaction_batch_factory_impl.hpp"
7 :
8 : #include "interfaces/iroha_internal/transaction_batch_impl.hpp"
9 : #include "interfaces/transaction.hpp"
10 : #include "validators/answer.hpp"
11 :
12 : namespace shared_model {
13 : namespace interface {
14 : TransactionBatchFactoryImpl::FactoryImplResult
15 : TransactionBatchFactoryImpl::createTransactionBatch(
16 : const types::SharedTxsCollectionType &transactions) const {
17 3949 : std::unique_ptr<TransactionBatch> batch_ptr =
18 3949 : std::make_unique<TransactionBatchImpl>(transactions);
19 4076 : if (auto answer = batch_validator_.validate(*batch_ptr)) {
20 9 : return iroha::expected::makeError(answer.reason());
21 : }
22 4024 : return iroha::expected::makeValue(std::move(batch_ptr));
23 4033 : }
24 :
25 : TransactionBatchFactoryImpl::FactoryImplResult
26 : TransactionBatchFactoryImpl::createTransactionBatch(
27 : std::shared_ptr<Transaction> transaction) const {
28 26 : return createTransactionBatch(
29 26 : types::SharedTxsCollectionType{std::move(transaction)});
30 0 : }
31 : } // namespace interface
32 : } // namespace shared_model
|