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 
10 #include "cryptography/hash.hpp"
13 #include "primitive.pb.h"
15 
16 namespace shared_model {
17  namespace proto {
18  class Peer final : public interface::Peer {
19  public:
20  template <typename PeerType>
21  explicit Peer(PeerType &&peer) : proto_(std::forward<PeerType>(peer)) {}
22 
23  Peer(const Peer &o) : Peer(o.proto_) {}
24 
25  Peer(Peer &&o) noexcept : Peer(std::move(o.proto_)) {}
26 
27  const interface::types::AddressType &address() const override {
28  return proto_->address();
29  }
30 
31  const interface::types::PubkeyType &pubkey() const override {
32  return public_key_;
33  }
34 
35  private:
37  const interface::types::PubkeyType public_key_{
38  crypto::Hash::fromHexString(proto_->peer_key())};
39  };
40  } // namespace proto
41 } // namespace shared_model
42 #endif // IROHA_SHARED_MODEL_PROTO_PEER_HPP
std::string AddressType
Type of peer address.
Definition: types.hpp:45
Peer(Peer &&o) noexcept
Definition: peer.hpp:25
Definition: peer.hpp:18
Definition: reference_holder.hpp:18
Definition: peer.hpp:48
const interface::types::PubkeyType & pubkey() const override
Definition: peer.hpp:31
Definition: peer.hpp:18
const interface::types::AddressType & address() const override
Definition: peer.hpp:27
Definition: public_key.hpp:16
Peer(const Peer &o)
Definition: peer.hpp:23
Peer(PeerType &&peer)
Definition: peer.hpp:21
Definition: command_executor.hpp:12
static Hash fromHexString(const std::string &hex)
Definition: hash.cpp:20