Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPFS integration #35

Merged
merged 15 commits into from
Jul 3, 2024
Merged
15 changes: 15 additions & 0 deletions src/lightning_hivemind/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ class HivemindStrategy(Strategy):
initial_peers: If connecting to a running process, a list of initial peers needs to be passed in.
This can also be set via the env variable ``INITIAL_PEERS``.

use_ipfs: Use IPFS to find initial_peers. If enabled, you only need to provide /p2p/XXXX part of the
multiaddrs for the initial_peers (no need to specify a particular IPv4/IPv6 host and port)"

wait_timeout: a kademlia rpc request is deemed lost if we did not receive a reply in this many seconds,
useful if `use_ipfs=True`

bootstrap_timeout: after one of peers responds, await other peers for at most this many seconds

**optimizer_kwargs: kwargs are passed to the :class:`hivemind.Optimizer` class.
"""

Expand All @@ -128,6 +136,9 @@ def __init__(
averager_opts: Optional[Dict] = None,
host_maddrs: Optional[List] = None,
initial_peers: Optional[Union[str, List]] = None,
use_ipfs: bool = False,
wait_timeout: int = 3,
bootstrap_timeout: Optional[float] = None,
**optimizer_kwargs: Any,
):
if platform.system() != "Linux":
Expand Down Expand Up @@ -165,6 +176,10 @@ def __init__(
start=True,
initial_peers=initial_peers,
host_maddrs=host_maddrs if host_maddrs is not None else ["/ip4/0.0.0.0/tcp/0", "/ip4/0.0.0.0/udp/0/quic"],
use_ipfs=use_ipfs,
wait_timeout=wait_timeout,
bootstrap_timeout=bootstrap_timeout,
ensure_bootstrap_success=bool(not use_ipfs),
)

visible_addresses = [
Expand Down