LCOV - code coverage report
Current view: top level - irohad/model - peer.hpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 7 7 100.0 %
Date: 2019-03-07 14:46:43 Functions: 13 13 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_PEER_HPP
       7             : #define IROHA_PEER_HPP
       8             : 
       9             : #include "crypto/keypair.hpp"
      10             : 
      11             : namespace iroha {
      12             :   namespace model {
      13             : 
      14             :     /**
      15             :      * Peer is Model, which contains information about network participants
      16             :      */
      17             :     struct Peer {
      18             :       /**
      19             :        * IP address of peer for connection
      20             :        */
      21          16 :       std::string address{};
      22             : 
      23             :       using AddressType = decltype(address);
      24             : 
      25             :       /**
      26             :        * Public key of peer
      27             :        */
      28          16 :       pubkey_t pubkey{};
      29             : 
      30             :       using KeyType = decltype(pubkey);
      31             : 
      32             :       bool operator==(const Peer &obj) const {
      33          12 :         if (address == obj.address && pubkey == obj.pubkey) {
      34           9 :           return true;
      35             :         } else {
      36           3 :           return false;
      37             :         }
      38          12 :       }
      39             : 
      40             :       Peer() = default;
      41             : 
      42             :       Peer(const AddressType &address, const KeyType &pubkey)
      43           3 :           : address(address), pubkey(pubkey) {}
      44             :     };
      45             :   }  // namespace model
      46             : }  // namespace iroha
      47             : 
      48             : namespace std {
      49             :   template <>
      50             :   struct hash<iroha::model::Peer> {
      51             :     std::size_t operator()(const iroha::model::Peer &obj) const {
      52             :       return std::hash<std::string>()(obj.address + obj.pubkey.to_string());
      53             :     }
      54             :   };
      55             : }  // namespace std
      56             : #endif  // IROHA_PEER_H

Generated by: LCOV version 1.13