libp2p 0.2.8__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. {libp2p-0.2.8/libp2p.egg-info → libp2p-0.3.0}/PKG-INFO +40 -34
  2. {libp2p-0.2.8 → libp2p-0.3.0}/README.md +26 -26
  3. libp2p-0.3.0/examples/advanced/network_discover.py +90 -0
  4. libp2p-0.3.0/examples/bootstrap/bootstrap.py +158 -0
  5. {libp2p-0.2.8 → libp2p-0.3.0}/examples/chat/chat.py +33 -6
  6. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_encryption_insecure.py +15 -7
  7. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_encryption_noise.py +9 -4
  8. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_encryption_secio.py +9 -4
  9. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_multiplexer.py +9 -4
  10. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_net_stream.py +12 -4
  11. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_peer_discovery.py +11 -5
  12. libp2p-0.3.0/examples/doc-examples/example_quic_transport.py +49 -0
  13. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_running.py +9 -4
  14. {libp2p-0.2.8 → libp2p-0.3.0}/examples/doc-examples/example_transport.py +9 -4
  15. libp2p-0.3.0/examples/doc-examples/multiple_connections_example.py +210 -0
  16. {libp2p-0.2.8 → libp2p-0.3.0}/examples/echo/echo.py +51 -17
  17. libp2p-0.3.0/examples/echo/echo_quic.py +207 -0
  18. libp2p-0.3.0/examples/identify/identify.py +326 -0
  19. libp2p-0.3.0/examples/identify_push/identify_push_demo.py +312 -0
  20. libp2p-0.3.0/examples/identify_push/identify_push_listener_dialer.py +455 -0
  21. libp2p-0.3.0/examples/kademlia/kademlia.py +321 -0
  22. libp2p-0.3.0/examples/mDNS/mDNS.py +90 -0
  23. {libp2p-0.2.8 → libp2p-0.3.0}/examples/ping/ping.py +34 -7
  24. {libp2p-0.2.8 → libp2p-0.3.0}/examples/pubsub/pubsub.py +26 -21
  25. libp2p-0.3.0/examples/random_walk/random_walk.py +228 -0
  26. libp2p-0.3.0/examples/test_tcp_data_transfer.py +446 -0
  27. libp2p-0.3.0/examples/transport_integration_demo.py +210 -0
  28. libp2p-0.3.0/examples/websocket/test_tcp_echo.py +220 -0
  29. libp2p-0.3.0/examples/websocket/test_websocket_transport.py +145 -0
  30. libp2p-0.3.0/examples/websocket/websocket_demo.py +448 -0
  31. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/__init__.py +113 -18
  32. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/abc.py +943 -113
  33. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/pb/crypto_pb2.py +2 -2
  34. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/pb/crypto_pb2.pyi +2 -0
  35. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/custom_types.py +9 -6
  36. libp2p-0.3.0/libp2p/discovery/bootstrap/__init__.py +5 -0
  37. libp2p-0.3.0/libp2p/discovery/bootstrap/bootstrap.py +312 -0
  38. libp2p-0.3.0/libp2p/discovery/bootstrap/utils.py +51 -0
  39. libp2p-0.3.0/libp2p/discovery/events/peerDiscovery.py +26 -0
  40. libp2p-0.3.0/libp2p/discovery/mdns/broadcaster.py +91 -0
  41. libp2p-0.3.0/libp2p/discovery/mdns/listener.py +83 -0
  42. libp2p-0.3.0/libp2p/discovery/mdns/mdns.py +73 -0
  43. libp2p-0.3.0/libp2p/discovery/mdns/utils.py +11 -0
  44. libp2p-0.3.0/libp2p/discovery/random_walk/__init__.py +17 -0
  45. libp2p-0.3.0/libp2p/discovery/random_walk/config.py +16 -0
  46. libp2p-0.3.0/libp2p/discovery/random_walk/exceptions.py +19 -0
  47. libp2p-0.3.0/libp2p/discovery/random_walk/random_walk.py +218 -0
  48. libp2p-0.3.0/libp2p/discovery/random_walk/rt_refresh_manager.py +208 -0
  49. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/basic_host.py +61 -8
  50. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/defaults.py +4 -1
  51. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/routed_host.py +8 -2
  52. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify/identify.py +64 -3
  53. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify/pb/identify_pb2.py +2 -2
  54. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify/pb/identify_pb2.pyi +5 -2
  55. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify_push/identify_push.py +111 -33
  56. libp2p-0.3.0/libp2p/kad_dht/__init__.py +30 -0
  57. libp2p-0.3.0/libp2p/kad_dht/common.py +14 -0
  58. libp2p-0.3.0/libp2p/kad_dht/kad_dht.py +825 -0
  59. libp2p-0.3.0/libp2p/kad_dht/pb/kademlia_pb2.py +34 -0
  60. libp2p-0.3.0/libp2p/kad_dht/pb/kademlia_pb2.pyi +70 -0
  61. libp2p-0.3.0/libp2p/kad_dht/peer_routing.py +460 -0
  62. libp2p-0.3.0/libp2p/kad_dht/provider_store.py +612 -0
  63. libp2p-0.3.0/libp2p/kad_dht/routing_table.py +745 -0
  64. libp2p-0.3.0/libp2p/kad_dht/utils.py +197 -0
  65. libp2p-0.3.0/libp2p/kad_dht/value_store.py +416 -0
  66. libp2p-0.3.0/libp2p/network/config.py +70 -0
  67. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/connection/swarm_connection.py +36 -1
  68. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/stream/net_stream.py +8 -2
  69. libp2p-0.3.0/libp2p/network/swarm.py +787 -0
  70. libp2p-0.3.0/libp2p/peer/envelope.py +276 -0
  71. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/peer/id.py +8 -9
  72. libp2p-0.3.0/libp2p/peer/pb/crypto_pb2.py +31 -0
  73. libp2p-0.3.0/libp2p/peer/pb/crypto_pb2.pyi +33 -0
  74. libp2p-0.3.0/libp2p/peer/pb/envelope_pb2.py +28 -0
  75. libp2p-0.3.0/libp2p/peer/pb/envelope_pb2.pyi +18 -0
  76. libp2p-0.3.0/libp2p/peer/pb/peer_record_pb2.py +29 -0
  77. libp2p-0.3.0/libp2p/peer/pb/peer_record_pb2.pyi +21 -0
  78. libp2p-0.3.0/libp2p/peer/peer_record.py +251 -0
  79. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/peer/peerdata.py +80 -0
  80. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/peer/peerinfo.py +22 -1
  81. libp2p-0.3.0/libp2p/peer/peerstore.py +578 -0
  82. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/protocol_muxer/multiselect.py +53 -30
  83. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/protocol_muxer/multiselect_client.py +54 -28
  84. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/protocol_muxer/multiselect_communicator.py +8 -2
  85. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/floodsub.py +7 -13
  86. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/gossipsub.py +292 -120
  87. libp2p-0.3.0/libp2p/pubsub/pb/rpc_pb2.py +52 -0
  88. libp2p-0.3.0/libp2p/pubsub/pb/rpc_pb2.pyi +132 -0
  89. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/pubsub.py +103 -16
  90. libp2p-0.3.0/libp2p/pubsub/utils.py +80 -0
  91. libp2p-0.3.0/libp2p/relay/__init__.py +37 -0
  92. libp2p-0.3.0/libp2p/relay/circuit_v2/__init__.py +46 -0
  93. libp2p-0.3.0/libp2p/relay/circuit_v2/config.py +182 -0
  94. libp2p-0.3.0/libp2p/relay/circuit_v2/dcutr.py +596 -0
  95. libp2p-0.3.0/libp2p/relay/circuit_v2/discovery.py +549 -0
  96. libp2p-0.3.0/libp2p/relay/circuit_v2/nat.py +300 -0
  97. libp2p-0.3.0/libp2p/relay/circuit_v2/pb/__init__.py +21 -0
  98. libp2p-0.3.0/libp2p/relay/circuit_v2/pb/circuit_pb2.py +39 -0
  99. libp2p-0.3.0/libp2p/relay/circuit_v2/pb/circuit_pb2.pyi +184 -0
  100. libp2p-0.3.0/libp2p/relay/circuit_v2/pb/dcutr_pb2.py +27 -0
  101. libp2p-0.3.0/libp2p/relay/circuit_v2/pb/dcutr_pb2.pyi +53 -0
  102. libp2p-0.3.0/libp2p/relay/circuit_v2/protocol.py +854 -0
  103. libp2p-0.3.0/libp2p/relay/circuit_v2/protocol_buffer.py +55 -0
  104. libp2p-0.3.0/libp2p/relay/circuit_v2/resources.py +276 -0
  105. libp2p-0.3.0/libp2p/relay/circuit_v2/transport.py +429 -0
  106. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/insecure/transport.py +32 -3
  107. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/io.py +14 -3
  108. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/messages.py +29 -1
  109. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/patterns.py +35 -0
  110. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/transport.py +0 -5
  111. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/security_multistream.py +8 -1
  112. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/mplex/mplex_stream.py +63 -52
  113. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/muxer_multistream.py +21 -8
  114. libp2p-0.3.0/libp2p/stream_muxer/rw_lock.py +70 -0
  115. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/yamux/yamux.py +222 -146
  116. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/constants.py +5 -0
  117. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/utils.py +4 -2
  118. libp2p-0.3.0/libp2p/transport/__init__.py +57 -0
  119. libp2p-0.3.0/libp2p/transport/quic/config.py +345 -0
  120. libp2p-0.3.0/libp2p/transport/quic/connection.py +1489 -0
  121. libp2p-0.3.0/libp2p/transport/quic/exceptions.py +391 -0
  122. libp2p-0.3.0/libp2p/transport/quic/listener.py +1041 -0
  123. libp2p-0.3.0/libp2p/transport/quic/security.py +1165 -0
  124. libp2p-0.3.0/libp2p/transport/quic/stream.py +656 -0
  125. libp2p-0.3.0/libp2p/transport/quic/transport.py +491 -0
  126. libp2p-0.3.0/libp2p/transport/quic/utils.py +466 -0
  127. libp2p-0.3.0/libp2p/transport/transport_registry.py +267 -0
  128. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/transport/upgrader.py +13 -8
  129. libp2p-0.3.0/libp2p/transport/websocket/connection.py +198 -0
  130. libp2p-0.3.0/libp2p/transport/websocket/listener.py +225 -0
  131. libp2p-0.3.0/libp2p/transport/websocket/multiaddr_utils.py +202 -0
  132. libp2p-0.3.0/libp2p/transport/websocket/transport.py +229 -0
  133. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/utils/__init__.py +17 -0
  134. libp2p-0.3.0/libp2p/utils/address_validation.py +160 -0
  135. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/utils/logging.py +24 -12
  136. libp2p-0.3.0/libp2p/utils/paths.py +267 -0
  137. libp2p-0.3.0/libp2p/utils/varint.py +232 -0
  138. {libp2p-0.2.8 → libp2p-0.3.0/libp2p.egg-info}/PKG-INFO +40 -34
  139. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p.egg-info/SOURCES.txt +156 -1
  140. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p.egg-info/entry_points.txt +2 -0
  141. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p.egg-info/requires.txt +11 -5
  142. {libp2p-0.2.8 → libp2p-0.3.0}/pyproject.toml +21 -11
  143. libp2p-0.3.0/scripts/audit_paths.py +255 -0
  144. libp2p-0.3.0/tests/__init__.py +0 -0
  145. libp2p-0.3.0/tests/core/host/test_basic_host.py +61 -0
  146. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/host/test_live_peers.py +2 -2
  147. libp2p-0.3.0/tests/core/identity/identify/test_identify.py +99 -0
  148. libp2p-0.3.0/tests/core/identity/identify/test_identify_integration.py +241 -0
  149. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/identity/identify_push/test_identify_push.py +286 -0
  150. libp2p-0.3.0/tests/core/identity/identify_push/test_identify_push_integration.py +552 -0
  151. libp2p-0.3.0/tests/core/kad_dht/test_kad_dht.py +504 -0
  152. libp2p-0.3.0/tests/core/kad_dht/test_unit_peer_routing.py +461 -0
  153. libp2p-0.3.0/tests/core/kad_dht/test_unit_provider_store.py +805 -0
  154. libp2p-0.3.0/tests/core/kad_dht/test_unit_routing_table.py +397 -0
  155. libp2p-0.3.0/tests/core/kad_dht/test_unit_value_store.py +504 -0
  156. libp2p-0.3.0/tests/core/network/test_enhanced_swarm.py +325 -0
  157. libp2p-0.3.0/tests/core/network/test_notifee_performance.py +82 -0
  158. libp2p-0.3.0/tests/core/network/test_notify.py +297 -0
  159. libp2p-0.3.0/tests/core/network/test_notify_listen_lifecycle.py +76 -0
  160. libp2p-0.3.0/tests/core/network/test_swarm.py +372 -0
  161. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_addrbook.py +53 -0
  162. libp2p-0.3.0/tests/core/peer/test_envelope.py +129 -0
  163. libp2p-0.3.0/tests/core/peer/test_peer_record.py +112 -0
  164. libp2p-0.3.0/tests/core/peer/test_peerdata.py +241 -0
  165. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_peerinfo.py +4 -5
  166. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_peerstore.py +58 -0
  167. libp2p-0.3.0/tests/core/protocol_muxer/test_negotiate_timeout.py +149 -0
  168. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/protocol_muxer/test_protocol_muxer.py +59 -0
  169. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_gossipsub.py +428 -3
  170. libp2p-0.3.0/tests/core/pubsub/test_gossipsub_px_and_backoff.py +275 -0
  171. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_pubsub.py +148 -5
  172. libp2p-0.3.0/tests/core/pubsub/test_pubsub_notifee_integration.py +90 -0
  173. libp2p-0.3.0/tests/core/relay/test_circuit_v2_discovery.py +443 -0
  174. libp2p-0.3.0/tests/core/relay/test_circuit_v2_protocol.py +665 -0
  175. libp2p-0.3.0/tests/core/relay/test_circuit_v2_transport.py +346 -0
  176. libp2p-0.3.0/tests/core/relay/test_dcutr_integration.py +563 -0
  177. libp2p-0.3.0/tests/core/relay/test_dcutr_protocol.py +208 -0
  178. libp2p-0.3.0/tests/core/relay/test_nat.py +297 -0
  179. libp2p-0.3.0/tests/core/security/test_insecure_peerstore_integration.py +314 -0
  180. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/security/test_security_multistream.py +27 -3
  181. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/test_mplex_stream.py +37 -0
  182. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/test_multiplexer_selection.py +6 -3
  183. libp2p-0.3.0/tests/core/stream_muxer/test_muxer_multistream.py +108 -0
  184. libp2p-0.3.0/tests/core/stream_muxer/test_read_write_lock.py +590 -0
  185. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/test_yamux.py +1 -1
  186. libp2p-0.3.0/tests/core/stream_muxer/test_yamux_interleaving.py +199 -0
  187. libp2p-0.3.0/tests/core/stream_muxer/test_yamux_interleaving_EOF.py +195 -0
  188. libp2p-0.3.0/tests/core/transport/quic/test_concurrency.py +0 -0
  189. libp2p-0.3.0/tests/core/transport/quic/test_connection.py +553 -0
  190. libp2p-0.3.0/tests/core/transport/quic/test_connection_id.py +624 -0
  191. libp2p-0.3.0/tests/core/transport/quic/test_integration.py +418 -0
  192. libp2p-0.3.0/tests/core/transport/quic/test_listener.py +150 -0
  193. libp2p-0.3.0/tests/core/transport/quic/test_transport.py +123 -0
  194. libp2p-0.3.0/tests/core/transport/quic/test_utils.py +321 -0
  195. libp2p-0.3.0/tests/core/transport/test_transport_registry.py +324 -0
  196. libp2p-0.3.0/tests/core/transport/test_upgrader.py +27 -0
  197. libp2p-0.3.0/tests/core/transport/test_websocket.py +1631 -0
  198. libp2p-0.3.0/tests/core/transport/test_websocket_p2p.py +532 -0
  199. libp2p-0.3.0/tests/core/utils/test_varint.py +215 -0
  200. libp2p-0.3.0/tests/discovery/__init__.py +1 -0
  201. libp2p-0.3.0/tests/discovery/bootstrap/__init__.py +1 -0
  202. libp2p-0.3.0/tests/discovery/bootstrap/test_integration.py +52 -0
  203. libp2p-0.3.0/tests/discovery/bootstrap/test_utils.py +39 -0
  204. libp2p-0.3.0/tests/discovery/mdns/__init__.py +0 -0
  205. libp2p-0.3.0/tests/discovery/mdns/test_broadcaster.py +91 -0
  206. libp2p-0.3.0/tests/discovery/mdns/test_listener.py +114 -0
  207. libp2p-0.3.0/tests/discovery/mdns/test_mdns.py +121 -0
  208. libp2p-0.3.0/tests/discovery/mdns/test_utils.py +39 -0
  209. libp2p-0.3.0/tests/discovery/random_walk/test_random_walk.py +99 -0
  210. libp2p-0.3.0/tests/discovery/random_walk/test_rt_refresh_manager.py +451 -0
  211. libp2p-0.3.0/tests/examples/test_echo_thin_waist.py +109 -0
  212. libp2p-0.3.0/tests/examples/test_examples_bind_address.py +117 -0
  213. libp2p-0.3.0/tests/examples/test_quic_echo_example.py +6 -0
  214. libp2p-0.3.0/tests/interop/__init__.py +0 -0
  215. libp2p-0.3.0/tests/interop/js_libp2p/README.md +81 -0
  216. libp2p-0.3.0/tests/interop/js_libp2p/js_node/README.md +53 -0
  217. libp2p-0.3.0/tests/interop/js_libp2p/js_node/package.json +39 -0
  218. libp2p-0.3.0/tests/interop/js_libp2p/js_node/src/package.json +21 -0
  219. libp2p-0.3.0/tests/interop/js_libp2p/js_node/src/ping.js +204 -0
  220. libp2p-0.3.0/tests/interop/js_libp2p/js_node/src/ping_client.js +241 -0
  221. libp2p-0.3.0/tests/interop/js_libp2p/js_node/src/ping_server.js +167 -0
  222. libp2p-0.3.0/tests/interop/js_libp2p/js_node/src/ws_ping_node.mjs +122 -0
  223. libp2p-0.3.0/tests/interop/js_libp2p/scripts/run_test.ps1 +194 -0
  224. libp2p-0.3.0/tests/interop/js_libp2p/scripts/run_test.sh +215 -0
  225. libp2p-0.3.0/tests/interop/nim_libp2p/.gitignore +8 -0
  226. libp2p-0.3.0/tests/interop/nim_libp2p/conftest.py +119 -0
  227. libp2p-0.3.0/tests/interop/nim_libp2p/nim_echo_server.nim +108 -0
  228. libp2p-0.3.0/tests/interop/nim_libp2p/scripts/setup_nim_echo.sh +74 -0
  229. libp2p-0.3.0/tests/interop/nim_libp2p/test_echo_interop.py +195 -0
  230. libp2p-0.3.0/tests/interop/test_js_ws_ping.py +127 -0
  231. libp2p-0.3.0/tests/utils/__init__.py +0 -0
  232. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/factories.py +20 -4
  233. libp2p-0.3.0/tests/utils/interop/__init__.py +0 -0
  234. libp2p-0.3.0/tests/utils/pubsub/__init__.py +0 -0
  235. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/pubsub/floodsub_integration_test_settings.py +3 -9
  236. libp2p-0.3.0/tests/utils/pubsub/utils.py +87 -0
  237. libp2p-0.3.0/tests/utils/test_address_validation.py +56 -0
  238. libp2p-0.3.0/tests/utils/test_default_bind_address.py +206 -0
  239. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/test_logging.py +36 -12
  240. libp2p-0.3.0/tests/utils/test_paths.py +290 -0
  241. libp2p-0.3.0/tests/utils/utils.py +31 -0
  242. libp2p-0.2.8/examples/identify/identify.py +0 -127
  243. libp2p-0.2.8/examples/identify_push/identify_push_demo.py +0 -163
  244. libp2p-0.2.8/examples/identify_push/identify_push_listener_dialer.py +0 -276
  245. libp2p-0.2.8/libp2p/network/swarm.py +0 -420
  246. libp2p-0.2.8/libp2p/peer/peerstore.py +0 -244
  247. libp2p-0.2.8/libp2p/pubsub/pb/rpc_pb2.py +0 -49
  248. libp2p-0.2.8/libp2p/pubsub/pb/rpc_pb2.pyi +0 -297
  249. libp2p-0.2.8/libp2p/utils/varint.py +0 -87
  250. libp2p-0.2.8/tests/core/host/test_basic_host.py +0 -24
  251. libp2p-0.2.8/tests/core/identity/identify/test_identify.py +0 -79
  252. libp2p-0.2.8/tests/core/network/test_notify.py +0 -130
  253. libp2p-0.2.8/tests/core/network/test_swarm.py +0 -186
  254. libp2p-0.2.8/tests/core/peer/test_peerdata.py +0 -109
  255. libp2p-0.2.8/tests/interop/js_libp2p/test_js_basic.py +0 -5
  256. libp2p-0.2.8/tests/utils/pubsub/utils.py +0 -42
  257. {libp2p-0.2.8 → libp2p-0.3.0}/LICENSE-APACHE +0 -0
  258. {libp2p-0.2.8 → libp2p-0.3.0}/LICENSE-MIT +0 -0
  259. {libp2p-0.2.8 → libp2p-0.3.0}/MANIFEST.in +0 -0
  260. {libp2p-0.2.8 → libp2p-0.3.0}/docs/conf.py +0 -0
  261. {libp2p-0.2.8 → libp2p-0.3.0}/examples/__init__.py +0 -0
  262. {libp2p-0.2.8 → libp2p-0.3.0}/examples/chat/__init__.py +0 -0
  263. {libp2p-0.2.8 → libp2p-0.3.0}/examples/echo/__init__.py +0 -0
  264. {libp2p-0.2.8 → libp2p-0.3.0}/examples/identify/__init__.py +0 -0
  265. {libp2p-0.2.8 → libp2p-0.3.0}/examples/identify_push/__init__.py +0 -0
  266. {libp2p-0.2.8 → libp2p-0.3.0}/examples/ping/__init__.py +0 -0
  267. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/__init__.py +0 -0
  268. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/authenticated_encryption.py +0 -0
  269. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/ecc.py +0 -0
  270. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/ed25519.py +0 -0
  271. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/exceptions.py +0 -0
  272. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/key_exchange.py +0 -0
  273. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/keys.py +0 -0
  274. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/pb/__init__.py +0 -0
  275. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/rsa.py +0 -0
  276. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/secp256k1.py +0 -0
  277. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/serialization.py +0 -0
  278. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/crypto/x25519.py +0 -0
  279. {libp2p-0.2.8/libp2p/host → libp2p-0.3.0/libp2p/discovery}/__init__.py +0 -0
  280. {libp2p-0.2.8/libp2p/host/autonat/pb → libp2p-0.3.0/libp2p/discovery/events}/__init__.py +0 -0
  281. {libp2p-0.2.8/libp2p/identity/identify/pb → libp2p-0.3.0/libp2p/discovery/mdns}/__init__.py +0 -0
  282. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/exceptions.py +0 -0
  283. {libp2p-0.2.8/libp2p/io → libp2p-0.3.0/libp2p/host}/__init__.py +0 -0
  284. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/__init__.py +0 -0
  285. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/autonat.py +0 -0
  286. {libp2p-0.2.8/libp2p/network → libp2p-0.3.0/libp2p/host/autonat/pb}/__init__.py +0 -0
  287. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/pb/autonat_pb2.py +0 -0
  288. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/pb/autonat_pb2.pyi +0 -0
  289. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/pb/autonat_pb2_grpc.py +0 -0
  290. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/pb/autonat_pb2_grpc.pyi +0 -0
  291. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/autonat/pb/generate_proto.py +0 -0
  292. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/exceptions.py +0 -0
  293. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/host/ping.py +0 -0
  294. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/__init__.py +0 -0
  295. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify/__init__.py +0 -0
  296. {libp2p-0.2.8/libp2p/network/connection → libp2p-0.3.0/libp2p/identity/identify/pb}/__init__.py +0 -0
  297. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/identity/identify_push/__init__.py +0 -0
  298. {libp2p-0.2.8/libp2p/network/stream → libp2p-0.3.0/libp2p/io}/__init__.py +0 -0
  299. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/io/abc.py +0 -0
  300. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/io/exceptions.py +0 -0
  301. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/io/msgio.py +0 -0
  302. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/io/trio.py +0 -0
  303. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/io/utils.py +0 -0
  304. {libp2p-0.2.8/libp2p/peer → libp2p-0.3.0/libp2p/kad_dht/pb}/__init__.py +0 -0
  305. {libp2p-0.2.8/libp2p/protocol_muxer → libp2p-0.3.0/libp2p/network}/__init__.py +0 -0
  306. {libp2p-0.2.8/libp2p/pubsub → libp2p-0.3.0/libp2p/network/connection}/__init__.py +0 -0
  307. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/connection/exceptions.py +0 -0
  308. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/connection/raw_connection.py +0 -0
  309. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/exceptions.py +0 -0
  310. {libp2p-0.2.8/libp2p/pubsub/pb → libp2p-0.3.0/libp2p/network/stream}/__init__.py +0 -0
  311. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/network/stream/exceptions.py +0 -0
  312. {libp2p-0.2.8/libp2p/security → libp2p-0.3.0/libp2p/peer}/__init__.py +0 -0
  313. {libp2p-0.2.8/libp2p/security/insecure → libp2p-0.3.0/libp2p/protocol_muxer}/__init__.py +0 -0
  314. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/protocol_muxer/exceptions.py +0 -0
  315. {libp2p-0.2.8/libp2p/security/insecure/pb → libp2p-0.3.0/libp2p/pubsub}/__init__.py +0 -0
  316. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/exceptions.py +0 -0
  317. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/mcache.py +0 -0
  318. {libp2p-0.2.8/libp2p/security/noise → libp2p-0.3.0/libp2p/pubsub/pb}/__init__.py +0 -0
  319. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/pubsub_notifee.py +0 -0
  320. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/subscription.py +0 -0
  321. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/pubsub/validators.py +0 -0
  322. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/py.typed +0 -0
  323. {libp2p-0.2.8/libp2p/security/noise/pb → libp2p-0.3.0/libp2p/security}/__init__.py +0 -0
  324. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/base_session.py +0 -0
  325. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/base_transport.py +0 -0
  326. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/exceptions.py +0 -0
  327. {libp2p-0.2.8/libp2p/security/secio → libp2p-0.3.0/libp2p/security/insecure}/__init__.py +0 -0
  328. {libp2p-0.2.8/libp2p/security/secio → libp2p-0.3.0/libp2p/security/insecure}/pb/__init__.py +0 -0
  329. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/insecure/pb/plaintext_pb2.py +0 -0
  330. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/insecure/pb/plaintext_pb2.pyi +0 -0
  331. {libp2p-0.2.8/libp2p/stream_muxer → libp2p-0.3.0/libp2p/security/noise}/__init__.py +0 -0
  332. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/exceptions.py +0 -0
  333. {libp2p-0.2.8/libp2p/stream_muxer/mplex → libp2p-0.3.0/libp2p/security/noise/pb}/__init__.py +0 -0
  334. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/pb/noise_pb2.py +0 -0
  335. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/noise/pb/noise_pb2.pyi +0 -0
  336. {libp2p-0.2.8/libp2p/tools → libp2p-0.3.0/libp2p/security/secio}/__init__.py +0 -0
  337. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/secio/exceptions.py +0 -0
  338. {libp2p-0.2.8/libp2p/tools/timed_cache → libp2p-0.3.0/libp2p/security/secio/pb}/__init__.py +0 -0
  339. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/secio/pb/spipe_pb2.py +0 -0
  340. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/secio/pb/spipe_pb2.pyi +0 -0
  341. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/secio/transport.py +0 -0
  342. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/security/secure_session.py +0 -0
  343. {libp2p-0.2.8/libp2p/transport → libp2p-0.3.0/libp2p/stream_muxer}/__init__.py +0 -0
  344. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/exceptions.py +0 -0
  345. {libp2p-0.2.8/libp2p/transport/tcp → libp2p-0.3.0/libp2p/stream_muxer/mplex}/__init__.py +0 -0
  346. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/mplex/constants.py +0 -0
  347. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/mplex/datastructures.py +0 -0
  348. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/mplex/exceptions.py +0 -0
  349. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/mplex/mplex.py +0 -0
  350. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/stream_muxer/yamux/__init__.py +0 -0
  351. {libp2p-0.2.8/tests → libp2p-0.3.0/libp2p/tools}/__init__.py +0 -0
  352. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/__init__.py +0 -0
  353. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/_utils.py +0 -0
  354. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/abc.py +0 -0
  355. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/base.py +0 -0
  356. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/exceptions.py +0 -0
  357. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/stats.py +0 -0
  358. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/trio_service.py +0 -0
  359. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/async_service/typing.py +0 -0
  360. {libp2p-0.2.8/tests/utils → libp2p-0.3.0/libp2p/tools/timed_cache}/__init__.py +0 -0
  361. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/timed_cache/base_timed_cache.py +0 -0
  362. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/timed_cache/first_seen_cache.py +0 -0
  363. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/tools/timed_cache/last_seen_cache.py +0 -0
  364. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/transport/exceptions.py +0 -0
  365. {libp2p-0.2.8/tests/utils/interop → libp2p-0.3.0/libp2p/transport/quic}/__init__.py +0 -0
  366. {libp2p-0.2.8/tests/utils/pubsub → libp2p-0.3.0/libp2p/transport/tcp}/__init__.py +0 -0
  367. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/transport/tcp/tcp.py +0 -0
  368. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p/utils/version.py +0 -0
  369. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p.egg-info/dependency_links.txt +0 -0
  370. {libp2p-0.2.8 → libp2p-0.3.0}/libp2p.egg-info/top_level.txt +0 -0
  371. {libp2p-0.2.8 → libp2p-0.3.0}/newsfragments/validate_files.py +0 -0
  372. {libp2p-0.2.8 → libp2p-0.3.0}/scripts/release/test_package.py +0 -0
  373. {libp2p-0.2.8 → libp2p-0.3.0}/setup.cfg +0 -0
  374. {libp2p-0.2.8 → libp2p-0.3.0}/tests/conftest.py +0 -0
  375. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/crypto/test_ed25519.py +0 -0
  376. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/crypto/test_rsa.py +0 -0
  377. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/crypto/test_secp256k1.py +0 -0
  378. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/crypto/test_x25519.py +0 -0
  379. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/examples/test_examples.py +0 -0
  380. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/host/test_autonat.py +0 -0
  381. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/host/test_connected_peers.py +0 -0
  382. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/host/test_ping.py +0 -0
  383. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/host/test_routed_host.py +0 -0
  384. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/network/conftest.py +0 -0
  385. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/network/test_net_stream.py +0 -0
  386. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/network/test_swarm_conn.py +0 -0
  387. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_interop.py +0 -0
  388. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_peerid.py +0 -0
  389. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/peer/test_peermetadata.py +0 -0
  390. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_dummyaccount_demo.py +0 -0
  391. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_floodsub.py +0 -0
  392. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_gossipsub_backward_compatibility.py +0 -0
  393. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_gossipsub_direct_peers.py +0 -0
  394. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_mcache.py +0 -0
  395. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/pubsub/test_subscription.py +0 -0
  396. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/security/noise/test_msg_read_writer.py +0 -0
  397. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/security/noise/test_noise.py +0 -0
  398. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/security/test_secio.py +0 -0
  399. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/conftest.py +0 -0
  400. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/test_async_context_manager.py +0 -0
  401. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/stream_muxer/test_mplex_conn.py +0 -0
  402. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/test_import_and_version.py +0 -0
  403. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/test_libp2p/test_libp2p.py +0 -0
  404. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/tools/async_service/test_trio_based_service.py +0 -0
  405. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/tools/async_service/test_trio_external_api.py +0 -0
  406. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/tools/async_service/test_trio_manager_stats.py +0 -0
  407. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/tools/timed_cache/test_timed_cache.py +0 -0
  408. {libp2p-0.2.8 → libp2p-0.3.0}/tests/core/transport/test_tcp.py +0 -0
  409. {libp2p-0.2.8 → libp2p-0.3.0}/tests/exceptions/test_exceptions.py +0 -0
  410. {libp2p-0.2.8 → libp2p-0.3.0}/tests/interop/go_libp2p/test_go_basic.py +0 -0
  411. {libp2p-0.2.8 → libp2p-0.3.0}/tests/interop/rust_libp2p/test_rust_basic.py +0 -0
  412. {libp2p-0.2.8 → libp2p-0.3.0}/tests/interop/zig_libp2p/test_zig_basic.py +0 -0
  413. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/interop/constants.py +0 -0
  414. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/interop/daemon.py +0 -0
  415. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/interop/envs.py +0 -0
  416. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/interop/process.py +0 -0
  417. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/interop/utils.py +0 -0
  418. {libp2p-0.2.8 → libp2p-0.3.0}/tests/utils/pubsub/dummy_account_node.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libp2p
3
- Version: 0.2.8
3
+ Version: 0.3.0
4
4
  Summary: libp2p: The Python implementation of the libp2p networking stack
5
- Author-email: The Ethereum Foundation <snakecharmers@ethereum.org>
5
+ Maintainer-email: pacrob <pacrob-py-libp2p@proton.me>, Manu Sheel Gupta <manu@seeta.in>, Dave Grantham <dwg@linuxprogrammer.org>
6
6
  License: MIT AND Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/libp2p/py-libp2p
8
8
  Keywords: libp2p,p2p
@@ -18,22 +18,25 @@ Requires-Python: <4.0,>=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE-APACHE
20
20
  License-File: LICENSE-MIT
21
+ Requires-Dist: aioquic>=1.2.0
21
22
  Requires-Dist: base58>=1.0.3
22
- Requires-Dist: coincurve>=10.0.0
23
+ Requires-Dist: coincurve==21.0.0
23
24
  Requires-Dist: exceptiongroup>=1.2.0; python_version < "3.11"
25
+ Requires-Dist: fastecdsa==2.3.2; sys_platform != "win32"
24
26
  Requires-Dist: grpcio>=1.41.0
25
27
  Requires-Dist: lru-dict>=1.1.6
26
- Requires-Dist: multiaddr>=0.0.9
28
+ Requires-Dist: multiaddr>=0.0.11
27
29
  Requires-Dist: mypy-protobuf>=3.0.0
28
30
  Requires-Dist: noiseprotocol>=0.3.0
29
- Requires-Dist: protobuf<4.0.0,>=3.20.1
31
+ Requires-Dist: protobuf<5.0.0,>=4.25.0
30
32
  Requires-Dist: pycryptodome>=3.9.2
31
33
  Requires-Dist: pymultihash>=0.8.2
32
34
  Requires-Dist: pynacl>=1.3.0
33
35
  Requires-Dist: rpcudp>=3.0.0
34
36
  Requires-Dist: trio-typing>=0.0.4
35
37
  Requires-Dist: trio>=0.26.0
36
- Requires-Dist: fastecdsa==2.3.2; sys_platform != "win32"
38
+ Requires-Dist: trio-websocket>=0.11.0
39
+ Requires-Dist: zeroconf<0.148.0,>=0.147.0
37
40
  Provides-Extra: dev
38
41
  Requires-Dist: build>=0.9.0; extra == "dev"
39
42
  Requires-Dist: bump_my_version>=0.19.0; extra == "dev"
@@ -51,6 +54,8 @@ Requires-Dist: p2pclient==0.2.0; extra == "dev"
51
54
  Requires-Dist: pytest>=7.0.0; extra == "dev"
52
55
  Requires-Dist: pytest-xdist>=2.4.0; extra == "dev"
53
56
  Requires-Dist: pytest-trio>=0.5.2; extra == "dev"
57
+ Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
58
+ Requires-Dist: pytest-rerunfailures>=12.0; extra == "dev"
54
59
  Requires-Dist: factory-boy<3.0.0,>=2.12.0; extra == "dev"
55
60
  Requires-Dist: ruff>=0.11.10; extra == "dev"
56
61
  Requires-Dist: pyrefly<0.18.0,>=0.17.1; extra == "dev"
@@ -60,11 +65,12 @@ Requires-Dist: sphinx_rtd_theme>=1.0.0; extra == "docs"
60
65
  Requires-Dist: towncrier<25,>=24; extra == "docs"
61
66
  Requires-Dist: tomli; python_version < "3.11" and extra == "docs"
62
67
  Provides-Extra: test
68
+ Requires-Dist: factory-boy<3.0.0,>=2.12.0; extra == "test"
63
69
  Requires-Dist: p2pclient==0.2.0; extra == "test"
64
70
  Requires-Dist: pytest>=7.0.0; extra == "test"
65
- Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
71
+ Requires-Dist: pytest-timeout>=2.4.0; extra == "test"
66
72
  Requires-Dist: pytest-trio>=0.5.2; extra == "test"
67
- Requires-Dist: factory-boy<3.0.0,>=2.12.0; extra == "test"
73
+ Requires-Dist: pytest-xdist>=2.4.0; extra == "test"
68
74
  Dynamic: license-file
69
75
 
70
76
  # py-libp2p
@@ -81,13 +87,13 @@ Dynamic: license-file
81
87
  [![Build Status](https://img.shields.io/github/actions/workflow/status/libp2p/py-libp2p/tox.yml?branch=main&label=build%20status)](https://github.com/libp2p/py-libp2p/actions/workflows/tox.yml)
82
88
  [![Docs build](https://readthedocs.org/projects/py-libp2p/badge/?version=latest)](http://py-libp2p.readthedocs.io/en/latest/?badge=latest)
83
89
 
84
- > ⚠️ **Warning:** py-libp2p is an experimental and work-in-progress repo under development. We do not yet recommend using py-libp2p in production environments.
90
+ > py-libp2p has moved beyond its experimental roots and is steadily progressing toward production readiness. The core features are stable, and we’re focused on refining performance, expanding protocol support, and ensuring smooth interop with other libp2p implementations. We welcome contributions and real-world usage feedback to help us reach full production maturity.
85
91
 
86
92
  Read more in the [documentation on ReadTheDocs](https://py-libp2p.readthedocs.io/). [View the release notes](https://py-libp2p.readthedocs.io/en/latest/release_notes.html).
87
93
 
88
94
  ## Maintainers
89
95
 
90
- Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
96
+ Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby). Please reach out to us for collaboration or active feedback. If you have questions, feel free to open a new [discussion](https://github.com/libp2p/py-libp2p/discussions). We are also available on the libp2p Discord — join us at #py-libp2p [sub-channel](https://discord.gg/d92MEugb).
91
97
 
92
98
  ## Feature Breakdown
93
99
 
@@ -103,19 +109,19 @@ ______________________________________________________________________
103
109
  | -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
104
110
  | **`libp2p-tcp`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
105
111
  | **`libp2p-quic`** | 🌱 | |
106
- | **`libp2p-websocket`** | ❌ | |
107
- | **`libp2p-webrtc-browser-to-server`** | ❌ | |
108
- | **`libp2p-webrtc-private-to-private`** | ❌ | |
112
+ | **`libp2p-websocket`** | 🌱 | |
113
+ | **`libp2p-webrtc-browser-to-server`** | 🌱 | |
114
+ | **`libp2p-webrtc-private-to-private`** | 🌱 | |
109
115
 
110
116
  ______________________________________________________________________
111
117
 
112
118
  ### NAT Traversal
113
119
 
114
- | **NAT Traversal** | **Status** |
115
- | ----------------------------- | :--------: |
116
- | **`libp2p-circuit-relay-v2`** | ❌ |
117
- | **`libp2p-autonat`** | ❌ |
118
- | **`libp2p-hole-punching`** | ❌ |
120
+ | **NAT Traversal** | **Status** | **Source** |
121
+ | ----------------------------- | :--------: | :-----------------------------------------------------------------------------: |
122
+ | **`libp2p-circuit-relay-v2`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
123
+ | **`libp2p-autonat`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/host/autonat) |
124
+ | **`libp2p-hole-punching`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
119
125
 
120
126
  ______________________________________________________________________
121
127
 
@@ -123,27 +129,27 @@ ______________________________________________________________________
123
129
 
124
130
  | **Secure Communication** | **Status** | **Source** |
125
131
  | ------------------------ | :--------: | :---------------------------------------------------------------------------: |
126
- | **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
127
- | **`libp2p-tls`** | ❌ | |
132
+ | **`libp2p-noise`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
133
+ | **`libp2p-tls`** | 🌱 | |
128
134
 
129
135
  ______________________________________________________________________
130
136
 
131
137
  ### Discovery
132
138
 
133
- | **Discovery** | **Status** |
134
- | -------------------- | :--------: |
135
- | **`bootstrap`** | ❌ |
136
- | **`random-walk`** | ❌ |
137
- | **`mdns-discovery`** | ❌ |
138
- | **`rendezvous`** | ❌ |
139
+ | **Discovery** | **Status** | **Source** |
140
+ | -------------------- | :--------: | :----------------------------------------------------------------------------------: |
141
+ | **`bootstrap`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/bootstrap) |
142
+ | **`random-walk`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/random_walk) |
143
+ | **`mdns-discovery`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/mdns) |
144
+ | **`rendezvous`** | 🌱 | |
139
145
 
140
146
  ______________________________________________________________________
141
147
 
142
148
  ### Peer Routing
143
149
 
144
- | **Peer Routing** | **Status** |
145
- | -------------------- | :--------: |
146
- | **`libp2p-kad-dht`** | ❌ |
150
+ | **Peer Routing** | **Status** | **Source** |
151
+ | -------------------- | :--------: | :--------------------------------------------------------------------: |
152
+ | **`libp2p-kad-dht`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/kad_dht) |
147
153
 
148
154
  ______________________________________________________________________
149
155
 
@@ -158,10 +164,10 @@ ______________________________________________________________________
158
164
 
159
165
  ### Stream Muxers
160
166
 
161
- | **Stream Muxers** | **Status** | **Status** |
162
- | ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
163
- | **`libp2p-yamux`** | 🌱 | |
164
- | **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
167
+ | **Stream Muxers** | **Status** | **Source** |
168
+ | ------------------ | :--------: | :-------------------------------------------------------------------------------: |
169
+ | **`libp2p-yamux`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/yamux) |
170
+ | **`libp2p-mplex`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/mplex) |
165
171
 
166
172
  ______________________________________________________________________
167
173
 
@@ -169,7 +175,7 @@ ______________________________________________________________________
169
175
 
170
176
  | **Storage** | **Status** |
171
177
  | ------------------- | :--------: |
172
- | **`libp2p-record`** | ❌ |
178
+ | **`libp2p-record`** | 🌱 |
173
179
 
174
180
  ______________________________________________________________________
175
181
 
@@ -12,13 +12,13 @@
12
12
  [![Build Status](https://img.shields.io/github/actions/workflow/status/libp2p/py-libp2p/tox.yml?branch=main&label=build%20status)](https://github.com/libp2p/py-libp2p/actions/workflows/tox.yml)
13
13
  [![Docs build](https://readthedocs.org/projects/py-libp2p/badge/?version=latest)](http://py-libp2p.readthedocs.io/en/latest/?badge=latest)
14
14
 
15
- > ⚠️ **Warning:** py-libp2p is an experimental and work-in-progress repo under development. We do not yet recommend using py-libp2p in production environments.
15
+ > py-libp2p has moved beyond its experimental roots and is steadily progressing toward production readiness. The core features are stable, and we’re focused on refining performance, expanding protocol support, and ensuring smooth interop with other libp2p implementations. We welcome contributions and real-world usage feedback to help us reach full production maturity.
16
16
 
17
17
  Read more in the [documentation on ReadTheDocs](https://py-libp2p.readthedocs.io/). [View the release notes](https://py-libp2p.readthedocs.io/en/latest/release_notes.html).
18
18
 
19
19
  ## Maintainers
20
20
 
21
- Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
21
+ Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby). Please reach out to us for collaboration or active feedback. If you have questions, feel free to open a new [discussion](https://github.com/libp2p/py-libp2p/discussions). We are also available on the libp2p Discord — join us at #py-libp2p [sub-channel](https://discord.gg/d92MEugb).
22
22
 
23
23
  ## Feature Breakdown
24
24
 
@@ -34,19 +34,19 @@ ______________________________________________________________________
34
34
  | -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
35
35
  | **`libp2p-tcp`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
36
36
  | **`libp2p-quic`** | 🌱 | |
37
- | **`libp2p-websocket`** | ❌ | |
38
- | **`libp2p-webrtc-browser-to-server`** | ❌ | |
39
- | **`libp2p-webrtc-private-to-private`** | ❌ | |
37
+ | **`libp2p-websocket`** | 🌱 | |
38
+ | **`libp2p-webrtc-browser-to-server`** | 🌱 | |
39
+ | **`libp2p-webrtc-private-to-private`** | 🌱 | |
40
40
 
41
41
  ______________________________________________________________________
42
42
 
43
43
  ### NAT Traversal
44
44
 
45
- | **NAT Traversal** | **Status** |
46
- | ----------------------------- | :--------: |
47
- | **`libp2p-circuit-relay-v2`** | ❌ |
48
- | **`libp2p-autonat`** | ❌ |
49
- | **`libp2p-hole-punching`** | ❌ |
45
+ | **NAT Traversal** | **Status** | **Source** |
46
+ | ----------------------------- | :--------: | :-----------------------------------------------------------------------------: |
47
+ | **`libp2p-circuit-relay-v2`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
48
+ | **`libp2p-autonat`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/host/autonat) |
49
+ | **`libp2p-hole-punching`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/relay/circuit_v2) |
50
50
 
51
51
  ______________________________________________________________________
52
52
 
@@ -54,27 +54,27 @@ ______________________________________________________________________
54
54
 
55
55
  | **Secure Communication** | **Status** | **Source** |
56
56
  | ------------------------ | :--------: | :---------------------------------------------------------------------------: |
57
- | **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58
- | **`libp2p-tls`** | ❌ | |
57
+ | **`libp2p-noise`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
58
+ | **`libp2p-tls`** | 🌱 | |
59
59
 
60
60
  ______________________________________________________________________
61
61
 
62
62
  ### Discovery
63
63
 
64
- | **Discovery** | **Status** |
65
- | -------------------- | :--------: |
66
- | **`bootstrap`** | ❌ |
67
- | **`random-walk`** | ❌ |
68
- | **`mdns-discovery`** | ❌ |
69
- | **`rendezvous`** | ❌ |
64
+ | **Discovery** | **Status** | **Source** |
65
+ | -------------------- | :--------: | :----------------------------------------------------------------------------------: |
66
+ | **`bootstrap`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/bootstrap) |
67
+ | **`random-walk`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/random_walk) |
68
+ | **`mdns-discovery`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/discovery/mdns) |
69
+ | **`rendezvous`** | 🌱 | |
70
70
 
71
71
  ______________________________________________________________________
72
72
 
73
73
  ### Peer Routing
74
74
 
75
- | **Peer Routing** | **Status** |
76
- | -------------------- | :--------: |
77
- | **`libp2p-kad-dht`** | ❌ |
75
+ | **Peer Routing** | **Status** | **Source** |
76
+ | -------------------- | :--------: | :--------------------------------------------------------------------: |
77
+ | **`libp2p-kad-dht`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/kad_dht) |
78
78
 
79
79
  ______________________________________________________________________
80
80
 
@@ -89,10 +89,10 @@ ______________________________________________________________________
89
89
 
90
90
  ### Stream Muxers
91
91
 
92
- | **Stream Muxers** | **Status** | **Status** |
93
- | ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
94
- | **`libp2p-yamux`** | 🌱 | |
95
- | **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
92
+ | **Stream Muxers** | **Status** | **Source** |
93
+ | ------------------ | :--------: | :-------------------------------------------------------------------------------: |
94
+ | **`libp2p-yamux`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/yamux) |
95
+ | **`libp2p-mplex`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/stream_muxer/mplex) |
96
96
 
97
97
  ______________________________________________________________________
98
98
 
@@ -100,7 +100,7 @@ ______________________________________________________________________
100
100
 
101
101
  | **Storage** | **Status** |
102
102
  | ------------------- | :--------: |
103
- | **`libp2p-record`** | ❌ |
103
+ | **`libp2p-record`** | 🌱 |
104
104
 
105
105
  ______________________________________________________________________
106
106
 
@@ -0,0 +1,90 @@
1
+ """
2
+ Advanced demonstration of Thin Waist address handling.
3
+
4
+ Run:
5
+ python -m examples.advanced.network_discovery
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from multiaddr import Multiaddr
11
+
12
+ try:
13
+ from libp2p.utils.address_validation import (
14
+ expand_wildcard_address,
15
+ get_available_interfaces,
16
+ get_optimal_binding_address,
17
+ get_wildcard_address,
18
+ )
19
+ except ImportError:
20
+ # Fallbacks if utilities are missing - use minimal network discovery
21
+ import socket
22
+
23
+ def get_available_interfaces(port: int, protocol: str = "tcp"):
24
+ # Try to get local network interfaces, fallback to loopback
25
+ addrs = []
26
+ try:
27
+ # Get hostname IP (better than hardcoded localhost)
28
+ hostname = socket.gethostname()
29
+ local_ip = socket.gethostbyname(hostname)
30
+ if local_ip != "127.0.0.1":
31
+ addrs.append(Multiaddr(f"/ip4/{local_ip}/{protocol}/{port}"))
32
+ except Exception:
33
+ pass
34
+ # Always include loopback as fallback
35
+ addrs.append(Multiaddr(f"/ip4/127.0.0.1/{protocol}/{port}"))
36
+ return addrs
37
+
38
+ def expand_wildcard_address(addr: Multiaddr, port: int | None = None):
39
+ if port is None:
40
+ return [addr]
41
+ addr_str = str(addr).rsplit("/", 1)[0]
42
+ return [Multiaddr(addr_str + f"/{port}")]
43
+
44
+ def get_optimal_binding_address(port: int, protocol: str = "tcp"):
45
+ # Try to get a non-loopback address first
46
+ interfaces = get_available_interfaces(port, protocol)
47
+ for addr in interfaces:
48
+ if "127.0.0.1" not in str(addr):
49
+ return addr
50
+ # Fallback to loopback if no other interfaces found
51
+ return Multiaddr(f"/ip4/127.0.0.1/{protocol}/{port}")
52
+
53
+ def get_wildcard_address(port: int, protocol: str = "tcp"):
54
+ return Multiaddr(f"/ip4/0.0.0.0/{protocol}/{port}")
55
+
56
+
57
+ def main() -> None:
58
+ port = 8080
59
+ interfaces = get_available_interfaces(port)
60
+ print(f"Discovered interfaces for port {port}:")
61
+ for a in interfaces:
62
+ print(f" - {a}")
63
+
64
+ # Demonstrate wildcard address as a feature
65
+ wildcard_v4 = get_wildcard_address(port)
66
+ print(f"\nWildcard address (feature): {wildcard_v4}")
67
+
68
+ expanded_v4 = expand_wildcard_address(wildcard_v4)
69
+ print("\nExpanded IPv4 wildcard:")
70
+ for a in expanded_v4:
71
+ print(f" - {a}")
72
+
73
+ wildcard_v6 = Multiaddr(f"/ip6/::/tcp/{port}")
74
+ expanded_v6 = expand_wildcard_address(wildcard_v6)
75
+ print("\nExpanded IPv6 wildcard:")
76
+ for a in expanded_v6:
77
+ print(f" - {a}")
78
+
79
+ print("\nOptimal binding address heuristic result:")
80
+ print(f" -> {get_optimal_binding_address(port)}")
81
+
82
+ override_port = 9000
83
+ overridden = expand_wildcard_address(wildcard_v4, port=override_port)
84
+ print(f"\nPort override expansion to {override_port}:")
85
+ for a in overridden:
86
+ print(f" - {a}")
87
+
88
+
89
+ if __name__ == "__main__":
90
+ main()
@@ -0,0 +1,158 @@
1
+ import argparse
2
+ import logging
3
+ import secrets
4
+
5
+ import trio
6
+
7
+ from libp2p import new_host
8
+ from libp2p.abc import PeerInfo
9
+ from libp2p.crypto.secp256k1 import create_new_key_pair
10
+ from libp2p.discovery.events.peerDiscovery import peerDiscovery
11
+
12
+ # Configure logging
13
+ logger = logging.getLogger("libp2p.discovery.bootstrap")
14
+ logger.setLevel(logging.INFO)
15
+ handler = logging.StreamHandler()
16
+ handler.setFormatter(
17
+ logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
18
+ )
19
+ logger.addHandler(handler)
20
+
21
+ # Configure root logger to only show warnings and above to reduce noise
22
+ # This prevents verbose DEBUG messages from multiaddr, DNS, etc.
23
+ logging.getLogger().setLevel(logging.WARNING)
24
+
25
+ # Specifically silence noisy libraries
26
+ logging.getLogger("multiaddr").setLevel(logging.WARNING)
27
+ logging.getLogger("root").setLevel(logging.WARNING)
28
+
29
+
30
+ def on_peer_discovery(peer_info: PeerInfo) -> None:
31
+ """Handler for peer discovery events."""
32
+ logger.info(f"🔍 Discovered peer: {peer_info.peer_id}")
33
+ logger.debug(f" Addresses: {[str(addr) for addr in peer_info.addrs]}")
34
+
35
+
36
+ # Example bootstrap peers
37
+ BOOTSTRAP_PEERS = [
38
+ "/dnsaddr/github.com/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
39
+ "/dnsaddr/cloudflare.com/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
40
+ "/dnsaddr/google.com/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
41
+ "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
42
+ "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
43
+ "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
44
+ "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
45
+ "/ip4/128.199.219.111/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
46
+ "/ip4/104.236.76.40/tcp/4001/p2p/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
47
+ "/ip4/178.62.158.247/tcp/4001/p2p/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
48
+ "/ip6/2604:a880:1:20::203:d001/tcp/4001/p2p/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
49
+ "/ip6/2400:6180:0:d0::151:6001/tcp/4001/p2p/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
50
+ "/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/p2p/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
51
+ ]
52
+
53
+
54
+ async def run(port: int, bootstrap_addrs: list[str]) -> None:
55
+ """Run the bootstrap discovery example."""
56
+ from libp2p.utils.address_validation import (
57
+ find_free_port,
58
+ get_available_interfaces,
59
+ get_optimal_binding_address,
60
+ )
61
+
62
+ if port <= 0:
63
+ port = find_free_port()
64
+
65
+ # Generate key pair
66
+ secret = secrets.token_bytes(32)
67
+ key_pair = create_new_key_pair(secret)
68
+
69
+ # Create listen addresses for all available interfaces
70
+ listen_addrs = get_available_interfaces(port)
71
+
72
+ # Register peer discovery handler
73
+ peerDiscovery.register_peer_discovered_handler(on_peer_discovery)
74
+
75
+ logger.info("🚀 Starting Bootstrap Discovery Example")
76
+ logger.info(f"🌐 Bootstrap peers: {len(bootstrap_addrs)}")
77
+
78
+ print("\n" + "=" * 60)
79
+ print("Bootstrap Discovery Example")
80
+ print("=" * 60)
81
+ print("This example demonstrates connecting to bootstrap peers.")
82
+ print("Watch the logs for peer discovery events!")
83
+ print("Press Ctrl+C to exit.")
84
+ print("=" * 60)
85
+
86
+ # Create and run host with bootstrap discovery
87
+ host = new_host(key_pair=key_pair, bootstrap=bootstrap_addrs)
88
+
89
+ try:
90
+ async with host.run(listen_addrs=listen_addrs):
91
+ # Get all available addresses with peer ID
92
+ all_addrs = host.get_addrs()
93
+
94
+ logger.info("Listener ready, listening on:")
95
+ print("Listener ready, listening on:")
96
+ for addr in all_addrs:
97
+ logger.info(f"{addr}")
98
+ print(f"{addr}")
99
+
100
+ # Display optimal address for reference
101
+ optimal_addr = get_optimal_binding_address(port)
102
+ optimal_addr_with_peer = f"{optimal_addr}/p2p/{host.get_id().to_string()}"
103
+ logger.info(f"Optimal address: {optimal_addr_with_peer}")
104
+ print(f"Optimal address: {optimal_addr_with_peer}")
105
+
106
+ # Keep running and log peer discovery events
107
+ await trio.sleep_forever()
108
+ except KeyboardInterrupt:
109
+ logger.info("👋 Shutting down...")
110
+
111
+
112
+ def main() -> None:
113
+ """Main entry point."""
114
+ description = """
115
+ Bootstrap Discovery Example for py-libp2p
116
+
117
+ This example demonstrates how to use bootstrap peers for peer discovery.
118
+ Bootstrap peers are predefined peers that help new nodes join the network.
119
+
120
+ Usage:
121
+ python bootstrap.py -p 8000
122
+ python bootstrap.py -p 8001 --custom-bootstrap \\
123
+ "/ip4/[HOST_IP]/tcp/8000/p2p/QmYourPeerID"
124
+ """
125
+
126
+ parser = argparse.ArgumentParser(
127
+ description=description, formatter_class=argparse.RawDescriptionHelpFormatter
128
+ )
129
+ parser.add_argument(
130
+ "-p", "--port", default=0, type=int, help="Port to listen on (default: random)"
131
+ )
132
+ parser.add_argument(
133
+ "--custom-bootstrap",
134
+ nargs="*",
135
+ help="Custom bootstrap addresses (space-separated)",
136
+ )
137
+ parser.add_argument(
138
+ "-v", "--verbose", action="store_true", help="Enable verbose output"
139
+ )
140
+
141
+ args = parser.parse_args()
142
+
143
+ if args.verbose:
144
+ logger.setLevel(logging.DEBUG)
145
+
146
+ # Use custom bootstrap addresses if provided, otherwise use defaults
147
+ bootstrap_addrs = (
148
+ args.custom_bootstrap if args.custom_bootstrap else BOOTSTRAP_PEERS
149
+ )
150
+
151
+ try:
152
+ trio.run(run, args.port, bootstrap_addrs)
153
+ except KeyboardInterrupt:
154
+ logger.info("Exiting...")
155
+
156
+
157
+ if __name__ == "__main__":
158
+ main()
@@ -1,4 +1,5 @@
1
1
  import argparse
2
+ import logging
2
3
  import sys
3
4
 
4
5
  import multiaddr
@@ -17,6 +18,11 @@ from libp2p.peer.peerinfo import (
17
18
  info_from_p2p_addr,
18
19
  )
19
20
 
21
+ # Configure minimal logging
22
+ logging.basicConfig(level=logging.WARNING)
23
+ logging.getLogger("multiaddr").setLevel(logging.WARNING)
24
+ logging.getLogger("libp2p").setLevel(logging.WARNING)
25
+
20
26
  PROTOCOL_ID = TProtocol("/chat/1.0.0")
21
27
  MAX_READ_LEN = 2**32 - 1
22
28
 
@@ -40,9 +46,21 @@ async def write_data(stream: INetStream) -> None:
40
46
 
41
47
 
42
48
  async def run(port: int, destination: str) -> None:
43
- listen_addr = multiaddr.Multiaddr(f"/ip4/0.0.0.0/tcp/{port}")
49
+ from libp2p.utils.address_validation import (
50
+ find_free_port,
51
+ get_available_interfaces,
52
+ get_optimal_binding_address,
53
+ )
54
+
55
+ if port <= 0:
56
+ port = find_free_port()
57
+
58
+ listen_addrs = get_available_interfaces(port)
44
59
  host = new_host()
45
- async with host.run(listen_addrs=[listen_addr]), trio.open_nursery() as nursery:
60
+ async with host.run(listen_addrs=listen_addrs), trio.open_nursery() as nursery:
61
+ # Start the peer-store cleanup task
62
+ nursery.start_soon(host.get_peerstore().start_cleanup_task, 60)
63
+
46
64
  if not destination: # its the server
47
65
 
48
66
  async def stream_handler(stream: INetStream) -> None:
@@ -51,10 +69,19 @@ async def run(port: int, destination: str) -> None:
51
69
 
52
70
  host.set_stream_handler(PROTOCOL_ID, stream_handler)
53
71
 
72
+ # Get all available addresses with peer ID
73
+ all_addrs = host.get_addrs()
74
+
75
+ print("Listener ready, listening on:\n")
76
+ for addr in all_addrs:
77
+ print(f"{addr}")
78
+
79
+ # Use optimal address for the client command
80
+ optimal_addr = get_optimal_binding_address(port)
81
+ optimal_addr_with_peer = f"{optimal_addr}/p2p/{host.get_id().to_string()}"
54
82
  print(
55
- "Run this from the same folder in another console:\n\n"
56
- f"chat-demo "
57
- f"-d {host.get_addrs()[0]}\n"
83
+ f"\nRun this from the same folder in another console:\n\n"
84
+ f"chat-demo -d {optimal_addr_with_peer}\n"
58
85
  )
59
86
  print("Waiting for incoming connection...")
60
87
 
@@ -83,7 +110,7 @@ def main() -> None:
83
110
  where <DESTINATION> is the multiaddress of the previous listener host.
84
111
  """
85
112
  example_maddr = (
86
- "/ip4/127.0.0.1/tcp/8000/p2p/QmQn4SwGkDZKkUEpBRBvTmheQycxAHJUNmVEnjA2v1qe8Q"
113
+ "/ip4/[HOST_IP]/tcp/8000/p2p/QmQn4SwGkDZKkUEpBRBvTmheQycxAHJUNmVEnjA2v1qe8Q"
87
114
  )
88
115
  parser = argparse.ArgumentParser(description=description)
89
116
  parser.add_argument("-p", "--port", default=0, type=int, help="source port number")
@@ -1,6 +1,5 @@
1
1
  import secrets
2
2
 
3
- import multiaddr
4
3
  import trio
5
4
 
6
5
  from libp2p import (
@@ -9,9 +8,10 @@ from libp2p import (
9
8
  from libp2p.crypto.secp256k1 import (
10
9
  create_new_key_pair,
11
10
  )
12
- from libp2p.security.insecure.transport import (
13
- PLAINTEXT_PROTOCOL_ID,
14
- InsecureTransport,
11
+ from libp2p.security.insecure.transport import PLAINTEXT_PROTOCOL_ID, InsecureTransport
12
+ from libp2p.utils.address_validation import (
13
+ get_available_interfaces,
14
+ get_optimal_binding_address,
15
15
  )
16
16
 
17
17
 
@@ -24,6 +24,12 @@ async def main():
24
24
  insecure_transport = InsecureTransport(
25
25
  # local_key_pair: The key pair used for libp2p identity
26
26
  local_key_pair=key_pair,
27
+ # secure_bytes_provider: Optional function to generate secure random bytes
28
+ # (defaults to secrets.token_bytes)
29
+ secure_bytes_provider=None, # Use default implementation
30
+ # peerstore: Optional peerstore to store peer IDs and public keys
31
+ # (defaults to None)
32
+ peerstore=None,
27
33
  )
28
34
 
29
35
  # Create a security options dictionary mapping protocol ID to transport
@@ -32,17 +38,19 @@ async def main():
32
38
  # Create a host with the key pair and insecure transport
33
39
  host = new_host(key_pair=key_pair, sec_opt=security_options)
34
40
 
35
- # Configure the listening address
41
+ # Configure the listening address using the new paradigm
36
42
  port = 8000
37
- listen_addr = multiaddr.Multiaddr(f"/ip4/0.0.0.0/tcp/{port}")
43
+ listen_addrs = get_available_interfaces(port)
44
+ optimal_addr = get_optimal_binding_address(port)
38
45
 
39
46
  # Start the host
40
- async with host.run(listen_addrs=[listen_addr]):
47
+ async with host.run(listen_addrs=listen_addrs):
41
48
  print(
42
49
  "libp2p has started with insecure transport "
43
50
  "(not recommended for production)"
44
51
  )
45
52
  print("libp2p is listening on:", host.get_addrs())
53
+ print(f"Optimal address: {optimal_addr}")
46
54
  # Keep the host running
47
55
  await trio.sleep_forever()
48
56