LCOV - code coverage report
Current view: top level - shared_model/builders/protobuf - transaction_sequence_builder.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 10 10 100.0 %
Date: 2018-12-05 17:11:35 Functions: 6 6 100.0 %

          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_TRANSACTION_SEQUENCE_BUILDER_HPP
       7             : #define IROHA_TRANSACTION_SEQUENCE_BUILDER_HPP
       8             : 
       9             : #include "builders/protobuf/transport_builder.hpp"
      10             : #include "interfaces/common_objects/types.hpp"
      11             : #include "interfaces/iroha_internal/transaction_sequence_factory.hpp"
      12             : 
      13             : namespace shared_model {
      14             :   namespace proto {
      15             : 
      16             :     /**
      17             :      * Class for building Transaction Sequence
      18             :      * @tparam SV Stateless validator type
      19             :      */
      20             :     template <typename SV>
      21             :     class DEPRECATED TransportBuilder<interface::TransactionSequence, SV> {
      22             :      public:
      23             :       TransportBuilder<interface::TransactionSequence, SV>(
      24             :           SV stateless_validator = SV())
      25           3 :           : stateless_validator_(stateless_validator) {}
      26             : 
      27             :       /**
      28             :        * Builds TransactionSequence from transport object
      29             :        * @param transport protobuf object from which TransactionSequence is
      30             :        * built
      31             :        * @return Result containing either TransactionSequence or message string
      32             :        */
      33             :       template <class T>
      34             :       iroha::expected::Result<interface::TransactionSequence, std::string>
      35             :       build(const T &transport) {
      36           3 :         const auto &txs = transport.transactions();
      37           3 :         std::vector<std::shared_ptr<interface::Transaction>> shm_txs;
      38           3 :         std::transform(txs.begin(),
      39           3 :                        txs.end(),
      40           3 :                        std::back_inserter(shm_txs),
      41             :                        [](const iroha::protocol::Transaction &tx) {
      42          34 :                          return std::make_shared<Transaction>(tx);
      43             :                        });
      44           3 :         return interface::TransactionSequenceFactory::createTransactionSequence(
      45           3 :             shm_txs, stateless_validator_);
      46           3 :       }
      47             : 
      48             :      private:
      49             :       SV stateless_validator_;
      50             :     };
      51             :   }  // namespace proto
      52             : }  // namespace shared_model
      53             : #endif  // IROHA_TRANSACTION_SEQUENCE_BUILDER_HPP

Generated by: LCOV version 1.13