LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/queries/impl - proto_blocks_query.cpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 19 21 90.5 %
Date: 2018-12-05 17:11:35 Functions: 17 36 47.2 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "backend/protobuf/queries/proto_blocks_query.hpp"
       7             : #include "backend/protobuf/util.hpp"
       8             : 
       9             : namespace shared_model {
      10             :   namespace proto {
      11             : 
      12             :     template <typename BlocksQueryType>
      13             :     BlocksQuery::BlocksQuery(BlocksQueryType &&query)
      14          16 :         : CopyableProto(std::forward<BlocksQueryType>(query)),
      15             :           blob_{[this] { return makeBlob(*proto_); }},
      16             :           payload_{[this] { return makeBlob(proto_->meta()); }},
      17             :           signatures_{[this] {
      18           9 :             SignatureSetType<proto::Signature> set;
      19           9 :             if (proto_->has_signature()) {
      20           9 :               set.emplace(proto_->signature());
      21           9 :             }
      22           9 :             return set;
      23          16 :           }} {}
      24             : 
      25             :     template BlocksQuery::BlocksQuery(BlocksQuery::TransportType &);
      26             :     template BlocksQuery::BlocksQuery(const BlocksQuery::TransportType &);
      27             :     template BlocksQuery::BlocksQuery(BlocksQuery::TransportType &&);
      28             : 
      29             :     BlocksQuery::BlocksQuery(const BlocksQuery &o) : BlocksQuery(o.proto_) {}
      30             : 
      31             :     BlocksQuery::BlocksQuery(BlocksQuery &&o) noexcept
      32          16 :         : BlocksQuery(std::move(o.proto_)) {}
      33             : 
      34             :     const interface::types::AccountIdType &BlocksQuery::creatorAccountId()
      35             :         const {
      36          10 :       return proto_->meta().creator_account_id();
      37             :     }
      38             : 
      39             :     interface::types::CounterType BlocksQuery::queryCounter() const {
      40           6 :       return proto_->meta().query_counter();
      41             :     }
      42             : 
      43             :     const interface::types::BlobType &BlocksQuery::blob() const {
      44           0 :       return *blob_;
      45             :     }
      46             : 
      47             :     const interface::types::BlobType &BlocksQuery::payload() const {
      48           7 :       return *payload_;
      49             :     }
      50             : 
      51             :     interface::types::SignatureRangeType BlocksQuery::signatures() const {
      52          11 :       return *signatures_;
      53             :     }
      54             : 
      55             :     bool BlocksQuery::addSignature(const crypto::Signed &signed_blob,
      56             :                                    const crypto::PublicKey &public_key) {
      57           5 :       if (proto_->has_signature()) {
      58           0 :         return false;
      59             :       }
      60             : 
      61           5 :       auto sig = proto_->mutable_signature();
      62           5 :       sig->set_signature(crypto::toBinaryString(signed_blob));
      63           5 :       sig->set_public_key(crypto::toBinaryString(public_key));
      64           5 :       return true;
      65           5 :     }
      66             : 
      67             :     interface::types::TimestampType BlocksQuery::createdTime() const {
      68           6 :       return proto_->meta().created_time();
      69             :     }
      70             : 
      71             :   }  // namespace proto
      72             : }  // namespace shared_model

Generated by: LCOV version 1.13