libp2p 0.2.5__tar.gz → 0.2.7__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 (255) hide show
  1. {libp2p-0.2.5/libp2p.egg-info → libp2p-0.2.7}/PKG-INFO +3 -2
  2. libp2p-0.2.7/examples/identify_push/identify_push_demo.py +163 -0
  3. libp2p-0.2.7/examples/identify_push/identify_push_listener_dialer.py +290 -0
  4. libp2p-0.2.7/libp2p/__init__.py +257 -0
  5. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/keys.py +23 -14
  6. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/pb/crypto_pb2.py +12 -23
  7. libp2p-0.2.7/libp2p/crypto/x25519.py +69 -0
  8. libp2p-0.2.7/libp2p/exceptions.py +53 -0
  9. libp2p-0.2.7/libp2p/host/autonat/__init__.py +8 -0
  10. libp2p-0.2.7/libp2p/host/autonat/autonat.py +226 -0
  11. libp2p-0.2.7/libp2p/host/autonat/pb/autonat_pb2.py +37 -0
  12. libp2p-0.2.7/libp2p/host/autonat/pb/autonat_pb2.pyi +149 -0
  13. libp2p-0.2.7/libp2p/host/autonat/pb/autonat_pb2_grpc.py +109 -0
  14. libp2p-0.2.7/libp2p/host/autonat/pb/autonat_pb2_grpc.pyi +26 -0
  15. libp2p-0.2.7/libp2p/host/autonat/pb/generate_proto.py +36 -0
  16. libp2p-0.2.7/libp2p/identity/__init__.py +9 -0
  17. libp2p-0.2.7/libp2p/identity/identify/__init__.py +9 -0
  18. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/identity/identify/pb/identify_pb2.py +8 -19
  19. libp2p-0.2.7/libp2p/identity/identify_push/__init__.py +13 -0
  20. libp2p-0.2.7/libp2p/identity/identify_push/identify_push.py +194 -0
  21. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/connection/swarm_connection.py +42 -2
  22. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/stream/net_stream.py +2 -1
  23. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/swarm.py +29 -1
  24. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/peer/peerstore.py +3 -0
  25. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/gossipsub.py +58 -0
  26. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/pb/rpc_pb2.py +32 -43
  27. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/pubsub.py +41 -36
  28. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/insecure/pb/plaintext_pb2.py +8 -19
  29. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/io.py +9 -0
  30. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/pb/noise_pb2.py +8 -19
  31. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/pb/spipe_pb2.py +10 -21
  32. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/muxer_multistream.py +21 -2
  33. libp2p-0.2.7/libp2p/stream_muxer/yamux/__init__.py +5 -0
  34. libp2p-0.2.7/libp2p/stream_muxer/yamux/yamux.py +676 -0
  35. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/constants.py +9 -0
  36. libp2p-0.2.7/libp2p/tools/timed_cache/first_seen_cache.py +32 -0
  37. libp2p-0.2.7/libp2p/tools/utils.py +154 -0
  38. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/transport/tcp/tcp.py +8 -2
  39. libp2p-0.2.7/libp2p/utils/__init__.py +23 -0
  40. libp2p-0.2.7/libp2p/utils/logging.py +217 -0
  41. libp2p-0.2.5/libp2p/utils.py → libp2p-0.2.7/libp2p/utils/varint.py +2 -23
  42. libp2p-0.2.7/libp2p/utils/version.py +22 -0
  43. {libp2p-0.2.5 → libp2p-0.2.7/libp2p.egg-info}/PKG-INFO +3 -2
  44. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/SOURCES.txt +33 -12
  45. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/entry_points.txt +2 -0
  46. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/requires.txt +2 -1
  47. {libp2p-0.2.5 → libp2p-0.2.7}/pyproject.toml +3 -3
  48. {libp2p-0.2.5 → libp2p-0.2.7}/setup.py +5 -2
  49. libp2p-0.2.7/tests/conftest.py +6 -0
  50. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/examples/test_examples.py +61 -2
  51. libp2p-0.2.7/tests/core/host/test_autonat.py +240 -0
  52. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/host/test_connected_peers.py +2 -0
  53. libp2p-0.2.7/tests/core/identity/identify_push/test_identify_push.py +415 -0
  54. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/network/test_net_stream.py +2 -2
  55. libp2p-0.2.7/tests/core/network/test_notify.py +208 -0
  56. libp2p-0.2.7/tests/core/pubsub/test_gossipsub_direct_peers.py +170 -0
  57. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_pubsub.py +8 -0
  58. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/security/test_security_multistream.py +23 -2
  59. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/stream_muxer/conftest.py +20 -0
  60. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/stream_muxer/test_mplex_conn.py +3 -3
  61. libp2p-0.2.7/tests/core/stream_muxer/test_multiplexer_selection.py +256 -0
  62. libp2p-0.2.7/tests/core/stream_muxer/test_yamux.py +448 -0
  63. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/tools/timed_cache/test_timed_cache.py +1 -1
  64. libp2p-0.2.7/tests/crypto/test_x25519.py +102 -0
  65. libp2p-0.2.7/tests/exceptions/test_exceptions.py +13 -0
  66. libp2p-0.2.7/tests/interop/go_libp2p/test_go_basic.py +5 -0
  67. libp2p-0.2.7/tests/interop/js_libp2p/test_js_basic.py +5 -0
  68. libp2p-0.2.7/tests/interop/rust_libp2p/test_rust_basic.py +5 -0
  69. libp2p-0.2.7/tests/interop/zig_libp2p/test_zig_basic.py +5 -0
  70. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/factories.py +62 -2
  71. libp2p-0.2.7/tests/utils/pubsub/__init__.py +0 -0
  72. libp2p-0.2.7/tests/utils/test_logging.py +257 -0
  73. libp2p-0.2.5/libp2p/__init__.py +0 -131
  74. libp2p-0.2.5/libp2p/exceptions.py +0 -16
  75. libp2p-0.2.5/libp2p/tools/timed_cache/first_seen_cache.py +0 -20
  76. libp2p-0.2.5/libp2p/tools/utils.py +0 -63
  77. libp2p-0.2.5/tests/conftest.py +0 -23
  78. libp2p-0.2.5/tests/core/network/test_notify.py +0 -126
  79. libp2p-0.2.5/tests/interop/conftest.py +0 -161
  80. libp2p-0.2.5/tests/interop/go_pkgs/examples/README.md +0 -1
  81. libp2p-0.2.5/tests/interop/go_pkgs/examples/echo/main.go +0 -137
  82. libp2p-0.2.5/tests/interop/go_pkgs/examples/go.mod +0 -12
  83. libp2p-0.2.5/tests/interop/go_pkgs/examples/go.sum +0 -1244
  84. libp2p-0.2.5/tests/interop/go_pkgs/examples/utils/host.go +0 -82
  85. libp2p-0.2.5/tests/interop/go_pkgs/install_interop_go_pkgs.sh +0 -32
  86. libp2p-0.2.5/tests/interop/test_bindings.py +0 -32
  87. libp2p-0.2.5/tests/interop/test_echo.py +0 -116
  88. libp2p-0.2.5/tests/interop/test_net_stream.py +0 -81
  89. libp2p-0.2.5/tests/interop/test_pubsub.py +0 -185
  90. {libp2p-0.2.5 → libp2p-0.2.7}/LICENSE-APACHE +0 -0
  91. {libp2p-0.2.5 → libp2p-0.2.7}/LICENSE-MIT +0 -0
  92. {libp2p-0.2.5 → libp2p-0.2.7}/MANIFEST.in +0 -0
  93. {libp2p-0.2.5 → libp2p-0.2.7}/README.md +0 -0
  94. {libp2p-0.2.5 → libp2p-0.2.7}/examples/__init__.py +0 -0
  95. {libp2p-0.2.5 → libp2p-0.2.7}/examples/chat/__init__.py +0 -0
  96. {libp2p-0.2.5 → libp2p-0.2.7}/examples/chat/chat.py +0 -0
  97. {libp2p-0.2.5 → libp2p-0.2.7}/examples/echo/__init__.py +0 -0
  98. {libp2p-0.2.5 → libp2p-0.2.7}/examples/echo/echo.py +0 -0
  99. {libp2p-0.2.5 → libp2p-0.2.7}/examples/identify/__init__.py +0 -0
  100. {libp2p-0.2.5 → libp2p-0.2.7}/examples/identify/identify.py +0 -0
  101. {libp2p-0.2.5/examples/ping → libp2p-0.2.7/examples/identify_push}/__init__.py +0 -0
  102. {libp2p-0.2.5/libp2p/crypto → libp2p-0.2.7/examples/ping}/__init__.py +0 -0
  103. {libp2p-0.2.5 → libp2p-0.2.7}/examples/ping/ping.py +0 -0
  104. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/abc.py +0 -0
  105. {libp2p-0.2.5/libp2p/crypto/pb → libp2p-0.2.7/libp2p/crypto}/__init__.py +0 -0
  106. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/authenticated_encryption.py +0 -0
  107. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/ecc.py +0 -0
  108. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/ed25519.py +0 -0
  109. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/exceptions.py +0 -0
  110. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/key_exchange.py +0 -0
  111. {libp2p-0.2.5/libp2p/host → libp2p-0.2.7/libp2p/crypto/pb}/__init__.py +0 -0
  112. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/pb/crypto_pb2.pyi +0 -0
  113. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/rsa.py +0 -0
  114. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/secp256k1.py +0 -0
  115. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/crypto/serialization.py +0 -0
  116. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/custom_types.py +0 -0
  117. {libp2p-0.2.5/libp2p/identity → libp2p-0.2.7/libp2p/host}/__init__.py +0 -0
  118. {libp2p-0.2.5/libp2p/identity/identify → libp2p-0.2.7/libp2p/host/autonat/pb}/__init__.py +0 -0
  119. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/host/basic_host.py +0 -0
  120. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/host/defaults.py +0 -0
  121. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/host/exceptions.py +0 -0
  122. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/host/ping.py +0 -0
  123. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/host/routed_host.py +0 -0
  124. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/identity/identify/identify.py +0 -0
  125. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/identity/identify/pb/__init__.py +0 -0
  126. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/identity/identify/pb/identify_pb2.pyi +0 -0
  127. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/__init__.py +0 -0
  128. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/abc.py +0 -0
  129. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/exceptions.py +0 -0
  130. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/msgio.py +0 -0
  131. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/trio.py +0 -0
  132. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/io/utils.py +0 -0
  133. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/__init__.py +0 -0
  134. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/connection/__init__.py +0 -0
  135. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/connection/exceptions.py +0 -0
  136. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/connection/raw_connection.py +0 -0
  137. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/exceptions.py +0 -0
  138. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/stream/__init__.py +0 -0
  139. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/network/stream/exceptions.py +0 -0
  140. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/peer/__init__.py +0 -0
  141. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/peer/id.py +0 -0
  142. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/peer/peerdata.py +0 -0
  143. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/peer/peerinfo.py +0 -0
  144. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/protocol_muxer/__init__.py +0 -0
  145. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/protocol_muxer/exceptions.py +0 -0
  146. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/protocol_muxer/multiselect.py +0 -0
  147. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/protocol_muxer/multiselect_client.py +0 -0
  148. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/protocol_muxer/multiselect_communicator.py +0 -0
  149. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/__init__.py +0 -0
  150. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/exceptions.py +0 -0
  151. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/floodsub.py +0 -0
  152. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/mcache.py +0 -0
  153. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/pb/__init__.py +0 -0
  154. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/pb/rpc_pb2.pyi +0 -0
  155. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/pubsub_notifee.py +0 -0
  156. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/subscription.py +0 -0
  157. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/pubsub/validators.py +0 -0
  158. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/py.typed +0 -0
  159. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/__init__.py +0 -0
  160. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/base_session.py +0 -0
  161. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/base_transport.py +0 -0
  162. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/exceptions.py +0 -0
  163. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/insecure/__init__.py +0 -0
  164. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/insecure/pb/__init__.py +0 -0
  165. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/insecure/pb/plaintext_pb2.pyi +0 -0
  166. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/insecure/transport.py +0 -0
  167. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/__init__.py +0 -0
  168. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/exceptions.py +0 -0
  169. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/messages.py +0 -0
  170. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/patterns.py +0 -0
  171. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/pb/__init__.py +0 -0
  172. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/pb/noise_pb2.pyi +0 -0
  173. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/noise/transport.py +0 -0
  174. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/__init__.py +0 -0
  175. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/exceptions.py +0 -0
  176. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/pb/__init__.py +0 -0
  177. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/pb/spipe_pb2.pyi +0 -0
  178. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secio/transport.py +0 -0
  179. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/secure_session.py +0 -0
  180. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/security/security_multistream.py +0 -0
  181. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/__init__.py +0 -0
  182. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/exceptions.py +0 -0
  183. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/__init__.py +0 -0
  184. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/constants.py +0 -0
  185. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/datastructures.py +0 -0
  186. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/exceptions.py +0 -0
  187. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/mplex.py +0 -0
  188. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/stream_muxer/mplex/mplex_stream.py +0 -0
  189. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/__init__.py +0 -0
  190. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/__init__.py +0 -0
  191. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/_utils.py +0 -0
  192. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/abc.py +0 -0
  193. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/base.py +0 -0
  194. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/exceptions.py +0 -0
  195. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/stats.py +0 -0
  196. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/trio_service.py +0 -0
  197. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/async_service/typing.py +0 -0
  198. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/timed_cache/__init__.py +0 -0
  199. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/timed_cache/base_timed_cache.py +0 -0
  200. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/tools/timed_cache/last_seen_cache.py +0 -0
  201. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/transport/__init__.py +0 -0
  202. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/transport/exceptions.py +0 -0
  203. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/transport/tcp/__init__.py +0 -0
  204. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p/transport/upgrader.py +0 -0
  205. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/dependency_links.txt +0 -0
  206. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/not-zip-safe +0 -0
  207. {libp2p-0.2.5 → libp2p-0.2.7}/libp2p.egg-info/top_level.txt +0 -0
  208. {libp2p-0.2.5 → libp2p-0.2.7}/scripts/release/test_package.py +0 -0
  209. {libp2p-0.2.5 → libp2p-0.2.7}/setup.cfg +0 -0
  210. {libp2p-0.2.5 → libp2p-0.2.7}/tests/__init__.py +0 -0
  211. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/crypto/test_ed25519.py +0 -0
  212. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/crypto/test_rsa.py +0 -0
  213. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/crypto/test_secp256k1.py +0 -0
  214. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/host/test_basic_host.py +0 -0
  215. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/host/test_live_peers.py +0 -0
  216. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/host/test_ping.py +0 -0
  217. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/host/test_routed_host.py +0 -0
  218. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/identity/identify/test_identify.py +0 -0
  219. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/network/conftest.py +0 -0
  220. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/network/test_swarm.py +0 -0
  221. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/network/test_swarm_conn.py +0 -0
  222. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_addrbook.py +0 -0
  223. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_interop.py +0 -0
  224. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_peerdata.py +0 -0
  225. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_peerid.py +0 -0
  226. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_peerinfo.py +0 -0
  227. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_peermetadata.py +0 -0
  228. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/peer/test_peerstore.py +0 -0
  229. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/protocol_muxer/test_protocol_muxer.py +0 -0
  230. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_dummyaccount_demo.py +0 -0
  231. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_floodsub.py +0 -0
  232. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_gossipsub.py +0 -0
  233. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_gossipsub_backward_compatibility.py +0 -0
  234. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_mcache.py +0 -0
  235. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/pubsub/test_subscription.py +0 -0
  236. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/security/noise/test_msg_read_writer.py +0 -0
  237. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/security/noise/test_noise.py +0 -0
  238. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/security/test_secio.py +0 -0
  239. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/stream_muxer/test_mplex_stream.py +0 -0
  240. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/test_import_and_version.py +0 -0
  241. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/test_libp2p/test_libp2p.py +0 -0
  242. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/tools/async_service/test_trio_based_service.py +0 -0
  243. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/tools/async_service/test_trio_external_api.py +0 -0
  244. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/tools/async_service/test_trio_manager_stats.py +0 -0
  245. {libp2p-0.2.5 → libp2p-0.2.7}/tests/core/transport/test_tcp.py +0 -0
  246. {libp2p-0.2.5/tests/utils/interop → libp2p-0.2.7/tests/utils}/__init__.py +0 -0
  247. {libp2p-0.2.5/tests/utils/pubsub → libp2p-0.2.7/tests/utils/interop}/__init__.py +0 -0
  248. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/interop/constants.py +0 -0
  249. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/interop/daemon.py +0 -0
  250. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/interop/envs.py +0 -0
  251. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/interop/process.py +0 -0
  252. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/interop/utils.py +0 -0
  253. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/pubsub/dummy_account_node.py +0 -0
  254. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/pubsub/floodsub_integration_test_settings.py +0 -0
  255. {libp2p-0.2.5 → libp2p-0.2.7}/tests/utils/pubsub/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libp2p
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: libp2p: The Python implementation of the libp2p networking stack
5
5
  Home-page: https://github.com/libp2p/py-libp2p
6
6
  Author: The Ethereum Foundation
@@ -27,11 +27,12 @@ License-File: LICENSE-APACHE
27
27
  Requires-Dist: base58>=1.0.3
28
28
  Requires-Dist: coincurve>=10.0.0
29
29
  Requires-Dist: exceptiongroup>=1.2.0; python_version < "3.11"
30
+ Requires-Dist: grpcio>=1.41.0
30
31
  Requires-Dist: lru-dict>=1.1.6
31
32
  Requires-Dist: multiaddr>=0.0.9
32
33
  Requires-Dist: mypy-protobuf>=3.0.0
33
34
  Requires-Dist: noiseprotocol>=0.3.0
34
- Requires-Dist: protobuf>=5.27.0
35
+ Requires-Dist: protobuf>=6.30.1
35
36
  Requires-Dist: pycryptodome>=3.9.2
36
37
  Requires-Dist: pymultihash>=0.8.2
37
38
  Requires-Dist: pynacl>=1.3.0
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Example demonstrating the identify/push protocol.
4
+
5
+ This example shows how to:
6
+ 1. Set up a host with the identify/push protocol handler
7
+ 2. Connect to another peer
8
+ 3. Push identify information to the peer
9
+ 4. Receive and process identify/push messages
10
+ """
11
+
12
+ import logging
13
+
14
+ import trio
15
+
16
+ from libp2p import (
17
+ new_host,
18
+ )
19
+ from libp2p.crypto.secp256k1 import (
20
+ create_new_key_pair,
21
+ )
22
+ from libp2p.custom_types import (
23
+ TProtocol,
24
+ )
25
+ from libp2p.identity.identify import (
26
+ identify_handler_for,
27
+ )
28
+ from libp2p.identity.identify_push import (
29
+ ID_PUSH,
30
+ identify_push_handler_for,
31
+ push_identify_to_peer,
32
+ )
33
+ from libp2p.peer.peerinfo import (
34
+ info_from_p2p_addr,
35
+ )
36
+
37
+ # Configure logging
38
+ logger = logging.getLogger(__name__)
39
+
40
+
41
+ async def main() -> None:
42
+ print("\n==== Starting Identify-Push Example ====\n")
43
+
44
+ # Create key pairs for the two hosts
45
+ key_pair_1 = create_new_key_pair()
46
+ key_pair_2 = create_new_key_pair()
47
+
48
+ # Create the first host
49
+ host_1 = new_host(key_pair=key_pair_1)
50
+
51
+ # Set up the identify and identify/push handlers
52
+ host_1.set_stream_handler(TProtocol("/ipfs/id/1.0.0"), identify_handler_for(host_1))
53
+ host_1.set_stream_handler(ID_PUSH, identify_push_handler_for(host_1))
54
+
55
+ # Create the second host
56
+ host_2 = new_host(key_pair=key_pair_2)
57
+
58
+ # Set up the identify and identify/push handlers
59
+ host_2.set_stream_handler(TProtocol("/ipfs/id/1.0.0"), identify_handler_for(host_2))
60
+ host_2.set_stream_handler(ID_PUSH, identify_push_handler_for(host_2))
61
+
62
+ # Start listening on random ports using the run context manager
63
+ import multiaddr
64
+
65
+ listen_addr_1 = multiaddr.Multiaddr("/ip4/127.0.0.1/tcp/0")
66
+ listen_addr_2 = multiaddr.Multiaddr("/ip4/127.0.0.1/tcp/0")
67
+
68
+ async with host_1.run([listen_addr_1]), host_2.run([listen_addr_2]):
69
+ # Get the addresses of both hosts
70
+ addr_1 = host_1.get_addrs()[0]
71
+ logger.info(f"Host 1 listening on {addr_1}")
72
+ print(f"Host 1 listening on {addr_1}")
73
+ print(f"Peer ID: {host_1.get_id().pretty()}")
74
+
75
+ addr_2 = host_2.get_addrs()[0]
76
+ logger.info(f"Host 2 listening on {addr_2}")
77
+ print(f"Host 2 listening on {addr_2}")
78
+ print(f"Peer ID: {host_2.get_id().pretty()}")
79
+
80
+ print("\nConnecting Host 2 to Host 1...")
81
+
82
+ # Connect host_2 to host_1
83
+ peer_info = info_from_p2p_addr(addr_1)
84
+ await host_2.connect(peer_info)
85
+ logger.info("Host 2 connected to Host 1")
86
+ print("Host 2 successfully connected to Host 1")
87
+
88
+ # Run the identify protocol from host_2 to host_1
89
+ # (so Host 1 learns Host 2's address)
90
+ from libp2p.identity.identify.identify import ID as IDENTIFY_PROTOCOL_ID
91
+
92
+ stream = await host_2.new_stream(host_1.get_id(), (IDENTIFY_PROTOCOL_ID,))
93
+ response = await stream.read()
94
+ await stream.close()
95
+
96
+ # Run the identify protocol from host_1 to host_2
97
+ # (so Host 2 learns Host 1's address)
98
+ stream = await host_1.new_stream(host_2.get_id(), (IDENTIFY_PROTOCOL_ID,))
99
+ response = await stream.read()
100
+ await stream.close()
101
+
102
+ # --- NEW CODE: Update Host 1's peerstore with Host 2's addresses ---
103
+ from libp2p.identity.identify.pb.identify_pb2 import (
104
+ Identify,
105
+ )
106
+
107
+ identify_msg = Identify()
108
+ identify_msg.ParseFromString(response)
109
+ peerstore_1 = host_1.get_peerstore()
110
+ peer_id_2 = host_2.get_id()
111
+ for addr_bytes in identify_msg.listen_addrs:
112
+ maddr = multiaddr.Multiaddr(addr_bytes)
113
+ # TTL can be any positive int
114
+ peerstore_1.add_addr(
115
+ peer_id_2,
116
+ maddr,
117
+ ttl=3600,
118
+ )
119
+ # --- END NEW CODE ---
120
+
121
+ # Now Host 1's peerstore should have Host 2's address
122
+ peerstore_1 = host_1.get_peerstore()
123
+ peer_id_2 = host_2.get_id()
124
+ addrs_1_for_2 = peerstore_1.addrs(peer_id_2)
125
+ logger.info(
126
+ f"[DEBUG] Host 1 peerstore addresses for Host 2 before push: "
127
+ f"{addrs_1_for_2}"
128
+ )
129
+ print(
130
+ f"[DEBUG] Host 1 peerstore addresses for Host 2 before push: "
131
+ f"{addrs_1_for_2}"
132
+ )
133
+
134
+ # Push identify information from host_1 to host_2
135
+ logger.info("Host 1 pushing identify information to Host 2")
136
+ print("\nHost 1 pushing identify information to Host 2...")
137
+
138
+ try:
139
+ # Call push_identify_to_peer which now returns a boolean
140
+ success = await push_identify_to_peer(host_1, host_2.get_id())
141
+
142
+ if success:
143
+ logger.info("Identify push completed successfully")
144
+ print("Identify push completed successfully!")
145
+ else:
146
+ logger.warning("Identify push didn't complete successfully")
147
+ print("\nWarning: Identify push didn't complete successfully")
148
+
149
+ except Exception as e:
150
+ logger.error(f"Error during identify push: {str(e)}")
151
+ print(f"\nError during identify push: {str(e)}")
152
+
153
+ # Add this at the end of your async with block:
154
+ await trio.sleep(0.5) # Give background tasks time to finish
155
+
156
+
157
+ if __name__ == "__main__":
158
+ trio.run(main)
159
+
160
+
161
+ def run_main():
162
+ """Non-async entry point for the console script."""
163
+ trio.run(main)
@@ -0,0 +1,290 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Example demonstrating the identify/push protocol with separate listener and dialer
4
+ roles.
5
+
6
+ This example shows how to:
7
+ 1. Set up a listener host with the identify/push protocol handler
8
+ 2. Connect to the listener from a dialer peer
9
+ 3. Push identify information to the listener
10
+ 4. Receive and process identify/push messages
11
+
12
+ Usage:
13
+ # First run this script as a listener (default port 8888):
14
+ python identify_push_listener_dialer.py
15
+
16
+ # Then in another console, run as a dialer (default port 8889):
17
+ python identify_push_listener_dialer.py -d /ip4/127.0.0.1/tcp/8888/p2p/PEER_ID
18
+ (where PEER_ID is the peer ID displayed by the listener)
19
+ """
20
+
21
+ import argparse
22
+ import logging
23
+ import sys
24
+
25
+ import multiaddr
26
+ from multiaddr import (
27
+ Multiaddr,
28
+ )
29
+ import trio
30
+
31
+ from libp2p import (
32
+ new_host,
33
+ )
34
+ from libp2p.abc import (
35
+ INetStream,
36
+ )
37
+ from libp2p.crypto.secp256k1 import (
38
+ create_new_key_pair,
39
+ )
40
+ from libp2p.identity.identify import (
41
+ identify_handler_for,
42
+ )
43
+ from libp2p.identity.identify import ID as ID_IDENTIFY
44
+ from libp2p.identity.identify.pb.identify_pb2 import (
45
+ Identify,
46
+ )
47
+ from libp2p.identity.identify_push import (
48
+ identify_push_handler_for,
49
+ push_identify_to_peer,
50
+ )
51
+ from libp2p.identity.identify_push import ID_PUSH as ID_IDENTIFY_PUSH
52
+ from libp2p.peer.peerinfo import (
53
+ info_from_p2p_addr,
54
+ )
55
+
56
+ # Configure logging
57
+ logger = logging.getLogger("libp2p.identity.identify-push-example")
58
+
59
+ # Default port configuration
60
+ DEFAULT_PORT = 8888
61
+
62
+
63
+ def custom_identify_push_handler_for(host):
64
+ """
65
+ Create a custom handler for the identify/push protocol that logs and prints
66
+ the identity information received from the dialer.
67
+ """
68
+
69
+ async def handle_identify_push(stream: INetStream) -> None:
70
+ peer_id = stream.muxed_conn.peer_id
71
+
72
+ try:
73
+ # Read the identify message from the stream
74
+ data = await stream.read()
75
+ identify_msg = Identify()
76
+ identify_msg.ParseFromString(data)
77
+
78
+ # Log and print the identify information
79
+ logger.info("Received identify/push from peer %s", peer_id)
80
+ print(f"\n==== Received identify/push from peer {peer_id} ====")
81
+
82
+ if identify_msg.HasField("protocol_version"):
83
+ logger.info(" Protocol Version: %s", identify_msg.protocol_version)
84
+ print(f" Protocol Version: {identify_msg.protocol_version}")
85
+
86
+ if identify_msg.HasField("agent_version"):
87
+ logger.info(" Agent Version: %s", identify_msg.agent_version)
88
+ print(f" Agent Version: {identify_msg.agent_version}")
89
+
90
+ if identify_msg.HasField("public_key"):
91
+ logger.info(
92
+ " Public Key: %s", identify_msg.public_key.hex()[:16] + "..."
93
+ )
94
+ print(f" Public Key: {identify_msg.public_key.hex()[:16]}...")
95
+
96
+ if identify_msg.listen_addrs:
97
+ addrs = [Multiaddr(addr) for addr in identify_msg.listen_addrs]
98
+ logger.info(" Listen Addresses: %s", addrs)
99
+ print(" Listen Addresses:")
100
+ for addr in addrs:
101
+ print(f" - {addr}")
102
+
103
+ if identify_msg.HasField("observed_addr") and identify_msg.observed_addr:
104
+ observed_addr = Multiaddr(identify_msg.observed_addr)
105
+ logger.info(" Observed Address: %s", observed_addr)
106
+ print(f" Observed Address: {observed_addr}")
107
+
108
+ if identify_msg.protocols:
109
+ logger.info(" Protocols: %s", identify_msg.protocols)
110
+ print(" Protocols:")
111
+ for protocol in identify_msg.protocols:
112
+ print(f" - {protocol}")
113
+
114
+ # Update the peerstore with the new information as usual
115
+ peerstore = host.get_peerstore()
116
+ from libp2p.identity.identify_push.identify_push import (
117
+ _update_peerstore_from_identify,
118
+ )
119
+
120
+ await _update_peerstore_from_identify(peerstore, peer_id, identify_msg)
121
+
122
+ logger.info("Successfully processed identify/push from peer %s", peer_id)
123
+ print(f"\nSuccessfully processed identify/push from peer {peer_id}")
124
+
125
+ except Exception as e:
126
+ logger.error("Error processing identify/push from %s: %s", peer_id, e)
127
+ print(f"\nError processing identify/push from {peer_id}: {e}")
128
+ finally:
129
+ # Close the stream after processing
130
+ await stream.close()
131
+
132
+ return handle_identify_push
133
+
134
+
135
+ async def run_listener(port: int) -> None:
136
+ """Run a host in listener mode."""
137
+ print(f"\n==== Starting Identify-Push Listener on port {port} ====\n")
138
+
139
+ # Create key pair for the listener
140
+ key_pair = create_new_key_pair()
141
+
142
+ # Create the listener host
143
+ host = new_host(key_pair=key_pair)
144
+
145
+ # Set up the identify and identify/push handlers
146
+ host.set_stream_handler(ID_IDENTIFY, identify_handler_for(host))
147
+ host.set_stream_handler(ID_IDENTIFY_PUSH, custom_identify_push_handler_for(host))
148
+
149
+ # Start listening
150
+ listen_addr = multiaddr.Multiaddr(f"/ip4/0.0.0.0/tcp/{port}")
151
+
152
+ async with host.run([listen_addr]):
153
+ addr = host.get_addrs()[0]
154
+ logger.info("Listener host ready!")
155
+ print("Listener host ready!")
156
+
157
+ logger.info(f"Listening on: {addr}")
158
+ print(f"Listening on: {addr}")
159
+
160
+ logger.info(f"Peer ID: {host.get_id().pretty()}")
161
+ print(f"Peer ID: {host.get_id().pretty()}")
162
+
163
+ print("\nRun dialer with command:")
164
+ print(f"identify-push-listener-dialer-demo -d {addr}")
165
+ print("\nWaiting for incoming connections... (Ctrl+C to exit)")
166
+
167
+ # Keep running until interrupted
168
+ await trio.sleep_forever()
169
+
170
+
171
+ async def run_dialer(port: int, destination: str) -> None:
172
+ """Run a host in dialer mode that connects to a listener."""
173
+ print(f"\n==== Starting Identify-Push Dialer on port {port} ====\n")
174
+
175
+ # Create key pair for the dialer
176
+ key_pair = create_new_key_pair()
177
+
178
+ # Create the dialer host
179
+ host = new_host(key_pair=key_pair)
180
+
181
+ # Set up the identify and identify/push handlers
182
+ host.set_stream_handler(ID_IDENTIFY, identify_handler_for(host))
183
+ host.set_stream_handler(ID_IDENTIFY_PUSH, identify_push_handler_for(host))
184
+
185
+ # Start listening on a different port
186
+ listen_addr = multiaddr.Multiaddr(f"/ip4/0.0.0.0/tcp/{port}")
187
+
188
+ async with host.run([listen_addr]):
189
+ logger.info("Dialer host ready!")
190
+ print("Dialer host ready!")
191
+
192
+ logger.info(f"Listening on: {host.get_addrs()[0]}")
193
+ print(f"Listening on: {host.get_addrs()[0]}")
194
+
195
+ # Parse the destination multiaddress and connect to the listener
196
+ maddr = multiaddr.Multiaddr(destination)
197
+ peer_info = info_from_p2p_addr(maddr)
198
+ logger.info(f"Connecting to peer: {peer_info.peer_id}")
199
+ print(f"\nConnecting to peer: {peer_info.peer_id}")
200
+
201
+ try:
202
+ await host.connect(peer_info)
203
+ logger.info("Successfully connected to listener!")
204
+ print("Successfully connected to listener!")
205
+
206
+ # Push identify information to the listener
207
+ logger.info("Pushing identify information to listener...")
208
+ print("\nPushing identify information to listener...")
209
+
210
+ try:
211
+ # Call push_identify_to_peer which returns a boolean
212
+ success = await push_identify_to_peer(host, peer_info.peer_id)
213
+
214
+ if success:
215
+ logger.info("Identify push completed successfully!")
216
+ print("Identify push completed successfully!")
217
+
218
+ logger.info("Example completed successfully!")
219
+ print("\nExample completed successfully!")
220
+ else:
221
+ logger.warning("Identify push didn't complete successfully.")
222
+ print("\nWarning: Identify push didn't complete successfully.")
223
+
224
+ logger.warning("Example completed with warnings.")
225
+ print("Example completed with warnings.")
226
+ except Exception as e:
227
+ logger.error(f"Error during identify push: {str(e)}")
228
+ print(f"\nError during identify push: {str(e)}")
229
+
230
+ logger.error("Example completed with errors.")
231
+ print("Example completed with errors.")
232
+ # Continue execution despite the push error
233
+
234
+ except Exception as e:
235
+ logger.error(f"Error during dialer operation: {str(e)}")
236
+ print(f"\nError during dialer operation: {str(e)}")
237
+ raise
238
+
239
+
240
+ def main() -> None:
241
+ """Parse arguments and start the appropriate mode."""
242
+ description = """
243
+ This program demonstrates the libp2p identify/push protocol.
244
+ Without arguments, it runs as a listener on port 8888.
245
+ With -d parameter, it runs as a dialer on port 8889.
246
+ """
247
+
248
+ example = (
249
+ f"/ip4/127.0.0.1/tcp/{DEFAULT_PORT}/p2p/"
250
+ "QmQn4SwGkDZkUEpBRBvTmheQycxAHJUNmVEnjA2v1qe8Q"
251
+ )
252
+
253
+ parser = argparse.ArgumentParser(description=description)
254
+ parser.add_argument(
255
+ "-p",
256
+ "--port",
257
+ type=int,
258
+ help=(
259
+ f"port to listen on (default: {DEFAULT_PORT} for listener, "
260
+ f"{DEFAULT_PORT + 1} for dialer)"
261
+ ),
262
+ )
263
+ parser.add_argument(
264
+ "-d",
265
+ "--destination",
266
+ type=str,
267
+ help=f"destination multiaddr string, e.g. {example}",
268
+ )
269
+ args = parser.parse_args()
270
+
271
+ try:
272
+ if args.destination:
273
+ # Run in dialer mode with default port DEFAULT_PORT + 1 if not specified
274
+ port = args.port if args.port is not None else DEFAULT_PORT + 1
275
+ trio.run(run_dialer, port, args.destination)
276
+ else:
277
+ # Run in listener mode with default port DEFAULT_PORT if not specified
278
+ port = args.port if args.port is not None else DEFAULT_PORT
279
+ trio.run(run_listener, port)
280
+ except KeyboardInterrupt:
281
+ print("\nInterrupted by user")
282
+ logger.info("Interrupted by user")
283
+ except Exception as e:
284
+ print(f"\nError: {str(e)}")
285
+ logger.error("Error: %s", str(e))
286
+ sys.exit(1)
287
+
288
+
289
+ if __name__ == "__main__":
290
+ main()