Added bootstrap module

This commit is contained in:
sumanjeet0012@gmail.com
2025-06-29 16:10:27 +05:30
parent 92c9ba7e46
commit 12ad2dcdf4
12 changed files with 419 additions and 4 deletions

View File

@ -249,6 +249,7 @@ def new_host(
muxer_preference: Literal["YAMUX", "MPLEX"] | None = None,
listen_addrs: Sequence[multiaddr.Multiaddr] | None = None,
enable_mDNS: bool = False,
bootstrap: list[str] | None = None,
) -> IHost:
"""
Create a new libp2p host based on the given parameters.
@ -261,6 +262,7 @@ def new_host(
:param muxer_preference: optional explicit muxer preference
:param listen_addrs: optional list of multiaddrs to listen on
:param enable_mDNS: whether to enable mDNS discovery
:param bootstrap: optional list of bootstrap peer addresses as strings
:return: return a host instance
"""
swarm = new_swarm(
@ -273,7 +275,7 @@ def new_host(
)
if disc_opt is not None:
return RoutedHost(swarm, disc_opt, enable_mDNS)
return BasicHost(swarm, enable_mDNS)
return RoutedHost(swarm, disc_opt, enable_mDNS, bootstrap)
return BasicHost(swarm, enable_mDNS, bootstrap)
__version__ = __version("libp2p")