CatapultServer  v0.5.0.1 (Elephant)
NetworkNode.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "Node.h"
23 #include <memory>
24 
25 namespace catapult { namespace ionet {
26 
27 #pragma pack(push, 1)
28 
30  struct NetworkNode {
32  uint32_t Size;
33 
36 
38  uint16_t Port;
39 
42 
45 
48 
50  uint8_t HostSize;
51 
54 
55  // followed by host if HostSize != 0
56  // followed by friendly name if FriendlyNameSize != 0
57 
58  public:
60  static constexpr uint64_t CalculateRealSize(const NetworkNode& node) noexcept {
61  return sizeof(NetworkNode) + node.HostSize + node.FriendlyNameSize;
62  }
63  };
64 
65 #pragma pack(pop)
66 
68  std::unique_ptr<NetworkNode> PackNode(const Node& node);
69 
71  Node UnpackNode(const NetworkNode& networkNode);
72 }}
catapult::ionet::NodeEndpoint
A node's publicly accessible endpoint.
Definition: Node.h:35
catapult::ionet::NetworkNode::Port
uint16_t Port
Port.
Definition: NetworkNode.h:38
catapult::ionet::NetworkNode
Information about a catapult node that is propagated through the network.
Definition: NetworkNode.h:30
MemoryUtils.h
catapult::ionet::UnpackNode
Node UnpackNode(const NetworkNode &networkNode)
Unpacks a network node (networkNode) into a node model.
Definition: NetworkNode.cpp:59
catapult::ionet::Node::identityKey
const Key & identityKey() const
Gets the unique identifier (a public key).
Definition: Node.cpp:60
catapult::ionet::NetworkNode::CalculateRealSize
static constexpr uint64_t CalculateRealSize(const NetworkNode &node) noexcept
Calculates the real size of node.
Definition: NetworkNode.h:60
catapult::ionet::NetworkNode::FriendlyNameSize
uint8_t FriendlyNameSize
Size of the friendly name in bytes.
Definition: NetworkNode.h:53
catapult::ionet::NetworkNode::NetworkIdentifier
model::NetworkIdentifier NetworkIdentifier
Network identifier.
Definition: NetworkNode.h:41
catapult::utils::BaseValue< uint32_t, NodeVersion_tag >
catapult::ionet::NetworkNode::HostSize
uint8_t HostSize
Size of the host in bytes.
Definition: NetworkNode.h:50
catapult::ionet::NetworkNode::Roles
NodeRoles Roles
Role(s).
Definition: NetworkNode.h:47
catapult::ionet::NodeRoles
NodeRoles
A node's role.
Definition: NodeRoles.h:28
catapult::ionet::NetworkNode::Version
NodeVersion Version
Version.
Definition: NetworkNode.h:44
Node.h
NetworkNode.h
catapult::model::NetworkIdentifier
NetworkIdentifier
Possible network identifiers.
Definition: NetworkInfo.h:45
catapult::ionet::NodeMetadata
Additional node information.
Definition: Node.h:44
catapult::ionet::Node::endpoint
const NodeEndpoint & endpoint() const
Gets the endpoint.
Definition: Node.cpp:64
catapult::ionet::Node::metadata
const NodeMetadata & metadata() const
Gets tne metadata.
Definition: Node.cpp:68
catapult::ionet::NetworkNode::Size
uint32_t Size
Size of the node.
Definition: NetworkNode.h:32
Node
ionet::Node Node
Definition: PacketWriters.cpp:45
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::ionet::PackNode
std::unique_ptr< NetworkNode > PackNode(const Node &node)
Packs a node model into a network node.
Definition: NetworkNode.cpp:32
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::ionet::Node
A node in the catapult network.
Definition: Node.h:82
catapult::ionet::NetworkNode::IdentityKey
Key IdentityKey
Unique node identifier (public key).
Definition: NetworkNode.h:35