LCOV - code coverage report
Current view: top level - irohad/torii/impl - command_client.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 22 22 100.0 %
Date: 2019-03-07 14:46:43 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             : #include <thread>
       7             : 
       8             : #include <grpc++/grpc++.h>
       9             : 
      10             : #include "common/byteutils.hpp"
      11             : #include "logger/logger.hpp"
      12             : #include "torii/command_client.hpp"
      13             : #include "transaction.pb.h"
      14             : 
      15             : namespace torii {
      16             : 
      17             :   using iroha::protocol::ToriiResponse;
      18             :   using iroha::protocol::Transaction;
      19             : 
      20             :   CommandSyncClient::CommandSyncClient(
      21             :       std::unique_ptr<iroha::protocol::CommandService_v1::StubInterface> stub,
      22             :       logger::LoggerPtr log)
      23         257 :       : stub_(std::move(stub)), log_(std::move(log)) {}
      24             : 
      25             :   grpc::Status CommandSyncClient::Torii(const Transaction &tx) const {
      26         789 :     google::protobuf::Empty a;
      27         789 :     grpc::ClientContext context;
      28         789 :     return stub_->Torii(&context, tx, &a);
      29         789 :   }
      30             : 
      31             :   grpc::Status CommandSyncClient::ListTorii(
      32             :       const iroha::protocol::TxList &tx_list) const {
      33           5 :     google::protobuf::Empty a;
      34           5 :     grpc::ClientContext context;
      35           5 :     return stub_->ListTorii(&context, tx_list, &a);
      36           5 :   }
      37             : 
      38             :   grpc::Status CommandSyncClient::Status(
      39             :       const iroha::protocol::TxStatusRequest &request,
      40             :       iroha::protocol::ToriiResponse &response) const {
      41         788 :     grpc::ClientContext context;
      42         788 :     return stub_->Status(&context, request, &response);
      43         788 :   }
      44             : 
      45             :   void CommandSyncClient::StatusStream(
      46             :       const iroha::protocol::TxStatusRequest &tx,
      47             :       std::vector<iroha::protocol::ToriiResponse> &response) const {
      48           1 :     grpc::ClientContext context;
      49           1 :     ToriiResponse resp;
      50           1 :     auto reader = stub_->StatusStream(&context, tx);
      51           2 :     while (reader->Read(&resp)) {
      52           1 :       log_->debug("received new status: {}, hash {}",
      53           1 :                   resp.tx_status(),
      54           1 :                   iroha::bytestringToHexstring(resp.tx_hash()));
      55           1 :       response.push_back(resp);
      56             :     }
      57           1 :     reader->Finish();
      58           1 :   }
      59             : 
      60             : }  // namespace torii

Generated by: LCOV version 1.13