hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
peer.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_PEER_HPP
7 #define IROHA_PEER_HPP
8 
9 #include "crypto/keypair.hpp"
10 
11 namespace iroha {
12  namespace model {
13 
17  struct Peer {
21  std::string address{};
22 
23  using AddressType = decltype(address);
24 
29 
30  using KeyType = decltype(pubkey);
31 
32  bool operator==(const Peer &obj) const {
33  if (address == obj.address && pubkey == obj.pubkey) {
34  return true;
35  } else {
36  return false;
37  }
38  }
39 
40  Peer() = default;
41 
43  : 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
Definition: peer.hpp:48
bool operator==(const Peer &obj) const
Definition: peer.hpp:32
pubkey_t pubkey
Definition: peer.hpp:28
std::string to_string() const noexcept
Definition: blob.hpp:68
Definition: block_query.hpp:16
Definition: peer.hpp:17
std::string address
Definition: peer.hpp:21
hash256_t hash(const T &pb)
Definition: pb_common.hpp:43
std::size_t operator()(const iroha::model::Peer &obj) const
Definition: peer.hpp:51
decltype(pubkey) KeyType
Definition: peer.hpp:30
Peer(const AddressType &address, const KeyType &pubkey)
Definition: peer.hpp:42
decltype(address) AddressType
Definition: peer.hpp:23