LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/queries/impl - proto_blocks_query.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 22 24 91.7 %
Date: 2019-03-07 14:46:43 Functions: 16 26 61.5 %

          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          16 :           blob_{makeBlob(*proto_)},
      16          16 :           payload_{makeBlob(proto_->meta())},
      17             :           signatures_{[this] {
      18          16 :             SignatureSetType<proto::Signature> set;
      19          16 :             if (proto_->has_signature()) {
      20           9 :               set.emplace(proto_->signature());
      21           9 :             }
      22          16 :             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           8 :       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           9 :       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(signed_blob.hex());
      63           5 :       sig->set_public_key(public_key.hex());
      64             :       // TODO: nickaleks IR-120 12.12.2018 remove set
      65           5 :       signatures_.emplace(proto_->signature());
      66           5 :       return true;
      67           5 :     }
      68             : 
      69             :     interface::types::TimestampType BlocksQuery::createdTime() const {
      70           6 :       return proto_->meta().created_time();
      71             :     }
      72             : 
      73             :   }  // namespace proto
      74             : }  // namespace shared_model

Generated by: LCOV version 1.13