CatapultServer  v0.5.0.1 (Elephant)
PackedNodeInfo.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NodeInfo.h"
24 
25 namespace catapult { namespace ionet {
26 
27 #pragma pack(push, 1)
28 
31  public:
34 
37  uint32_t Age;
38 
41 
44  uint32_t BanAge;
45 
46  public:
48  void Update(const ConnectionState& connectionState) {
49  Age = connectionState.Age;
51  BanAge = connectionState.BanAge;
52  }
53  };
54 
57  public:
59  uint32_t NumSuccesses;
60 
62  uint32_t NumFailures;
63 
64  public:
66  void Update(const NodeInteractions& interactions) {
67  NumSuccesses = interactions.NumSuccesses;
68  NumFailures = interactions.NumFailures;
69  }
70  };
71 
73  struct PackedNodeInfo : public model::TrailingVariableDataLayout<PackedNodeInfo, PackedConnectionState> {
74  public:
77 
80 
83 
86 
87  // followed by connection states if ConnectionStatesCount != 0
88 
89  public:
92  return ConnectionStatesCount ? ToTypedPointer(PayloadStart(*this)) : nullptr;
93  }
94 
97  return ConnectionStatesCount ? ToTypedPointer(PayloadStart(*this)) : nullptr;
98  }
99 
100  public:
102  static constexpr uint64_t CalculateRealSize(const PackedNodeInfo& nodeInfo) noexcept {
103  return sizeof(PackedNodeInfo) + nodeInfo.ConnectionStatesCount * sizeof(PackedConnectionState);
104  }
105  };
106 
107 #pragma pack(pop)
108 }}
catapult::ionet::ConnectionState
Connection state unique to a node and connection identifier.
Definition: NodeInfo.h:59
catapult::model::TrailingVariableDataLayout< PackedNodeInfo, PackedConnectionState >::PayloadStart
static auto PayloadStart(T &derived)
Gets the start of the variable data part of derived.
Definition: TrailingVariableDataLayout.h:39
catapult::ionet::PackedNodeInfo::IdentityKey
Key IdentityKey
Node unique identifier.
Definition: PackedNodeInfo.h:76
catapult::ionet::PackedNodeInteractions
Node interactions.
Definition: PackedNodeInfo.h:56
catapult::ionet::ConnectionState::NumConsecutiveFailures
uint32_t NumConsecutiveFailures
Number of consecutive failed connections.
Definition: NodeInfo.h:74
NodeInfo.h
catapult::ionet::PackedConnectionState::Update
void Update(const ConnectionState &connectionState)
Updates values with corresponding values from connectionState.
Definition: PackedNodeInfo.h:48
catapult::ionet::ConnectionState::BanAge
uint32_t BanAge
Definition: NodeInfo.h:78
catapult::ionet::PackedConnectionState::NumConsecutiveFailures
uint32_t NumConsecutiveFailures
Number of consecutive failed connections.
Definition: PackedNodeInfo.h:40
catapult::ionet::PackedNodeInteractions::NumSuccesses
uint32_t NumSuccesses
Number of successful interactions.
Definition: PackedNodeInfo.h:59
catapult::utils::BaseValue< uint32_t, ServiceIdentifier_tag >
catapult::ionet::PackedNodeInfo::Source
NodeSource Source
Node source.
Definition: PackedNodeInfo.h:79
catapult::ionet::PackedNodeInfo::ConnectionStatesPtr
PackedConnectionState * ConnectionStatesPtr()
Returns a pointer to the first connection state contained in this node info.
Definition: PackedNodeInfo.h:96
TrailingVariableDataLayout.h
catapult::ionet::PackedNodeInfo
Information about a node and its interactions.
Definition: PackedNodeInfo.h:73
catapult::ionet::PackedConnectionState::BanAge
uint32_t BanAge
Definition: PackedNodeInfo.h:44
catapult::ionet::PackedNodeInteractions::Update
void Update(const NodeInteractions &interactions)
Updates values with corresponding values from interactions.
Definition: PackedNodeInfo.h:66
catapult::ionet::NodeInteractions::NumSuccesses
uint32_t NumSuccesses
Number of successful interactions.
Definition: NodeInteractionsContainer.h:43
catapult::ionet::NodeSource
NodeSource
Definition: NodeInfo.h:47
catapult::ionet::NodeInteractions
Node interactions.
Definition: NodeInteractionsContainer.h:29
catapult::ionet::PackedNodeInfo::CalculateRealSize
static constexpr uint64_t CalculateRealSize(const PackedNodeInfo &nodeInfo) noexcept
Calculates the real size of nodeInfo.
Definition: PackedNodeInfo.h:102
catapult::ionet::NodeInteractions::NumFailures
uint32_t NumFailures
Number of failed interactions.
Definition: NodeInteractionsContainer.h:46
catapult::ionet::PackedNodeInfo::ConnectionStatesCount
uint8_t ConnectionStatesCount
Number of connection states.
Definition: PackedNodeInfo.h:85
catapult::ionet::PackedNodeInfo::ConnectionStatesPtr
const PackedConnectionState * ConnectionStatesPtr() const
Returns a const pointer to the first connection state contained in this node info.
Definition: PackedNodeInfo.h:91
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::ionet::PackedConnectionState
Connection state unique to a node and connection identifier.
Definition: PackedNodeInfo.h:30
catapult::ionet::PackedConnectionState::ServiceId
ServiceIdentifier ServiceId
Connection identifier.
Definition: PackedNodeInfo.h:33
catapult::model::TrailingVariableDataLayout< PackedNodeInfo, PackedConnectionState >::ToTypedPointer
static const PackedConnectionState * ToTypedPointer(const uint8_t *pData)
Gets a typed pointer to the variable data pData.
Definition: TrailingVariableDataLayout.h:44
catapult::ionet::PackedNodeInteractions::NumFailures
uint32_t NumFailures
Number of failed interactions.
Definition: PackedNodeInfo.h:62
catapult::utils::ByteArray< Key_Size, Key_tag >
catapult::ionet::PackedNodeInfo::Interactions
PackedNodeInteractions Interactions
Node interactions.
Definition: PackedNodeInfo.h:82
catapult::ionet::PackedConnectionState::Age
uint32_t Age
Definition: PackedNodeInfo.h:37
catapult::ionet::ConnectionState::Age
uint32_t Age
Definition: NodeInfo.h:71
catapult::model::TrailingVariableDataLayout
Definition: TrailingVariableDataLayout.h:31