libp2p.filecoin package

Filecoin DX helpers for py-libp2p. This package locks canonical protocol/topic constants and ships bootstrap/preset helpers plus a lightweight CLI.

Scope boundary and architecture positioning:

Submodules

libp2p.filecoin.constants module

libp2p.filecoin.constants.blocks_topic(network_name: str) str
libp2p.filecoin.constants.dht_protocol_name(network_name: str) TProtocol
libp2p.filecoin.constants.filecoin_message_id(msg: object) bytes

Expect msg to expose a bytes-like data attribute.

libp2p.filecoin.constants.messages_topic(network_name: str) str

libp2p.filecoin.networks module

class libp2p.filecoin.networks.FilecoinNetworkPreset(name: 'NetworkAlias', genesis_network_name: 'str', bootstrap_addresses: 'tuple[str, ...]')

Bases: object

bootstrap_addresses: tuple[str, ...]
genesis_network_name: str
name: Literal['mainnet', 'calibnet']
libp2p.filecoin.networks.get_network_preset(network: Literal['mainnet', 'calibnet'] | str) FilecoinNetworkPreset

libp2p.filecoin.bootstrap module

libp2p.filecoin.bootstrap.filter_bootstrap_for_transport(addrs: list[str], include_tcp: bool = True, include_quic: bool = False) list[str]
libp2p.filecoin.bootstrap.get_bootstrap_addresses(network: str, canonical: bool = True) list[str]
libp2p.filecoin.bootstrap.get_runtime_bootstrap_addresses(network: str, resolve_dns: bool = True, include_quic: bool = False) list[str]
libp2p.filecoin.bootstrap.resolve_dns_bootstrap_to_ip4_tcp(addrs: list[str]) list[str]

libp2p.filecoin.pubsub module

libp2p.filecoin.pubsub.build_filecoin_gossipsub(network_name: str, bootstrapper: bool = False, direct_peers: Sequence[PeerInfo] | None = None, score_mode: str = 'thresholds_only', protocols: Sequence[TProtocol] | None = None) GossipSub
libp2p.filecoin.pubsub.build_filecoin_pubsub(host: IHost, network_name: str, bootstrapper: bool = False, gossipsub: GossipSub | None = None, score_mode: str = 'thresholds_only', strict_signing: bool = True, direct_peers: Sequence[PeerInfo] | None = None) Pubsub
libp2p.filecoin.pubsub.build_filecoin_score_params(mode: str = 'thresholds_only') ScoreParams

libp2p.filecoin.cli module

libp2p.filecoin.cli.build_parser() ArgumentParser
libp2p.filecoin.cli.main(argv: Sequence[str] | None = None) int

Module contents

Filecoin-focused developer experience helpers for py-libp2p.

class libp2p.filecoin.FilecoinAddress(protocol: Literal[0, 1, 2, 3, 4], is_testnet: bool, payload: bytes, namespace: int | None)

Bases: object

A parsed Filecoin address.

property is_delegated: bool
is_testnet: bool
namespace: int | None
payload: bytes
property prefix: str
protocol: Literal[0, 1, 2, 3, 4]
property subaddress: bytes

For delegated addresses, the subaddress bytes (after namespace prefix).

class libp2p.filecoin.FilecoinNetworkPreset(name: 'NetworkAlias', genesis_network_name: 'str', bootstrap_addresses: 'tuple[str, ...]')

Bases: object

bootstrap_addresses: tuple[str, ...]
genesis_network_name: str
name: Literal['mainnet', 'calibnet']
libp2p.filecoin.address_protocol(addr_str: str) Literal[0, 1, 2, 3, 4]

Return the protocol indicator byte from addr_str without full parsing.

libp2p.filecoin.blocks_topic(network_name: str) str
libp2p.filecoin.build_filecoin_gossipsub(network_name: str, bootstrapper: bool = False, direct_peers: Sequence[PeerInfo] | None = None, score_mode: str = 'thresholds_only', protocols: Sequence[TProtocol] | None = None) GossipSub
libp2p.filecoin.build_filecoin_pubsub(host: IHost, network_name: str, bootstrapper: bool = False, gossipsub: GossipSub | None = None, score_mode: str = 'thresholds_only', strict_signing: bool = True, direct_peers: Sequence[PeerInfo] | None = None) Pubsub
libp2p.filecoin.build_filecoin_score_params(mode: str = 'thresholds_only') ScoreParams
libp2p.filecoin.dht_protocol_name(network_name: str) TProtocol
libp2p.filecoin.filecoin_message_id(msg: object) bytes

Expect msg to expose a bytes-like data attribute.

libp2p.filecoin.filter_bootstrap_for_transport(addrs: list[str], include_tcp: bool = True, include_quic: bool = False) list[str]
libp2p.filecoin.get_bootstrap_addresses(network: str, canonical: bool = True) list[str]
libp2p.filecoin.get_network_preset(network: Literal['mainnet', 'calibnet'] | str) FilecoinNetworkPreset
libp2p.filecoin.get_runtime_bootstrap_addresses(network: str, resolve_dns: bool = True, include_quic: bool = False) list[str]
libp2p.filecoin.is_valid_address(addr_str: str) bool

Return True if addr_str is a syntactically valid Filecoin address.

libp2p.filecoin.make_delegated_address(namespace: int, subaddress: bytes, *, is_testnet: bool = False) str

Create a delegated (f4/t4) Filecoin address.

namespace is the integer namespace (e.g. 10 for Ethereum Address Manager). subaddress is the raw sub-address bytes (e.g. 20-byte Ethereum address).

libp2p.filecoin.make_id_address(actor_id: int, *, is_testnet: bool = False) str

Create an ID address (f0/t0) from a numeric actor ID.

libp2p.filecoin.messages_topic(network_name: str) str
libp2p.filecoin.parse_address(addr_str: str) FilecoinAddress

Parse a Filecoin address string (e.g. f1..., f410..., t410...).

Raises ValueError if addr_str is not a valid Filecoin address.

libp2p.filecoin.resolve_dns_bootstrap_to_ip4_tcp(addrs: list[str]) list[str]