libp2p 0.2.2__tar.gz → 0.2.3__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 (244) hide show
  1. {libp2p-0.2.2/libp2p.egg-info → libp2p-0.2.3}/PKG-INFO +92 -93
  2. libp2p-0.2.3/README.md +143 -0
  3. {libp2p-0.2.2 → libp2p-0.2.3}/examples/chat/chat.py +1 -1
  4. {libp2p-0.2.2 → libp2p-0.2.3}/examples/echo/echo.py +1 -1
  5. libp2p-0.2.3/examples/identify/identify.py +132 -0
  6. {libp2p-0.2.2 → libp2p-0.2.3}/examples/ping/ping.py +1 -1
  7. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/__init__.py +8 -16
  8. libp2p-0.2.3/libp2p/abc.py +2062 -0
  9. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/pb/crypto_pb2.py +4 -4
  10. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/rsa.py +36 -0
  11. libp2p-0.2.3/libp2p/custom_types.py +49 -0
  12. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/host/basic_host.py +34 -13
  13. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/host/defaults.py +3 -3
  14. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/host/ping.py +4 -6
  15. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/host/routed_host.py +4 -6
  16. libp2p-0.2.3/libp2p/identity/identify/identify.py +114 -0
  17. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/identity/identify/pb/identify_pb2.py +4 -4
  18. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/io/abc.py +17 -1
  19. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/io/trio.py +11 -0
  20. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/connection/raw_connection.py +11 -3
  21. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/connection/swarm_connection.py +3 -5
  22. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/stream/net_stream.py +8 -6
  23. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/swarm.py +10 -24
  24. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/peer/peerdata.py +3 -4
  25. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/peer/peerstore.py +3 -3
  26. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/protocol_muxer/multiselect.py +4 -6
  27. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/protocol_muxer/multiselect_client.py +4 -6
  28. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/protocol_muxer/multiselect_communicator.py +3 -3
  29. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/floodsub.py +3 -3
  30. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/gossipsub.py +6 -5
  31. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/pb/rpc_pb2.py +4 -4
  32. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/pubsub.py +19 -31
  33. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/pubsub_notifee.py +2 -8
  34. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/subscription.py +5 -4
  35. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/base_session.py +3 -3
  36. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/base_transport.py +3 -3
  37. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/insecure/pb/plaintext_pb2.py +4 -4
  38. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/insecure/transport.py +20 -6
  39. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/io.py +3 -3
  40. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/patterns.py +4 -6
  41. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/pb/noise_pb2.py +4 -4
  42. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/transport.py +5 -9
  43. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/pb/spipe_pb2.py +4 -4
  44. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/transport.py +4 -6
  45. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secure_session.py +7 -0
  46. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/security_multistream.py +6 -12
  47. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/mplex.py +9 -7
  48. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/mplex_stream.py +6 -1
  49. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/muxer_multistream.py +7 -14
  50. libp2p-0.2.3/libp2p/tools/timed_cache/base_timed_cache.py +54 -0
  51. libp2p-0.2.3/libp2p/tools/timed_cache/first_seen_cache.py +20 -0
  52. libp2p-0.2.3/libp2p/tools/timed_cache/last_seen_cache.py +22 -0
  53. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/utils.py +2 -4
  54. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/transport/tcp/tcp.py +8 -12
  55. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/transport/upgrader.py +9 -18
  56. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/utils.py +22 -0
  57. {libp2p-0.2.2 → libp2p-0.2.3/libp2p.egg-info}/PKG-INFO +92 -93
  58. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/SOURCES.txt +19 -31
  59. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/entry_points.txt +1 -0
  60. {libp2p-0.2.2 → libp2p-0.2.3}/pyproject.toml +1 -1
  61. {libp2p-0.2.2 → libp2p-0.2.3}/setup.py +2 -1
  62. {libp2p-0.2.2 → libp2p-0.2.3}/tests/conftest.py +1 -1
  63. libp2p-0.2.3/tests/core/crypto/test_rsa.py +30 -0
  64. libp2p-0.2.3/tests/core/examples/test_examples.py +210 -0
  65. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/host/test_connected_peers.py +1 -1
  66. libp2p-0.2.3/tests/core/host/test_live_peers.py +182 -0
  67. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/host/test_ping.py +1 -1
  68. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/host/test_routed_host.py +1 -1
  69. libp2p-0.2.3/tests/core/identity/identify/test_identify.py +79 -0
  70. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/network/conftest.py +1 -1
  71. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/network/test_notify.py +4 -4
  72. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/network/test_swarm.py +3 -3
  73. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/protocol_muxer/test_protocol_muxer.py +3 -3
  74. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_dummyaccount_demo.py +3 -3
  75. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_floodsub.py +9 -14
  76. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_gossipsub.py +5 -5
  77. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_gossipsub_backward_compatibility.py +2 -2
  78. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_pubsub.py +10 -10
  79. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/security/noise/test_msg_read_writer.py +1 -1
  80. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/security/noise/test_noise.py +1 -1
  81. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/security/test_secio.py +1 -1
  82. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/security/test_security_multistream.py +1 -1
  83. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/stream_muxer/conftest.py +1 -1
  84. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/test_libp2p/test_libp2p.py +3 -3
  85. libp2p-0.2.3/tests/core/tools/timed_cache/test_timed_cache.py +131 -0
  86. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/conftest.py +1 -1
  87. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/test_bindings.py +1 -1
  88. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/test_echo.py +1 -1
  89. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/test_pubsub.py +3 -3
  90. {libp2p-0.2.2/libp2p/tools → libp2p-0.2.3/tests/utils}/factories.py +35 -38
  91. libp2p-0.2.3/tests/utils/interop/__init__.py +0 -0
  92. libp2p-0.2.3/tests/utils/pubsub/__init__.py +0 -0
  93. {libp2p-0.2.2/libp2p/tools → libp2p-0.2.3/tests/utils}/pubsub/dummy_account_node.py +2 -2
  94. {libp2p-0.2.2/libp2p/tools → libp2p-0.2.3/tests/utils}/pubsub/utils.py +1 -1
  95. libp2p-0.2.2/README.md +0 -145
  96. libp2p-0.2.2/libp2p/custom_types.py +0 -15
  97. libp2p-0.2.2/libp2p/host/host_interface.py +0 -133
  98. libp2p-0.2.2/libp2p/identity/identify/protocol.py +0 -68
  99. libp2p-0.2.2/libp2p/network/connection/net_connection_interface.py +0 -28
  100. libp2p-0.2.2/libp2p/network/connection/raw_connection_interface.py +0 -9
  101. libp2p-0.2.2/libp2p/network/network_interface.py +0 -100
  102. libp2p-0.2.2/libp2p/network/notifee_interface.py +0 -65
  103. libp2p-0.2.2/libp2p/network/stream/net_stream_interface.py +0 -33
  104. libp2p-0.2.2/libp2p/peer/addrbook_interface.py +0 -61
  105. libp2p-0.2.2/libp2p/peer/peerdata_interface.py +0 -100
  106. libp2p-0.2.2/libp2p/peer/peermetadata_interface.py +0 -31
  107. libp2p-0.2.2/libp2p/peer/peerstore_interface.py +0 -161
  108. libp2p-0.2.2/libp2p/protocol_muxer/multiselect_client_interface.py +0 -58
  109. libp2p-0.2.2/libp2p/protocol_muxer/multiselect_communicator_interface.py +0 -24
  110. libp2p-0.2.2/libp2p/protocol_muxer/multiselect_muxer_interface.py +0 -47
  111. libp2p-0.2.2/libp2p/pubsub/abc.py +0 -158
  112. libp2p-0.2.2/libp2p/pubsub/typing.py +0 -21
  113. libp2p-0.2.2/libp2p/routing/interfaces.py +0 -42
  114. libp2p-0.2.2/libp2p/security/secure_conn_interface.py +0 -44
  115. libp2p-0.2.2/libp2p/security/secure_transport_interface.py +0 -42
  116. libp2p-0.2.2/libp2p/stream_muxer/abc.py +0 -85
  117. libp2p-0.2.2/libp2p/transport/listener_interface.py +0 -32
  118. libp2p-0.2.2/libp2p/transport/transport_interface.py +0 -41
  119. libp2p-0.2.2/libp2p/transport/typing.py +0 -25
  120. libp2p-0.2.2/tests/core/examples/test_examples.py +0 -112
  121. libp2p-0.2.2/tests/core/identity/identify/test_protocol.py +0 -27
  122. {libp2p-0.2.2 → libp2p-0.2.3}/LICENSE-APACHE +0 -0
  123. {libp2p-0.2.2 → libp2p-0.2.3}/LICENSE-MIT +0 -0
  124. {libp2p-0.2.2 → libp2p-0.2.3}/MANIFEST.in +0 -0
  125. {libp2p-0.2.2 → libp2p-0.2.3}/examples/__init__.py +0 -0
  126. {libp2p-0.2.2 → libp2p-0.2.3}/examples/chat/__init__.py +0 -0
  127. {libp2p-0.2.2 → libp2p-0.2.3}/examples/echo/__init__.py +0 -0
  128. {libp2p-0.2.2/examples/ping → libp2p-0.2.3/examples/identify}/__init__.py +0 -0
  129. {libp2p-0.2.2/libp2p/crypto → libp2p-0.2.3/examples/ping}/__init__.py +0 -0
  130. {libp2p-0.2.2/libp2p/crypto/pb → libp2p-0.2.3/libp2p/crypto}/__init__.py +0 -0
  131. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/authenticated_encryption.py +0 -0
  132. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/ecc.py +0 -0
  133. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/ed25519.py +0 -0
  134. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/exceptions.py +0 -0
  135. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/key_exchange.py +0 -0
  136. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/keys.py +0 -0
  137. {libp2p-0.2.2/libp2p/host → libp2p-0.2.3/libp2p/crypto/pb}/__init__.py +0 -0
  138. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/pb/crypto_pb2.pyi +0 -0
  139. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/secp256k1.py +0 -0
  140. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/crypto/serialization.py +0 -0
  141. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/exceptions.py +0 -0
  142. {libp2p-0.2.2/libp2p/identity → libp2p-0.2.3/libp2p/host}/__init__.py +0 -0
  143. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/host/exceptions.py +0 -0
  144. {libp2p-0.2.2/libp2p/identity/identify → libp2p-0.2.3/libp2p/identity}/__init__.py +0 -0
  145. {libp2p-0.2.2/libp2p/identity/identify/pb → libp2p-0.2.3/libp2p/identity/identify}/__init__.py +0 -0
  146. {libp2p-0.2.2/libp2p/io → libp2p-0.2.3/libp2p/identity/identify/pb}/__init__.py +0 -0
  147. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/identity/identify/pb/identify_pb2.pyi +0 -0
  148. {libp2p-0.2.2/libp2p/network → libp2p-0.2.3/libp2p/io}/__init__.py +0 -0
  149. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/io/exceptions.py +0 -0
  150. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/io/msgio.py +0 -0
  151. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/io/utils.py +0 -0
  152. {libp2p-0.2.2/libp2p/network/connection → libp2p-0.2.3/libp2p/network}/__init__.py +0 -0
  153. {libp2p-0.2.2/libp2p/network/stream → libp2p-0.2.3/libp2p/network/connection}/__init__.py +0 -0
  154. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/connection/exceptions.py +0 -0
  155. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/exceptions.py +0 -0
  156. {libp2p-0.2.2/libp2p/peer → libp2p-0.2.3/libp2p/network/stream}/__init__.py +0 -0
  157. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/network/stream/exceptions.py +0 -0
  158. {libp2p-0.2.2/libp2p/protocol_muxer → libp2p-0.2.3/libp2p/peer}/__init__.py +0 -0
  159. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/peer/id.py +0 -0
  160. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/peer/peerinfo.py +0 -0
  161. {libp2p-0.2.2/libp2p/pubsub → libp2p-0.2.3/libp2p/protocol_muxer}/__init__.py +0 -0
  162. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/protocol_muxer/exceptions.py +0 -0
  163. {libp2p-0.2.2/libp2p/pubsub/pb → libp2p-0.2.3/libp2p/pubsub}/__init__.py +0 -0
  164. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/exceptions.py +0 -0
  165. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/mcache.py +0 -0
  166. {libp2p-0.2.2/libp2p/routing → libp2p-0.2.3/libp2p/pubsub/pb}/__init__.py +0 -0
  167. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/pb/rpc_pb2.pyi +0 -0
  168. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/pubsub/validators.py +0 -0
  169. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/py.typed +0 -0
  170. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/__init__.py +0 -0
  171. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/exceptions.py +0 -0
  172. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/insecure/__init__.py +0 -0
  173. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/insecure/pb/__init__.py +0 -0
  174. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/insecure/pb/plaintext_pb2.pyi +0 -0
  175. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/__init__.py +0 -0
  176. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/exceptions.py +0 -0
  177. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/messages.py +0 -0
  178. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/pb/__init__.py +0 -0
  179. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/noise/pb/noise_pb2.pyi +0 -0
  180. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/__init__.py +0 -0
  181. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/exceptions.py +0 -0
  182. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/pb/__init__.py +0 -0
  183. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/security/secio/pb/spipe_pb2.pyi +0 -0
  184. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/__init__.py +0 -0
  185. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/exceptions.py +0 -0
  186. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/__init__.py +0 -0
  187. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/constants.py +0 -0
  188. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/datastructures.py +0 -0
  189. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/stream_muxer/mplex/exceptions.py +0 -0
  190. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/__init__.py +0 -0
  191. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/__init__.py +0 -0
  192. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/_utils.py +0 -0
  193. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/abc.py +0 -0
  194. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/base.py +0 -0
  195. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/exceptions.py +0 -0
  196. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/stats.py +0 -0
  197. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/trio_service.py +0 -0
  198. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/async_service/typing.py +0 -0
  199. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/tools/constants.py +0 -0
  200. {libp2p-0.2.2/libp2p/tools/pubsub → libp2p-0.2.3/libp2p/tools/timed_cache}/__init__.py +0 -0
  201. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/transport/__init__.py +0 -0
  202. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/transport/exceptions.py +0 -0
  203. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p/transport/tcp/__init__.py +0 -0
  204. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/dependency_links.txt +0 -0
  205. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/not-zip-safe +0 -0
  206. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/requires.txt +0 -0
  207. {libp2p-0.2.2 → libp2p-0.2.3}/libp2p.egg-info/top_level.txt +0 -0
  208. {libp2p-0.2.2 → libp2p-0.2.3}/scripts/release/test_package.py +0 -0
  209. {libp2p-0.2.2 → libp2p-0.2.3}/setup.cfg +0 -0
  210. {libp2p-0.2.2/tests/utils/interop → libp2p-0.2.3/tests}/__init__.py +0 -0
  211. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/crypto/test_ed25519.py +0 -0
  212. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/crypto/test_secp256k1.py +0 -0
  213. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/host/test_basic_host.py +0 -0
  214. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/network/test_net_stream.py +0 -0
  215. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/network/test_swarm_conn.py +0 -0
  216. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_addrbook.py +0 -0
  217. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_interop.py +0 -0
  218. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_peerdata.py +0 -0
  219. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_peerid.py +0 -0
  220. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_peerinfo.py +0 -0
  221. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_peermetadata.py +0 -0
  222. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/peer/test_peerstore.py +0 -0
  223. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_mcache.py +0 -0
  224. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/pubsub/test_subscription.py +0 -0
  225. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/stream_muxer/test_mplex_conn.py +0 -0
  226. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/stream_muxer/test_mplex_stream.py +0 -0
  227. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/test_import_and_version.py +0 -0
  228. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/tools/async_service/test_trio_based_service.py +0 -0
  229. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/tools/async_service/test_trio_external_api.py +0 -0
  230. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/tools/async_service/test_trio_manager_stats.py +0 -0
  231. {libp2p-0.2.2 → libp2p-0.2.3}/tests/core/transport/test_tcp.py +0 -0
  232. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/examples/README.md +0 -0
  233. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/examples/echo/main.go +0 -0
  234. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/examples/go.mod +0 -0
  235. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/examples/go.sum +0 -0
  236. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/examples/utils/host.go +0 -0
  237. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/go_pkgs/install_interop_go_pkgs.sh +0 -0
  238. {libp2p-0.2.2 → libp2p-0.2.3}/tests/interop/test_net_stream.py +0 -0
  239. {libp2p-0.2.2 → libp2p-0.2.3}/tests/utils/interop/constants.py +0 -0
  240. {libp2p-0.2.2 → libp2p-0.2.3}/tests/utils/interop/daemon.py +0 -0
  241. {libp2p-0.2.2 → libp2p-0.2.3}/tests/utils/interop/envs.py +0 -0
  242. {libp2p-0.2.2 → libp2p-0.2.3}/tests/utils/interop/process.py +0 -0
  243. {libp2p-0.2.2 → libp2p-0.2.3}/tests/utils/interop/utils.py +0 -0
  244. {libp2p-0.2.2/libp2p/tools → libp2p-0.2.3/tests/utils}/pubsub/floodsub_integration_test_settings.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: libp2p
3
- Version: 0.2.2
3
+ Version: 0.2.3
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
@@ -76,6 +76,7 @@ Dynamic: description-content-type
76
76
  Dynamic: home-page
77
77
  Dynamic: keywords
78
78
  Dynamic: license
79
+ Dynamic: license-file
79
80
  Dynamic: platform
80
81
  Dynamic: provides-extra
81
82
  Dynamic: requires-dist
@@ -105,102 +106,100 @@ Read more in the [documentation on ReadTheDocs](https://py-libp2p.readthedocs.io
105
106
 
106
107
  ## Maintainers
107
108
 
108
- Currently maintained by [@pacrob](https://github.com/pacrob) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
109
+ Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
109
110
 
110
111
  ## Feature Breakdown
111
112
 
112
113
  py-libp2p aims for conformity with [the standard libp2p modules](https://libp2p.io/implementations/). Below is a breakdown of the modules we have developed, are developing, and may develop in the future.
113
114
 
114
- > Legend: ✅: Done   🛠️: In Progress   🚫: Missing   ❌: Not planned
115
-
116
- | libp2p Node | Status |
117
- | ------------ | :-----------: |
118
- | **`libp2p`** | ✅ |
119
-
120
- | Core Protocols | Status |
121
- | -------------- | :-----------: |
122
- | **`Ping`** | ✅ |
123
- | **`Identify`** | ✅ |
124
-
125
- | Transport Protocols | Status |
126
- | ------------------- | :-----------: |
127
- | **`TCP`** | ✅|
128
- | **`QUIC`** | 🛠️ |
129
- | **`UDP`** | 🚫 |
130
- | **`WebSockets`** | ❌ |
131
- | **`UTP`** | ❌ |
132
- | **`WebRTC`** | ❌ |
133
- | **`SCTP`** | ❌ |
134
- | **`Tor`** | ❌ |
135
- | **`i2p`** | ❌ |
136
- | **`cjdns`** | ❌ |
137
- | **`Bluetooth LE`** | ❌ |
138
- | **`Audio TP`** | ❌ |
139
- | **`Zerotier`** | ❌ |
140
-
141
- | Stream Muxers | Status |
142
- | ---------------- | :-----------: |
143
- | **`multiplex`** | ✅ |
144
- | **`yamux`** | 🚫 |
145
- | **`benchmarks`** | ❌ |
146
- | **`muxado`** | ❌ |
147
- | **`spdystream`** | ❌ |
148
- | **`spdy`** | ❌ |
149
- | **`http2`** | ❌ |
150
- | **`QUIC`** | ❌ |
151
-
152
- | Protocol Muxers | Status |
153
- | ----------------- | :-----------: |
154
- | **`multiselect`** | ✅ |
155
-
156
- | Switch (Swarm) | Status |
157
- | ------------------ | :-----------: |
158
- | **`Switch`** | ✅ |
159
- | **`Dialer stack`** | ✅ |
160
-
161
- | Peer Discovery | Status |
115
+ > Legend: ✅: Done  🛠️: In Progress/Usable  🌱 Prototype/Unstable  ❌: Missing
116
+
117
+ ______________________________________________________________________
118
+
119
+ ### Transports
120
+
121
+ | **Transport** | **Status** | **Source** |
122
+ | -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
123
+ | **`libp2p-tcp`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
124
+ | **`libp2p-quic`** | 🌱 | |
125
+ | **`libp2p-websocket`** | ❌ | |
126
+ | **`libp2p-webrtc-browser-to-server`** | ❌ | |
127
+ | **`libp2p-webrtc-private-to-private`** | ❌ | |
128
+
129
+ ______________________________________________________________________
130
+
131
+ ### NAT Traversal
132
+
133
+ | **NAT Traversal** | **Status** |
134
+ | ----------------------------- | :--------: |
135
+ | **`libp2p-circuit-relay-v2`** | ❌ |
136
+ | **`libp2p-autonat`** | ❌ |
137
+ | **`libp2p-hole-punching`** | ❌ |
138
+
139
+ ______________________________________________________________________
140
+
141
+ ### Secure Communication
142
+
143
+ | **Secure Communication** | **Status** | **Source** |
144
+ | ------------------------ | :--------: | :---------------------------------------------------------------------------: |
145
+ | **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
146
+ | **`libp2p-tls`** | ❌ | |
147
+
148
+ ______________________________________________________________________
149
+
150
+ ### Discovery
151
+
152
+ | **Discovery** | **Status** |
162
153
  | -------------------- | :--------: |
163
- | **`bootstrap list`** | 🚫 |
164
- | **`Kademlia DHT`** | ❌ |
165
- | **`mDNS`** | ❌ |
166
- | **`PEX`** | ❌ |
167
- | **`DNS`** | ❌ |
168
-
169
- | Content Routing | Status |
170
- | ------------------ | :-----------: |
171
- | **`Kademlia DHT`** | ❌ |
172
- | **`floodsub`** | ✅ |
173
- | **`gossipsub`** | ✅ |
174
- | **`PHT`** | ❌ |
175
-
176
- | Peer Routing | Status |
177
- | ------------------ | :-----------: |
178
- | **`Kademlia DHT`** | ❌ |
179
- | **`floodsub`** | ✅|
180
- | **`gossipsub`** | ✅ |
181
- | **`PHT`** | ❌ |
182
-
183
- | NAT Traversal | Status |
184
- | ------------------------ | :--------: |
185
- | **`nat-pmp`** | ❌ |
186
- | **`upnp`** | ❌ |
187
- | **`ext addr discovery`** | ❌ |
188
- | **`STUN-like`** | ❌ |
189
- | **`line-switch relay`** | ❌ |
190
- | **`pkt-switch relay`** | ❌ |
191
-
192
- | Exchange | Status |
193
- | ---------------- | :--------: |
194
- | **`HTTP`** | ❌ |
195
- | **`Bitswap`** | ❌ |
196
- | **`Bittorrent`** | ❌ |
197
-
198
- | Consensus | Status |
199
- | -------------- | :--------: |
200
- | **`Paxos`** | ❌ |
201
- | **`Raft`** | ❌ |
202
- | **`PBTF`** | ❌ |
203
- | **`Nakamoto`** | ❌ |
154
+ | **`bootstrap`** | ❌ |
155
+ | **`random-walk`** | ❌ |
156
+ | **`mdns-discovery`** | ❌ |
157
+ | **`rendezvous`** | ❌ |
158
+
159
+ ______________________________________________________________________
160
+
161
+ ### Peer Routing
162
+
163
+ | **Peer Routing** | **Status** |
164
+ | -------------------- | :--------: |
165
+ | **`libp2p-kad-dht`** | ❌ |
166
+
167
+ ______________________________________________________________________
168
+
169
+ ### Publish/Subscribe
170
+
171
+ | **Publish/Subscribe** | **Status** | **Source** |
172
+ | ---------------------- | :--------: | :--------------------------------------------------------------------------------: |
173
+ | **`libp2p-floodsub`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/pubsub/floodsub.py) |
174
+ | **`libp2p-gossipsub`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/pubsub/gossipsub.py) |
175
+
176
+ ______________________________________________________________________
177
+
178
+ ### Stream Muxers
179
+
180
+ | **Stream Muxers** | **Status** | **Status** |
181
+ | ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
182
+ | **`libp2p-yamux`** | 🌱 | |
183
+ | **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
184
+
185
+ ______________________________________________________________________
186
+
187
+ ### Storage
188
+
189
+ | **Storage** | **Status** |
190
+ | ------------------- | :--------: |
191
+ | **`libp2p-record`** | ❌ |
192
+
193
+ ______________________________________________________________________
194
+
195
+ ### General Purpose Utilities & Datatypes
196
+
197
+ | **Utility/Datatype** | **Status** | **Source** |
198
+ | -------------------- | :--------: | :-------------------------------------------------------------------------: |
199
+ | **`libp2p-ping`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/host/ping.py) |
200
+ | **`libp2p-peer`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/peer) |
201
+
202
+ ______________________________________________________________________
204
203
 
205
204
  ## Explanation of Basic Two Node Communication
206
205
 
@@ -222,7 +221,7 @@ Several components of the libp2p stack take part when establishing a connection
222
221
 
223
222
  _(non-normative, useful for team notes, not a reference)_
224
223
 
225
- **Initiate the connection**: A host is simply a node in the libp2p network that is able to communicate with other nodes in the network. In order for X and Y to communicate with one another, one of the hosts must initiate the connection. Let's say that X is going to initiate the connection. X will first open a connection to Y. This connection is where all of the actual communication will take place.
224
+ **Initiate the connection**: A host is simply a node in the libp2p network that is able to communicate with other nodes in the network. In order for X and Y to communicate with one another, one of the hosts must initiate the connection. Let's say that X is going to initiate the connection. X will first open a connection to Y. This connection is where all of the actual communication will take place.
226
225
 
227
226
  **Communication over one connection with multiple protocols**: X and Y can communicate over the same connection using different protocols and the multiplexer will appropriately route messages for a given protocol to a particular handler function for that protocol, which allows for each host to handle different protocols with separate functions. Furthermore, we can use multiple streams for a given protocol that allow for the same protocol and same underlying connection to be used for communication about separate topics between nodes X and Y.
228
227
 
libp2p-0.2.3/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # py-libp2p
2
+
3
+ <h1 align="center">
4
+ <a href="https://libp2p.io/"><img width="250" src="https://github.com/libp2p/py-libp2p/blob/main/assets/py-libp2p-logo.png?raw=true" alt="py-libp2p hex logo" /></a>
5
+ </h1>
6
+
7
+ <h3 align="center">The Python implementation of the libp2p networking stack.</h3>
8
+
9
+ [![Join the chat at https://gitter.im/py-libp2p/Lobby](https://badges.gitter.im/py-libp2p/Lobby.png)](https://gitter.im/py-libp2p/Lobby)
10
+ [![Build Status](https://circleci.com/gh/libp2p/py-libp2p.svg?style=shield)](https://circleci.com/gh/libp2p/py-libp2p)
11
+ [![PyPI version](https://badge.fury.io/py/libp2p.svg)](https://badge.fury.io/py/libp2p)
12
+ [![Python versions](https://img.shields.io/pypi/pyversions/libp2p.svg)](https://pypi.python.org/pypi/libp2p)
13
+ [![Docs build](https://readthedocs.org/projects/py-libp2p/badge/?version=latest)](http://py-libp2p.readthedocs.io/en/latest/?badge=latest)
14
+ [![Freenode](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg)](https://webchat.freenode.net/?channels=%23libp2p)
15
+ [![Matrix](https://img.shields.io/badge/matrix-%23libp2p%3Apermaweb.io-blue.svg)](https://riot.permaweb.io/#/room/#libp2p:permaweb.io)
16
+ [![Discord](https://img.shields.io/discord/475789330380488707?color=blueviolet&label=discord)](https://discord.gg/66KBrm2)
17
+
18
+ > ⚠️ **Warning:** py-libp2p is an experimental and work-in-progress repo under development. We do not yet recommend using py-libp2p in production environments.
19
+
20
+ 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).
21
+
22
+ ## Maintainers
23
+
24
+ Currently maintained by [@pacrob](https://github.com/pacrob), [@seetadev](https://github.com/seetadev) and [@dhuseby](https://github.com/dhuseby), looking for assistance!
25
+
26
+ ## Feature Breakdown
27
+
28
+ py-libp2p aims for conformity with [the standard libp2p modules](https://libp2p.io/implementations/). Below is a breakdown of the modules we have developed, are developing, and may develop in the future.
29
+
30
+ > Legend: ✅: Done  🛠️: In Progress/Usable  🌱 Prototype/Unstable  ❌: Missing
31
+
32
+ ______________________________________________________________________
33
+
34
+ ### Transports
35
+
36
+ | **Transport** | **Status** | **Source** |
37
+ | -------------------------------------- | :--------: | :---------------------------------------------------------------------------------: |
38
+ | **`libp2p-tcp`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/transport/tcp/tcp.py) |
39
+ | **`libp2p-quic`** | 🌱 | |
40
+ | **`libp2p-websocket`** | ❌ | |
41
+ | **`libp2p-webrtc-browser-to-server`** | ❌ | |
42
+ | **`libp2p-webrtc-private-to-private`** | ❌ | |
43
+
44
+ ______________________________________________________________________
45
+
46
+ ### NAT Traversal
47
+
48
+ | **NAT Traversal** | **Status** |
49
+ | ----------------------------- | :--------: |
50
+ | **`libp2p-circuit-relay-v2`** | ❌ |
51
+ | **`libp2p-autonat`** | ❌ |
52
+ | **`libp2p-hole-punching`** | ❌ |
53
+
54
+ ______________________________________________________________________
55
+
56
+ ### Secure Communication
57
+
58
+ | **Secure Communication** | **Status** | **Source** |
59
+ | ------------------------ | :--------: | :---------------------------------------------------------------------------: |
60
+ | **`libp2p-noise`** | 🌱 | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/security/noise) |
61
+ | **`libp2p-tls`** | ❌ | |
62
+
63
+ ______________________________________________________________________
64
+
65
+ ### Discovery
66
+
67
+ | **Discovery** | **Status** |
68
+ | -------------------- | :--------: |
69
+ | **`bootstrap`** | ❌ |
70
+ | **`random-walk`** | ❌ |
71
+ | **`mdns-discovery`** | ❌ |
72
+ | **`rendezvous`** | ❌ |
73
+
74
+ ______________________________________________________________________
75
+
76
+ ### Peer Routing
77
+
78
+ | **Peer Routing** | **Status** |
79
+ | -------------------- | :--------: |
80
+ | **`libp2p-kad-dht`** | ❌ |
81
+
82
+ ______________________________________________________________________
83
+
84
+ ### Publish/Subscribe
85
+
86
+ | **Publish/Subscribe** | **Status** | **Source** |
87
+ | ---------------------- | :--------: | :--------------------------------------------------------------------------------: |
88
+ | **`libp2p-floodsub`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/pubsub/floodsub.py) |
89
+ | **`libp2p-gossipsub`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/pubsub/gossipsub.py) |
90
+
91
+ ______________________________________________________________________
92
+
93
+ ### Stream Muxers
94
+
95
+ | **Stream Muxers** | **Status** | **Status** |
96
+ | ------------------ | :--------: | :----------------------------------------------------------------------------------------: |
97
+ | **`libp2p-yamux`** | 🌱 | |
98
+ | **`libp2p-mplex`** | 🛠️ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/stream_muxer/mplex/mplex.py) |
99
+
100
+ ______________________________________________________________________
101
+
102
+ ### Storage
103
+
104
+ | **Storage** | **Status** |
105
+ | ------------------- | :--------: |
106
+ | **`libp2p-record`** | ❌ |
107
+
108
+ ______________________________________________________________________
109
+
110
+ ### General Purpose Utilities & Datatypes
111
+
112
+ | **Utility/Datatype** | **Status** | **Source** |
113
+ | -------------------- | :--------: | :-------------------------------------------------------------------------: |
114
+ | **`libp2p-ping`** | ✅ | [source](https://github.com/libp2p/py-libp2p/blob/main/libp2p/host/ping.py) |
115
+ | **`libp2p-peer`** | ✅ | [source](https://github.com/libp2p/py-libp2p/tree/main/libp2p/peer) |
116
+
117
+ ______________________________________________________________________
118
+
119
+ ## Explanation of Basic Two Node Communication
120
+
121
+ ### Core Concepts
122
+
123
+ _(non-normative, useful for team notes, not a reference)_
124
+
125
+ Several components of the libp2p stack take part when establishing a connection between two nodes:
126
+
127
+ 1. **Host**: a node in the libp2p network.
128
+ 1. **Connection**: the layer 3 connection between two nodes in a libp2p network.
129
+ 1. **Transport**: the component that creates a _Connection_, e.g. TCP, UDP, QUIC, etc.
130
+ 1. **Streams**: an abstraction on top of a _Connection_ representing parallel conversations about different matters, each of which is identified by a protocol ID. Multiple streams are layered on top of a _Connection_ via the _Multiplexer_.
131
+ 1. **Multiplexer**: a component that is responsible for wrapping messages sent on a stream with an envelope that identifies the stream they pertain to, normally via an ID. The multiplexer on the other unwraps the message and routes it internally based on the stream identification.
132
+ 1. **Secure channel**: optionally establishes a secure, encrypted, and authenticated channel over the _Connection_.
133
+ 1. **Upgrader**: a component that takes a raw layer 3 connection returned by the _Transport_, and performs the security and multiplexing negotiation to set up a secure, multiplexed channel on top of which _Streams_ can be opened.
134
+
135
+ ### Communication between two hosts X and Y
136
+
137
+ _(non-normative, useful for team notes, not a reference)_
138
+
139
+ **Initiate the connection**: A host is simply a node in the libp2p network that is able to communicate with other nodes in the network. In order for X and Y to communicate with one another, one of the hosts must initiate the connection. Let's say that X is going to initiate the connection. X will first open a connection to Y. This connection is where all of the actual communication will take place.
140
+
141
+ **Communication over one connection with multiple protocols**: X and Y can communicate over the same connection using different protocols and the multiplexer will appropriately route messages for a given protocol to a particular handler function for that protocol, which allows for each host to handle different protocols with separate functions. Furthermore, we can use multiple streams for a given protocol that allow for the same protocol and same underlying connection to be used for communication about separate topics between nodes X and Y.
142
+
143
+ **Why use multiple streams?**: The purpose of using the same connection for multiple streams to communicate over is to avoid the overhead of having multiple connections between X and Y. In order for X and Y to differentiate between messages on different streams and different protocols, a multiplexer is used to encode the messages when a message will be sent and decode a message when a message is received. The multiplexer encodes the message by adding a header to the beginning of any message to be sent that contains the stream id (along with some other info). Then, the message is sent across the raw connection and the receiving host will use its multiplexer to decode the message, i.e. determine which stream id the message should be routed to.
@@ -10,7 +10,7 @@ from libp2p import (
10
10
  from libp2p.custom_types import (
11
11
  TProtocol,
12
12
  )
13
- from libp2p.network.stream.net_stream_interface import (
13
+ from libp2p.network.stream.net_stream import (
14
14
  INetStream,
15
15
  )
16
16
  from libp2p.peer.peerinfo import (
@@ -12,7 +12,7 @@ from libp2p.crypto.secp256k1 import (
12
12
  from libp2p.custom_types import (
13
13
  TProtocol,
14
14
  )
15
- from libp2p.network.stream.net_stream_interface import (
15
+ from libp2p.network.stream.net_stream import (
16
16
  INetStream,
17
17
  )
18
18
  from libp2p.peer.peerinfo import (
@@ -0,0 +1,132 @@
1
+ import argparse
2
+ import base64
3
+ import logging
4
+
5
+ import multiaddr
6
+ import trio
7
+
8
+ from libp2p import (
9
+ new_host,
10
+ )
11
+ from libp2p.identity.identify.identify import ID as IDENTIFY_PROTOCOL_ID
12
+ from libp2p.identity.identify.pb.identify_pb2 import (
13
+ Identify,
14
+ )
15
+ from libp2p.peer.peerinfo import (
16
+ info_from_p2p_addr,
17
+ )
18
+
19
+ logger = logging.getLogger("libp2p.identity.identify-example")
20
+
21
+
22
+ def decode_multiaddrs(raw_addrs):
23
+ """Convert raw listen addresses into human-readable multiaddresses."""
24
+ decoded_addrs = []
25
+ for addr in raw_addrs:
26
+ try:
27
+ decoded_addrs.append(str(multiaddr.Multiaddr(addr)))
28
+ except Exception as e:
29
+ decoded_addrs.append(f"Invalid Multiaddr ({addr}): {e}")
30
+ return decoded_addrs
31
+
32
+
33
+ def print_identify_response(identify_response):
34
+ """Pretty-print Identify response."""
35
+ public_key_b64 = base64.b64encode(identify_response.public_key).decode("utf-8")
36
+ listen_addrs = decode_multiaddrs(identify_response.listen_addrs)
37
+ try:
38
+ observed_addr_decoded = decode_multiaddrs([identify_response.observed_addr])
39
+ except Exception:
40
+ observed_addr_decoded = identify_response.observed_addr
41
+ print(
42
+ f"Identify response:\n"
43
+ f" Public Key (Base64): {public_key_b64}\n"
44
+ f" Listen Addresses: {listen_addrs}\n"
45
+ f" Protocols: {list(identify_response.protocols)}\n"
46
+ f" Observed Address: "
47
+ f"{observed_addr_decoded if identify_response.observed_addr else 'None'}\n"
48
+ f" Protocol Version: {identify_response.protocol_version}\n"
49
+ f" Agent Version: {identify_response.agent_version}"
50
+ )
51
+
52
+
53
+ async def run(port: int, destination: str) -> None:
54
+ localhost_ip = "0.0.0.0"
55
+
56
+ if not destination:
57
+ # Create first host (listener)
58
+ listen_addr = multiaddr.Multiaddr(f"/ip4/{localhost_ip}/tcp/{port}")
59
+ host_a = new_host()
60
+
61
+ async with host_a.run(listen_addrs=[listen_addr]):
62
+ print(
63
+ "First host listening. Run this from another console:\n\n"
64
+ f"identify-demo -p {int(port) + 1} "
65
+ f"-d /ip4/{localhost_ip}/tcp/{port}/p2p/{host_a.get_id().pretty()}\n"
66
+ )
67
+ print("Waiting for incoming identify request...")
68
+ await trio.sleep_forever()
69
+
70
+ else:
71
+ # Create second host (dialer)
72
+ print(f"dialer (host_b) listening on /ip4/{localhost_ip}/tcp/{port}")
73
+ listen_addr = multiaddr.Multiaddr(f"/ip4/{localhost_ip}/tcp/{port}")
74
+ host_b = new_host()
75
+
76
+ async with host_b.run(listen_addrs=[listen_addr]):
77
+ # Connect to the first host
78
+ maddr = multiaddr.Multiaddr(destination)
79
+ info = info_from_p2p_addr(maddr)
80
+ print(f"Second host connecting to peer: {info.peer_id}")
81
+
82
+ await host_b.connect(info)
83
+ stream = await host_b.new_stream(info.peer_id, (IDENTIFY_PROTOCOL_ID,))
84
+
85
+ try:
86
+ print("Starting identify protocol...")
87
+ response = await stream.read()
88
+ await stream.close()
89
+ identify_msg = Identify()
90
+ identify_msg.ParseFromString(response)
91
+ print_identify_response(identify_msg)
92
+ except Exception as e:
93
+ print(f"Identify protocol error: {e}")
94
+
95
+ return
96
+
97
+
98
+ def main() -> None:
99
+ description = """
100
+ This program demonstrates the libp2p identify protocol.
101
+ First run identify-demo -p <PORT>' to start a listener.
102
+ Then run 'identify-demo <ANOTHER_PORT> -d <DESTINATION>'
103
+ where <DESTINATION> is the multiaddress shown by the listener.
104
+ """
105
+
106
+ example_maddr = (
107
+ "/ip4/127.0.0.1/tcp/8888/p2p/QmQn4SwGkDZkUEpBRBvTmheQycxAHJUNmVEnjA2v1qe8Q"
108
+ )
109
+
110
+ parser = argparse.ArgumentParser(description=description)
111
+ parser.add_argument(
112
+ "-p", "--port", default=8888, type=int, help="source port number"
113
+ )
114
+ parser.add_argument(
115
+ "-d",
116
+ "--destination",
117
+ type=str,
118
+ help=f"destination multiaddr string, e.g. {example_maddr}",
119
+ )
120
+ args = parser.parse_args()
121
+
122
+ if not args.port:
123
+ raise RuntimeError("failed to determine local port")
124
+
125
+ try:
126
+ trio.run(run, *(args.port, args.destination))
127
+ except KeyboardInterrupt:
128
+ pass
129
+
130
+
131
+ if __name__ == "__main__":
132
+ main()
@@ -9,7 +9,7 @@ from libp2p import (
9
9
  from libp2p.custom_types import (
10
10
  TProtocol,
11
11
  )
12
- from libp2p.network.stream.net_stream_interface import (
12
+ from libp2p.network.stream.net_stream import (
13
13
  INetStream,
14
14
  )
15
15
  from libp2p.peer.peerinfo import (
@@ -1,5 +1,11 @@
1
1
  from importlib.metadata import version as __version
2
2
 
3
+ from libp2p.abc import (
4
+ IHost,
5
+ INetworkService,
6
+ IPeerRouting,
7
+ IPeerStore,
8
+ )
3
9
  from libp2p.crypto.keys import (
4
10
  KeyPair,
5
11
  )
@@ -7,20 +13,16 @@ from libp2p.crypto.rsa import (
7
13
  create_new_key_pair,
8
14
  )
9
15
  from libp2p.custom_types import (
16
+ TMuxerOptions,
10
17
  TProtocol,
18
+ TSecurityOptions,
11
19
  )
12
20
  from libp2p.host.basic_host import (
13
21
  BasicHost,
14
22
  )
15
- from libp2p.host.host_interface import (
16
- IHost,
17
- )
18
23
  from libp2p.host.routed_host import (
19
24
  RoutedHost,
20
25
  )
21
- from libp2p.network.network_interface import (
22
- INetworkService,
23
- )
24
26
  from libp2p.network.swarm import (
25
27
  Swarm,
26
28
  )
@@ -30,12 +32,6 @@ from libp2p.peer.id import (
30
32
  from libp2p.peer.peerstore import (
31
33
  PeerStore,
32
34
  )
33
- from libp2p.peer.peerstore_interface import (
34
- IPeerStore,
35
- )
36
- from libp2p.routing.interfaces import (
37
- IPeerRouting,
38
- )
39
35
  from libp2p.security.insecure.transport import (
40
36
  PLAINTEXT_PROTOCOL_ID,
41
37
  InsecureTransport,
@@ -48,10 +44,6 @@ from libp2p.stream_muxer.mplex.mplex import (
48
44
  from libp2p.transport.tcp.tcp import (
49
45
  TCP,
50
46
  )
51
- from libp2p.transport.typing import (
52
- TMuxerOptions,
53
- TSecurityOptions,
54
- )
55
47
  from libp2p.transport.upgrader import (
56
48
  TransportUpgrader,
57
49
  )