3.0.ipv8.peerdiscovery.discovery ================================ .. py:module:: 3.0.ipv8.peerdiscovery.discovery Attributes ---------- .. autoapisummary:: 3.0.ipv8.peerdiscovery.discovery._OT Classes ------- .. autoapisummary:: 3.0.ipv8.peerdiscovery.discovery.DiscoveryStrategy 3.0.ipv8.peerdiscovery.discovery.RandomWalk 3.0.ipv8.peerdiscovery.discovery.EdgeWalk Module Contents --------------- .. py:data:: _OT .. py:class:: DiscoveryStrategy(overlay: _OT) Bases: :py:obj:`Generic`\ [\ :py:obj:`_OT`\ ] Strategy for discovering peers in a network. .. py:attribute:: overlay :type: _OT .. py:attribute:: walk_lock .. py:method:: take_step() -> None :abstractmethod: Callback for when an IPv8 tick occurs (defaults to roughly every 0.5 seconds). .. py:method:: get_peer_count() -> int Determine the current number of peers. This is used by IPv8 to determine whether to call this strategy. If ``self.overlay`` is not ``None``, we expect it to have a ``get_peers() -> list[Peer]`` method. .. py:class:: RandomWalk(overlay: 3.0.ipv8.types.Overlay, timeout: float = 3.0, window_size: int = 5, reset_chance: int = 50, target_interval: int = 0) Bases: :py:obj:`DiscoveryStrategy`\ [\ :py:obj:`3.0.ipv8.types.Overlay`\ ] Walk randomly through the network. .. py:attribute:: intro_timeouts :type: dict[3.0.ipv8.types.Address, float] .. py:attribute:: node_timeout .. py:attribute:: window_size .. py:attribute:: reset_chance .. py:attribute:: target_interval .. py:attribute:: last_step :type: float :value: 0 .. py:method:: take_step() -> None Walk to random walkable peer. .. py:class:: EdgeWalk(overlay: 3.0.ipv8.types.Overlay, edge_length: int = 4, neighborhood_size: int = 6, edge_timeout: float = 3.0) Bases: :py:obj:`DiscoveryStrategy`\ [\ :py:obj:`3.0.ipv8.types.Overlay`\ ] Walk through the network by using edges. This will perform a depth-first search in the network starting from your direct neighborhood. When a certain depth is reached, we teleport home and start again from our neighborhood. .. py:attribute:: _neighborhood :type: list[3.0.ipv8.types.Peer] :value: [] .. py:attribute:: complete_edges :type: list[list[3.0.ipv8.types.Peer]] :value: [] .. py:attribute:: under_construction :type: dict[3.0.ipv8.types.Peer, list[3.0.ipv8.types.Peer]] .. py:attribute:: last_edge_responses :type: dict[3.0.ipv8.types.Peer, float] .. py:attribute:: edge_length .. py:attribute:: neighborhood_size .. py:attribute:: edge_timeout .. py:method:: get_available_root() -> 3.0.ipv8.types.Peer | None Get a root, if it exists, which is not busy constructing an edge for us. .. py:method:: take_step() -> None Attempt to grow an edge.