diff --git a/examples/bootstrap/bootstrap.py b/examples/bootstrap/bootstrap.py index 415b7a81..2ab24d54 100644 --- a/examples/bootstrap/bootstrap.py +++ b/examples/bootstrap/bootstrap.py @@ -29,11 +29,16 @@ def on_peer_discovery(peer_info: PeerInfo) -> None: logger.info(f" Addresses: {[str(addr) for addr in peer_info.addrs]}") -# Example bootstrap peers (you can replace with real bootstrap nodes) +# Example bootstrap peers ( valid IPFS bootstrap nodes) BOOTSTRAP_PEERS = [ - # IPFS bootstrap nodes (examples - replace with actual working nodes) - "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SznbYGzPwp8qDrq", + "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", + "/ip4/128.199.219.111/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", + "/ip4/104.236.76.40/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64", + "/ip4/178.62.158.247/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd", + "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM", + "/ip6/2400:6180:0:d0::151:6001/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu", + "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/p2p/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm", ] diff --git a/libp2p/discovery/bootstrap/bootstrap.py b/libp2p/discovery/bootstrap/bootstrap.py index 49e070e5..0f9a0b9b 100644 --- a/libp2p/discovery/bootstrap/bootstrap.py +++ b/libp2p/discovery/bootstrap/bootstrap.py @@ -32,7 +32,7 @@ class BootstrapDiscovery: try: self._process_bootstrap_addr(addr_str) except Exception as e: - logger.warning(f"Failed to process bootstrap address {addr_str}: {e}") + logger.debug(f"Failed to process bootstrap address {addr_str}: {e}") def stop(self) -> None: """Clean up bootstrap discovery resources.""" @@ -41,11 +41,18 @@ class BootstrapDiscovery: def _process_bootstrap_addr(self, addr_str: str) -> None: """Convert string address to PeerInfo and add to peerstore.""" - # Convert string to Multiaddr - multiaddr = Multiaddr(addr_str) + try: + multiaddr = Multiaddr(addr_str) + except Exception as e: + logger.debug(f"Invalid multiaddr format '{addr_str}': {e}") + return # Extract peer info from multiaddr - peer_info = info_from_p2p_addr(multiaddr) + try: + peer_info = info_from_p2p_addr(multiaddr) + except Exception as e: + logger.debug(f"Failed to extract peer info from '{addr_str}': {e}") + return # Skip if it's our own peer if peer_info.peer_id == self.swarm.get_peer_id(): @@ -65,5 +72,3 @@ class BootstrapDiscovery: # Emit peer discovery event peerDiscovery.emit_peer_discovered(peer_info) - - logger.info(f"Discovered bootstrap peer: {peer_info.peer_id}")