3.0.ipv8.configuration ====================== .. py:module:: 3.0.ipv8.configuration Attributes ---------- .. autoapisummary:: 3.0.ipv8.configuration.DISPERSY_BOOTSTRAPPER 3.0.ipv8.configuration.default_bootstrap_defs Classes ------- .. autoapisummary:: 3.0.ipv8.configuration.Strategy 3.0.ipv8.configuration.WalkerDefinition 3.0.ipv8.configuration.Bootstrapper 3.0.ipv8.configuration.BootstrapperDefinition 3.0.ipv8.configuration.ConfigBuilder Functions --------- .. autoapisummary:: 3.0.ipv8.configuration.get_default_configuration Module Contents --------------- .. py:data:: DISPERSY_BOOTSTRAPPER :type: dict[Any, Any] .. py:function:: get_default_configuration() -> dict[Any, Any] Get a COPY of the default configuration. You should always use this method instead of accesesing the global default directly. .. py:class:: Strategy(*args, **kwds) Bases: :py:obj:`enum.Enum` ConfigBuilder enum to request default DiscoveryStrategies to be instantiated. .. py:attribute:: RandomWalk :value: 'RandomWalk' .. py:attribute:: RandomChurn :value: 'RandomChurn' .. py:attribute:: PeriodicSimilarity :value: 'PeriodicSimilarity' .. py:attribute:: EdgeWalk :value: 'EdgeWalk' .. py:attribute:: PingChurn :value: 'PingChurn' .. py:method:: values() -> list[str] :classmethod: Get the known default DiscoveryStrategy names. .. py:class:: WalkerDefinition Bases: :py:obj:`NamedTuple` ConfigBuilder directive to request a given strategy to run below a given peer count. The strategy instance is created with the keyword arguments given in ``init``. If the ``peers`` are set to ``-1``, the strategy will always be invoked, regardless of the number of peers. .. py:attribute:: strategy :type: Strategy .. py:attribute:: peers :type: int .. py:attribute:: init :type: dict .. py:class:: Bootstrapper(*args, **kwds) Bases: :py:obj:`enum.Enum` ConfigBuilder enum to request a community to use a given bootstrapping method. .. py:attribute:: DispersyBootstrapper :value: 'DispersyBootstrapper' .. py:attribute:: UDPBroadcastBootstrapper :value: 'UDPBroadcastBootstrapper' .. py:method:: values() -> list[str] :classmethod: Get the known default Bootstrapper names. .. py:class:: BootstrapperDefinition Bases: :py:obj:`NamedTuple` ConfigBuilder directive to specify how Bootstrapper instances should be instantiated. The bootstrapper instance is created with the keyword arguments given in ``init``. .. py:attribute:: bootstrapper :type: Bootstrapper .. py:attribute:: init :type: dict .. py:data:: default_bootstrap_defs Shortcut for the most common ConfigBuilder default bootstrapper settings. .. py:class:: ConfigBuilder(clean: bool = False) Factory class to create IPv8 configurations. .. py:attribute:: config .. py:method:: finalize() -> dict Process the builder input and check for errors, this produces a configuration dictionary suitable for IPv8. Essentially this only checks the `config` variable for errors, use that instead if you're confident you never make any errors. .. py:method:: clear_keys() -> ConfigBuilder Remove all keys in the current configuration. .. py:method:: clear_overlays() -> ConfigBuilder Remove all overlays in the current configuration. .. py:method:: set_address(address: str, interface: str = 'UDPIPv4') -> ConfigBuilder Set the address IPv8 is to try and bind to. | For IPv4 localhost only use ``127.0.0.1`` | For IPv4 Internet communication use ``0.0.0.0`` | For IPv6 localhost only use ``::1`` | For IPv6 Internet communication use ``::`` :param address: the address to attempt to bind to. :param interface: the interface to use (currently "UDPIPv4" or "UDPIPv6"). .. py:method:: set_port(port: int, interface: str = 'UDPIPv4') -> ConfigBuilder Set the port that IPv8 should TRY to bind to. If your port is not available, IPv8 will try and find another one. :param port: the port to attempt to bind to. :param interface: the interface to use (currently "UDPIPv4" or "UDPIPv6"). .. py:method:: set_log_level(log_level: str) -> ConfigBuilder Set the log level for all of IPv8's loggers. Choose from 'CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG' or 'NOTSET'. .. py:method:: set_working_directory(folder_path: str) -> ConfigBuilder Set the common working directory for overlays. Individual settings may override this working directory, but it serves as the base working directory. .. py:method:: set_walker_interval(interval: float) -> ConfigBuilder Set the interval, in seconds, at which IPv8 schedules its strategies. An interval of 3.14 would mean that each walker attempts to walk every 3.14 seconds. Setting this interval too low will choke the event thread and decrease the QoS of IPv8 overlays. Setting this interval too high will decrease the QoS of IPv8 overlays due to lack of content. .. py:method:: add_key(alias: str, generation: str, file_path: str) -> ConfigBuilder Add a key by alias and mode of generation, to be stored at a certain file path. If a key already exists at the given file path, that will be loaded instead of generating a new key. .. py:method:: add_key_from_bin(alias: str, key_bin_b64: str, file_path: str | None = None) -> ConfigBuilder Add a key by alias and its raw key material, possibly stored at a certain file path. If a key already exists at the given file path, that will be loaded instead of the given key material. :param alias: the alias used to reference this key :param key_bin_b64: the base64 encoded private key material :param file_path: the optional file path to save the key to .. py:method:: add_ephemeral_key(alias: str) -> ConfigBuilder Add an ephemeral key, which is only stored in memory (i.e., not associated with a file). :param alias: the alias used to reference this key .. py:method:: add_overlay(overlay_class: str, key_alias: str, walkers: list[WalkerDefinition], bootstrappers: list[BootstrapperDefinition], initialize: dict[str, Any], on_start: list[tuple], allow_duplicate: bool = False) -> ConfigBuilder Add an overlay by its class name. You can choose from the default communities or register your own (see IPv8's ``extra_communities`` for the latter). Whatever key alias you choose for this overlay should be registered through add_key. The default communities include: - 'AttestationCommunity' - 'DiscoveryCommunity' - 'HiddenTunnelCommunity' - 'IdentityCommunity' - 'TunnelCommunity' - 'DHTDiscoveryCommunity' The initialize argument is a key-value mapping passed to the constructor (__init__) of the overlay. The on_start contains a list of tuples that specify the method to call on the overlay when IPv8 has initialized, coupled to the positional arguments to pass to the method, for example to call ``some_method(1, 2)``: [("some_method", 1, 2)] Lastly, IPv8 is capable of loading two distinct instances of the same overlay class. Set ``allow_duplicate`` to explicitly allow this (usually this is programmer error).