#include <logical_node_info.h>
LogicalNodeInfo represents the position of a peer within the p2p network. Each peer has a unique position (level:number) in the range of 0..(m^level)-1
◆ LogicalNodeInfo() [1/3]
minhton::LogicalNodeInfo::LogicalNodeInfo |
( |
uint16_t |
fanout | ) |
|
|
explicit |
0:0 is always a valid position, therefore we can use setFanout to check if the fanout is valid
Creates a LogicalNodeInfo object without a given position. It's optional to give a fanout. As default the k_FANOUT_DEFAULT value gets set. Level and Number are being set as 0. This object is set as not initialized. There is no possibility of initializing it. This constructor is there to represent a non-existing peer.
Typical usage:
Definition logical_node_info.h:23
- Parameters
-
fanout | maximum number of children a node can have |
- Returns
- nothing on success, otherwise throws std::invalid_argument in case of an invalid fanout
◆ LogicalNodeInfo() [2/3]
minhton::LogicalNodeInfo::LogicalNodeInfo |
( |
uint32_t |
p_level, |
|
|
uint32_t |
p_number |
|
) |
| |
Creates a LogicalNodeInfo object with a given position but without a fanout. Directly after the fanout is known, setFanout has to be called to set the fanout. Otherwise the fanout stays set as 0 and an invalid position might not get recognized.
Typical usage:
- Parameters
-
level | level in the tree, root has level 0 |
number | number in the tree, the leftmost node on the level has number 0 |
- Returns
- nothing
The fanout isn't valid, therefore setPosition will always throw an exception. When setFanout is executed afterwards (which must happen), the position will get verified this way. Therefore we can set the position directly without setPosition
◆ LogicalNodeInfo() [3/3]
minhton::LogicalNodeInfo::LogicalNodeInfo |
( |
uint32_t |
p_level, |
|
|
uint32_t |
p_number, |
|
|
uint16_t |
p_fanout |
|
) |
| |
Creates a LogicalNodeInfo object with a given position and fanout. It gets set as initialized. It gets verified if the position with the given fanout is valid.
Typical usage:
- Parameters
-
level | level in the tree, root has level 0 |
number | number in the tree, the leftmost node on the level has number 0 |
fanout | maximum number of children a node can have |
- Returns
- nothing on success, otherwise throws std::invalid_argument in case of an invalid level:number or fanout
The validity of the fanout will get checked in setPosition. There is no need to call setFanout.
◆ getFanout()
uint16_t minhton::LogicalNodeInfo::getFanout |
( |
| ) |
const |
- Returns
- the fanout of this MINHTON tree
◆ getHorizontalValue()
double minhton::LogicalNodeInfo::getHorizontalValue |
( |
| ) |
const |
- Returns
- the horizontal value defined by the TreeMapper of this peer
◆ getLevel()
uint32_t minhton::LogicalNodeInfo::getLevel |
( |
| ) |
const |
- Returns
- the level of this peer within MINHTON tree
◆ getNumber()
uint32_t minhton::LogicalNodeInfo::getNumber |
( |
| ) |
const |
- Returns
- the number of this peer within MINHTON tree
◆ getRawUuid()
solanet::UUID minhton::LogicalNodeInfo::getRawUuid |
( |
| ) |
const |
- Returns
- the uuid of this peer
◆ getString()
std::string minhton::LogicalNodeInfo::getString |
( |
| ) |
const |
- Returns
- a readable representation of information about this peer
◆ getUuid()
std::string minhton::LogicalNodeInfo::getUuid |
( |
| ) |
const |
- Returns
- the uuid string of this peer
◆ isDeeperThan()
Checks if another peer has a deeper/ higher (>) level. E.g. a peer with level 1 is deeper/higher than a peer (root) on level 0
Typical usage:
bool isDeeperThan(LogicalNodeInfo other) const
Definition logical_node_info.cpp:98
- Parameters
-
other | instance of a peer which is compared to. |
- Returns
- true if same level, otherwise false.
◆ isDeeperThanOrSameLevel()
bool minhton::LogicalNodeInfo::isDeeperThanOrSameLevel |
( |
LogicalNodeInfo |
other | ) |
const |
Checks if another peer has is on the same or on a deeper/ higher (>=) level. E.g. a peer on level 2 is deeper/higher or on the same level than a peer (root) on level 0 The same peer on level 2 is also on the same level as another peer on level 2
Typical usage:
bool isDeeperThanOrSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:108
- Parameters
-
other | instance of a peer which is compared to. |
- Returns
- true if same level, otherwise false.
◆ isInitialized()
bool minhton::LogicalNodeInfo::isInitialized |
( |
| ) |
const |
Returns the current state of the peer if the peer is proper initialized. It depends on the constructor call.
Typical usage:
bool isInitialized() const
Definition logical_node_info.cpp:86
- Returns
- true if the peer has proper level:number:fanout
◆ isPrioNode()
bool minhton::LogicalNodeInfo::isPrioNode |
( |
| ) |
const |
Checks if the current peer with its level:number is part of the prio-node set
Typical usage:
bool isPrioNode() const
Definition logical_node_info.cpp:118
- Returns
- true if peer is a prio-node, otherwise false.
◆ isRoot()
bool minhton::LogicalNodeInfo::isRoot |
( |
| ) |
const |
Checks if the current peer is the root peer, in fact level = 0 and number = 0
Typical usage:
bool isRoot() const
Definition logical_node_info.cpp:78
- Returns
- true if peer root, otherwise false.
◆ isSameLevel()
Checks if another peer has the same level
Typical usage:
bool isSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:88
- Parameters
-
other | instance of a peer which is compared to. |
- Returns
- true if same level, otherwise false.
◆ setFanout()
void minhton::LogicalNodeInfo::setFanout |
( |
uint16_t |
fanout | ) |
|
Sets the fanout of this peer
Typical usage:
void setFanout(uint16_t fanout)
Definition logical_node_info.cpp:65
- Parameters
-
◆ setPosition() [1/2]
Sets the position of peer based on the passed peer. All information get copied, also fanout and initialization status.
Typical usage:
void setPosition(uint32_t level, uint32_t number)
Definition logical_node_info.cpp:32
- Parameters
-
other | peer with the new level, number, fanout and initialized |
- Returns
- nothing on succes, otherwise throws std::invalid_argument in case of an invalid level:number
◆ setPosition() [2/2]
void minhton::LogicalNodeInfo::setPosition |
( |
uint32_t |
level, |
|
|
uint32_t |
number |
|
) |
| |
Sets the position of a peer depending on the previous set fanout
Typical usage:
- Parameters
-
level | for the new level |
number | for the new number |
- Returns
- nothing on success, otherwise throws std::invalid_argument in case of an invalid level:number
The documentation for this class was generated from the following files: