latest.ipv8.peer
Module Contents
Classes
Dictionary that becomes dirty when elements are changed. |
|
A public key that has additional information attached to it (like an IP address, measured RTT, etc.). |
- class latest.ipv8.peer.DirtyDict(**kwargs)
Bases:
dict
Dictionary that becomes dirty when elements are changed.
- __setitem__(key: Any, value: Any) None
Callback for when an item is set to a value. This dirties the dict.
- update(mapping: collections.abc.Mapping, **kwargs) None
Callback for when another mapping is merged into this dict. This dirties the dict.
- pop(key: Any) Any
Callback for when a particular item is popped. This dirties the dict.
- popitem() Any
Callback for when an item is popped. This dirties the dict.
- class latest.ipv8.peer.Peer(key: latest.ipv8.keyvault.keys.Key | bytes, address: latest.ipv8.types.Address | None = None, intro: bool = True)
A public key that has additional information attached to it (like an IP address, measured RTT, etc.).
- property addresses: dict[type[latest.ipv8.types.Address], latest.ipv8.types.Address]
Retrieve the addresses belonging to this Peer.
You are not allowed to set this addresses dict for a Peer manually. You can change the dictionary itself by setting its items or calling its functions, for example
update()
.
- property address: latest.ipv8.types.Address
Retrieve the preferred address for this Peer.
If you want to manually select the interface, use the
.addresses
dictionary instead.
- INTERFACE_ORDER
- add_address(value: Any) None
Add a known address for this Peer.
Any object can form an address, but only one type of address can be used per object type. For example (normally A, B and C are
namedtuple
types):Adding instances A(1), B(2) leads to addresses {A: A(1), B: B(2)}
Adding instances A(1), B(2), A(3) leads to addresses {A: A(3), B: B(2)}
- get_median_ping() float | None
Get the median ping time of this peer.
- Returns:
the median ping or None if no measurements were performed yet
- Return type:
float or None
- get_average_ping() float | None
Get the average ping time of this peer.
- Returns:
the average ping or None if no measurements were performed yet
- Return type:
float or None
- update_clock(timestamp: int) None
Update the Lamport timestamp for this peer. The Lamport clock dictates that the current timestamp is the maximum of the last known and the most recently delivered timestamp. This is useful when messages are delivered asynchronously.
We also keep a real time timestamp of the last received message for timeout purposes.
- Parameters:
timestamp – a received timestamp