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 
11 #include <optional>
12 
14 #include "cryptography/hash.hpp"
15 #include "primitive.pb.h"
17 
18 namespace shared_model {
19  namespace proto {
20  class Peer final : public interface::Peer {
21  public:
22  template <typename PeerType>
23  explicit Peer(PeerType &&peer) : proto_(std::forward<PeerType>(peer)) {
24  if (proto_->certificate_case()) {
25  tls_certificate_ = proto_->tls_certificate();
26  }
27  }
28 
29  Peer(const Peer &o) : Peer(o.proto_) {}
30 
31  Peer(Peer &&o) noexcept : Peer(std::move(o.proto_)) {}
32 
33  const interface::types::AddressType &address() const override {
34  return proto_->address();
35  }
36 
37  const std::optional<interface::types::TLSCertificateType>
38  &tlsCertificate() const override {
39  return tls_certificate_;
40  }
41 
42  const std::string &pubkey() const override {
43  return proto_->peer_key();
44  }
45 
46  private:
48  std::optional<std::string> tls_certificate_;
49  };
50  } // namespace proto
51 } // namespace shared_model
52 #endif // IROHA_SHARED_MODEL_PROTO_PEER_HPP
std::string AddressType
Type of peer address.
Definition: types.hpp:50
Peer(Peer &&o) noexcept
Definition: peer.hpp:31
Definition: peer.hpp:20
Definition: peer.hpp:48
const std::string & pubkey() const override
Definition: peer.hpp:42
Definition: peer.hpp:20
const std::optional< interface::types::TLSCertificateType > & tlsCertificate() const override
Definition: peer.hpp:38
const interface::types::AddressType & address() const override
Definition: peer.hpp:33
Peer(const Peer &o)
Definition: peer.hpp:29
Peer(PeerType &&peer)
Definition: peer.hpp:23
Definition: command_executor.hpp:12