Module RelayModel.RelayId
Expand source code
class RelayLayerId:
"""
Holds the information identifying a relay layer.
Attributes:
ip (str): Defines the address on which the relay layer should be reachable.
port (int): Defines the port on which the relay layer should be reachable.
node_id (int): Defines the id of a node if it is needed to form a topology.
"""
def __init__(self, ip: str, port: int):
"""
Creates a RelayLayerId object with a given ip and port.
Args:
ip (str): Defines the address on which the relay layer should be reachable.
port (int): Defines the port on which the relay layer should be reachable.
"""
self.ip = ip
self.port = port
self._id = 0
def _get_id(self):
"""Handles the internal id storing the node id of a node.
"""
return self._id
def _set_id(self, node_id: int):
self._id = node_id
node_id = property(_get_id, _set_id)
def __eq__(self, other):
return self.__class__ == other.__class__ and self.ip == other.ip and self.port == other.port \
and self._id == other._id
def __hash__(self):
rid_string = self.ip + ":" + str(self.port)
return hash(rid_string)
def __str__(self):
return self.ip + ":" + str(self.port) + "_id(" + str(self._id) + ")"
class RelayId:
"""Holds the information identifying a specific relay.
Attributes:
layer_id (RelayLayerId): Holds the reference to a RelayLayerId which defines the RelayLayer holding the Relay defined by this RelayId
relay_id (int): Holds an identifier for the Relay which defines a specific Relay in a RelayLayer
"""
def __init__(self, layer_id: RelayLayerId, relay_id: int):
"""Creates an object for a RelayId with the given RelayLayerId and a given integer defining the internal relay id.
Args:
layer_id (RelayLayerId): Defines the RelayLayerId representing a specific RelayLayer
relay_id (RelayId): Defines the internal Relay ID
"""
self.layer_id = layer_id
self.relay_id = relay_id
def __eq__(self, other):
return self.__class__ == other.__class__ and self.layer_id == other.layer_id and self.relay_id == other.relay_id
def __hash__(self):
relay_id_string = str(self.layer_id) + ":" + str(self.relay_id)
return hash(relay_id_string)
def __str__(self):
return str(self.layer_id) + ":" + str(self.relay_id)
Classes
class RelayId (layer_id: RelayLayerId, relay_id: int)-
Holds the information identifying a specific relay.
Attributes
- layer_id (RelayLayerId): Holds the reference to a RelayLayerId which defines the RelayLayer holding the Relay defined by this RelayId
relay_id:int- Holds an identifier for the Relay which defines a specific Relay in a RelayLayer
Creates an object for a RelayId with the given RelayLayerId and a given integer defining the internal relay id.
Args
layer_id:RelayLayerId- Defines the RelayLayerId representing a specific RelayLayer
relay_id:RelayId- Defines the internal Relay ID
Expand source code
class RelayId: """Holds the information identifying a specific relay. Attributes: layer_id (RelayLayerId): Holds the reference to a RelayLayerId which defines the RelayLayer holding the Relay defined by this RelayId relay_id (int): Holds an identifier for the Relay which defines a specific Relay in a RelayLayer """ def __init__(self, layer_id: RelayLayerId, relay_id: int): """Creates an object for a RelayId with the given RelayLayerId and a given integer defining the internal relay id. Args: layer_id (RelayLayerId): Defines the RelayLayerId representing a specific RelayLayer relay_id (RelayId): Defines the internal Relay ID """ self.layer_id = layer_id self.relay_id = relay_id def __eq__(self, other): return self.__class__ == other.__class__ and self.layer_id == other.layer_id and self.relay_id == other.relay_id def __hash__(self): relay_id_string = str(self.layer_id) + ":" + str(self.relay_id) return hash(relay_id_string) def __str__(self): return str(self.layer_id) + ":" + str(self.relay_id) class RelayLayerId (ip: str, port: int)-
Holds the information identifying a relay layer.
Attributes
ip:str- Defines the address on which the relay layer should be reachable.
port:int- Defines the port on which the relay layer should be reachable.
node_id:int- Defines the id of a node if it is needed to form a topology.
Creates a RelayLayerId object with a given ip and port.
Args
ip:str- Defines the address on which the relay layer should be reachable.
port:int- Defines the port on which the relay layer should be reachable.
Expand source code
class RelayLayerId: """ Holds the information identifying a relay layer. Attributes: ip (str): Defines the address on which the relay layer should be reachable. port (int): Defines the port on which the relay layer should be reachable. node_id (int): Defines the id of a node if it is needed to form a topology. """ def __init__(self, ip: str, port: int): """ Creates a RelayLayerId object with a given ip and port. Args: ip (str): Defines the address on which the relay layer should be reachable. port (int): Defines the port on which the relay layer should be reachable. """ self.ip = ip self.port = port self._id = 0 def _get_id(self): """Handles the internal id storing the node id of a node. """ return self._id def _set_id(self, node_id: int): self._id = node_id node_id = property(_get_id, _set_id) def __eq__(self, other): return self.__class__ == other.__class__ and self.ip == other.ip and self.port == other.port \ and self._id == other._id def __hash__(self): rid_string = self.ip + ":" + str(self.port) return hash(rid_string) def __str__(self): return self.ip + ":" + str(self.port) + "_id(" + str(self._id) + ")"Instance variables
var node_id-
Handles the internal id storing the node id of a node.
Expand source code
def _get_id(self): """Handles the internal id storing the node id of a node. """ return self._id