hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
peer.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SHARED_MODEL_PROTO_PEER_HPP
7 #define IROHA_SHARED_MODEL_PROTO_PEER_HPP
8 
11 #include "cryptography/hash.hpp"
14 #include "primitive.pb.h"
15 
16 namespace shared_model {
17  namespace proto {
18  class Peer final
19  : public CopyableProto<interface::Peer, iroha::protocol::Peer, Peer> {
20  public:
21  template <typename PeerType>
22  explicit Peer(PeerType &&peer)
23  : CopyableProto(std::forward<PeerType>(peer)) {}
24 
25  Peer(const Peer &o) : Peer(o.proto_) {}
26 
27  Peer(Peer &&o) noexcept : Peer(std::move(o.proto_)) {}
28 
29  const interface::types::AddressType &address() const override {
30  return proto_->address();
31  }
32 
33  const interface::types::PubkeyType &pubkey() const override {
34  return public_key_;
35  }
36 
37  private:
38  const interface::types::PubkeyType public_key_{
39  crypto::Hash::fromHexString(proto_->peer_key())};
40  };
41  } // namespace proto
42 } // namespace shared_model
43 #endif // IROHA_SHARED_MODEL_PROTO_PEER_HPP
detail::ReferenceHolder< iroha::protocol::Peer > proto_
Definition: trivial_proto.hpp:65
Peer(Peer &&o) noexcept
Definition: peer.hpp:27
std::string AddressType
Type of peer address.
Definition: types.hpp:41
Definition: peer.hpp:48
const interface::types::PubkeyType & pubkey() const override
Definition: peer.hpp:33
Definition: peer.hpp:18
const interface::types::AddressType & address() const override
Definition: peer.hpp:29
Definition: public_key.hpp:16
Peer(const Peer &o)
Definition: peer.hpp:25
Peer(PeerType &&peer)
Definition: peer.hpp:22
Definition: command_executor.hpp:12
Definition: trivial_proto.hpp:45
static Hash fromHexString(const std::string &hex)
Definition: hash.cpp:20