latest.ipv8.overlay

Module Contents

Classes

Settings

Overlay settings, extensible for Overlay subclasses.

Overlay

Interface for an Internet overlay.

Attributes

SettingsClass

class latest.ipv8.overlay.Settings

Bases: types.SimpleNamespace

Overlay settings, extensible for Overlay subclasses.

community_id: bytes

The byte-string used to identify this overlay.

my_peer: latest.ipv8.types.Peer

The (private key) peer of this peer.

endpoint: latest.ipv8.types.Endpoint

The endpoint to use for messaging.

network: latest.ipv8.peerdiscovery.network.Network

The network graph backend.

latest.ipv8.overlay.SettingsClass
class latest.ipv8.overlay.Overlay(settings: SettingsClass)

Bases: latest.ipv8.messaging.interfaces.endpoint.EndpointListener, latest.ipv8.taskmanager.TaskManager, Generic[SettingsClass]

Interface for an Internet overlay.

property global_time: int

The lamport timestamp of this overlay.

settings_class: type[SettingsClass]
async discover_lan_addresses() None

Called for discovering LAN addresses.

async unload() None

Called when this overlay needs to shut down.

get_serializer() latest.ipv8.messaging.serialization.Serializer

Get a Serializer for this Overlay.

abstract on_packet(packet: tuple[latest.ipv8.types.Address, bytes]) None

Callback for when data is received on this endpoint.

Parameters:

packet – the received packet, in (source, binary string) format.

claim_global_time() int

Increments the current global time by one and returns this value.

update_global_time(global_time: int) None

Increase the local global time if the given GLOBAL_TIME is larger.

get_available_strategies() dict[str, type[latest.ipv8.peerdiscovery.discovery.DiscoveryStrategy]]

Supply custom DiscoveryStrategies for use with this Overlay. This is used by the configuration system to allow for non-globally defined strategies.

Returns:

a dictionary of names and DiscoveryStrategy subclass classes

Return type:

{str: class<DiscoveryStrategy>}

bootstrap() None

Perform introduction logic to get into the network.

abstract walk_to(address: latest.ipv8.types.Address) None

Puncture the NAT of an address.

Parameters:

address – the address to walk to (ip, port)

abstract get_new_introduction(from_peer: latest.ipv8.types.Peer | None = None) None

Get a new IP address to walk to from a random, or selected peer.

Parameters:

from_peer – the peer to ask for an introduction

abstract get_peers() list[latest.ipv8.types.Peer]

Get the peers for this specific overlay.

Returns:

the peers in the Network that use this overlay

abstract get_walkable_addresses() list[latest.ipv8.types.Address]

Get the list of IPv4 addresses we can walk to on this overlay.

Returns:

a list of IPv4 addresses

Return type:

[(str, int)]

get_peer_for_introduction(exclude: latest.ipv8.types.Peer | None = None) latest.ipv8.types.Peer | None

Get a peer for introduction.

Param:

exclude: optionally specify a peer that is not considered eligible for introduction

Returns:

a Peer to send an introduction request to, or None if there are no available