LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/common_objects - signature.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 5 5 100.0 %
Date: 2018-12-05 17:11:35 Functions: 19 19 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_PROTO_SIGNATURE_HPP
       7             : #define IROHA_PROTO_SIGNATURE_HPP
       8             : 
       9             : #include "interfaces/common_objects/signature.hpp"
      10             : 
      11             : #include "backend/protobuf/common_objects/trivial_proto.hpp"
      12             : #include "cryptography/public_key.hpp"
      13             : #include "cryptography/signed.hpp"
      14             : #include "primitive.pb.h"
      15             : 
      16             : namespace shared_model {
      17             :   namespace proto {
      18             :     class Signature final : public CopyableProto<interface::Signature,
      19             :                                                  iroha::protocol::Signature,
      20             :                                                  Signature> {
      21             :      public:
      22             :       template <typename SignatureType>
      23             :       explicit Signature(SignatureType &&signature)
      24       22577 :           : CopyableProto(std::forward<SignatureType>(signature)) {}
      25             : 
      26             :       Signature(const Signature &o) : Signature(o.proto_) {}
      27             : 
      28             :       Signature(Signature &&o) noexcept : Signature(std::move(o.proto_)) {}
      29             : 
      30             :       const PublicKeyType &publicKey() const override {
      31       42750 :         return *public_key_;
      32             :       }
      33             : 
      34             :       const SignedType &signedData() const override {
      35       12813 :         return *signed_;
      36             :       }
      37             : 
      38             :      private:
      39             :       // lazy
      40             :       template <typename T>
      41             :       using Lazy = detail::LazyInitializer<T>;
      42             : 
      43       22554 :       const Lazy<PublicKeyType> public_key_{
      44             :           [this] { return PublicKeyType(proto_->public_key()); }};
      45             : 
      46       22575 :       const Lazy<SignedType> signed_{
      47             :           [this] { return SignedType(proto_->signature()); }};
      48             :     };
      49             :   }  // namespace proto
      50             : }  // namespace shared_model
      51             : 
      52             : #endif  // IROHA_PROTO_SIGNATURE_HPP

Generated by: LCOV version 1.13