libp2p 0.36.0 → 0.36.2-1473044

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 (415) hide show
  1. package/LICENSE +3 -21
  2. package/README.md +13 -10
  3. package/dist/src/address-manager/index.d.ts +33 -52
  4. package/dist/src/address-manager/index.d.ts.map +1 -1
  5. package/dist/src/address-manager/index.js +81 -0
  6. package/dist/src/address-manager/index.js.map +1 -0
  7. package/dist/src/circuit/auto-relay.d.ts +24 -85
  8. package/dist/src/circuit/auto-relay.d.ts.map +1 -1
  9. package/dist/src/circuit/auto-relay.js +215 -0
  10. package/dist/src/circuit/auto-relay.js.map +1 -0
  11. package/dist/src/circuit/circuit/hop.d.ts +26 -53
  12. package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
  13. package/dist/src/circuit/circuit/hop.js +138 -0
  14. package/dist/src/circuit/circuit/hop.js.map +1 -0
  15. package/dist/src/circuit/circuit/stop.d.ts +18 -10
  16. package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
  17. package/dist/src/circuit/circuit/stop.js +49 -0
  18. package/dist/src/circuit/circuit/stop.js.map +1 -0
  19. package/dist/src/circuit/circuit/stream-handler.d.ts +19 -38
  20. package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
  21. package/dist/src/circuit/circuit/stream-handler.js +59 -0
  22. package/dist/src/circuit/circuit/stream-handler.js.map +1 -0
  23. package/dist/src/circuit/circuit/utils.d.ts +3 -6
  24. package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
  25. package/dist/src/circuit/circuit/utils.js +43 -0
  26. package/dist/src/circuit/circuit/utils.js.map +1 -0
  27. package/dist/src/circuit/constants.d.ts +24 -6
  28. package/dist/src/circuit/constants.d.ts.map +1 -1
  29. package/dist/src/circuit/constants.js +26 -0
  30. package/dist/src/circuit/constants.js.map +1 -0
  31. package/dist/src/circuit/index.d.ts +41 -74
  32. package/dist/src/circuit/index.d.ts.map +1 -1
  33. package/dist/src/circuit/index.js +69 -0
  34. package/dist/src/circuit/index.js.map +1 -0
  35. package/dist/src/circuit/listener.d.ts +8 -3
  36. package/dist/src/circuit/listener.d.ts.map +1 -1
  37. package/dist/src/circuit/listener.js +54 -0
  38. package/dist/src/circuit/listener.js.map +1 -0
  39. package/dist/src/circuit/multicodec.d.ts +1 -1
  40. package/dist/src/circuit/multicodec.d.ts.map +1 -1
  41. package/dist/src/circuit/multicodec.js +2 -0
  42. package/dist/src/circuit/multicodec.js.map +1 -0
  43. package/dist/src/circuit/pb/index.d.ts +51 -0
  44. package/dist/src/circuit/pb/index.d.ts.map +1 -0
  45. package/dist/src/circuit/pb/index.js +72 -0
  46. package/dist/src/circuit/pb/index.js.map +1 -0
  47. package/dist/src/circuit/transport.d.ts +18 -78
  48. package/dist/src/circuit/transport.d.ts.map +1 -1
  49. package/dist/src/circuit/transport.js +190 -0
  50. package/dist/src/circuit/transport.js.map +1 -0
  51. package/dist/src/circuit/utils.d.ts +5 -2
  52. package/dist/src/circuit/utils.d.ts.map +1 -1
  53. package/dist/src/circuit/utils.js +11 -0
  54. package/dist/src/circuit/utils.js.map +1 -0
  55. package/dist/src/config.d.ts +3 -85
  56. package/dist/src/config.d.ts.map +1 -1
  57. package/dist/src/config.js +93 -0
  58. package/dist/src/config.js.map +1 -0
  59. package/dist/src/connection-manager/auto-dialler.d.ts +24 -41
  60. package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
  61. package/dist/src/connection-manager/auto-dialler.js +105 -0
  62. package/dist/src/connection-manager/auto-dialler.js.map +1 -0
  63. package/dist/src/connection-manager/index.d.ts +79 -144
  64. package/dist/src/connection-manager/index.d.ts.map +1 -1
  65. package/dist/src/connection-manager/index.js +295 -0
  66. package/dist/src/connection-manager/index.js.map +1 -0
  67. package/dist/src/connection-manager/latency-monitor.d.ts +72 -97
  68. package/dist/src/connection-manager/latency-monitor.d.ts.map +1 -1
  69. package/dist/src/connection-manager/latency-monitor.js +220 -0
  70. package/dist/src/connection-manager/latency-monitor.js.map +1 -0
  71. package/dist/src/connection-manager/visibility-change-emitter.d.ts +15 -16
  72. package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +1 -1
  73. package/dist/src/connection-manager/visibility-change-emitter.js +118 -0
  74. package/dist/src/connection-manager/visibility-change-emitter.js.map +1 -0
  75. package/dist/src/constants.d.ts +22 -10
  76. package/dist/src/constants.d.ts.map +1 -1
  77. package/dist/src/constants.js +27 -0
  78. package/dist/src/constants.js.map +1 -0
  79. package/dist/src/content-routing/index.d.ts +26 -81
  80. package/dist/src/content-routing/index.d.ts.map +1 -1
  81. package/dist/src/content-routing/index.js +99 -0
  82. package/dist/src/content-routing/index.js.map +1 -0
  83. package/dist/src/content-routing/utils.d.ts +6 -49
  84. package/dist/src/content-routing/utils.d.ts.map +1 -1
  85. package/dist/src/content-routing/utils.js +42 -0
  86. package/dist/src/content-routing/utils.js.map +1 -0
  87. package/dist/src/dht/dht-content-routing.d.ts +10 -24
  88. package/dist/src/dht/dht-content-routing.d.ts.map +1 -1
  89. package/dist/src/dht/dht-content-routing.js +32 -0
  90. package/dist/src/dht/dht-content-routing.js.map +1 -0
  91. package/dist/src/dht/dht-peer-routing.d.ts +9 -24
  92. package/dist/src/dht/dht-peer-routing.d.ts.map +1 -1
  93. package/dist/src/dht/dht-peer-routing.js +26 -0
  94. package/dist/src/dht/dht-peer-routing.js.map +1 -0
  95. package/dist/src/dialer/auto-dialer.d.ts +14 -0
  96. package/dist/src/dialer/auto-dialer.d.ts.map +1 -0
  97. package/dist/src/dialer/auto-dialer.js +24 -0
  98. package/dist/src/dialer/auto-dialer.js.map +1 -0
  99. package/dist/src/dialer/dial-request.d.ts +18 -46
  100. package/dist/src/dialer/dial-request.d.ts.map +1 -1
  101. package/dist/src/dialer/dial-request.js +83 -0
  102. package/dist/src/dialer/dial-request.js.map +1 -0
  103. package/dist/src/dialer/index.d.ts +41 -148
  104. package/dist/src/dialer/index.d.ts.map +1 -1
  105. package/dist/src/dialer/index.js +280 -0
  106. package/dist/src/dialer/index.js.map +1 -0
  107. package/dist/src/errors.d.ts +68 -63
  108. package/dist/src/errors.d.ts.map +1 -1
  109. package/dist/src/errors.js +73 -0
  110. package/dist/src/errors.js.map +1 -0
  111. package/dist/src/fetch/constants.d.ts +1 -1
  112. package/dist/src/fetch/constants.d.ts.map +1 -1
  113. package/dist/src/fetch/constants.js +3 -0
  114. package/dist/src/fetch/constants.js.map +1 -0
  115. package/dist/src/fetch/index.d.ts +30 -49
  116. package/dist/src/fetch/index.d.ts.map +1 -1
  117. package/dist/src/fetch/index.js +129 -0
  118. package/dist/src/fetch/index.js.map +1 -0
  119. package/dist/src/fetch/pb/proto.d.ts +26 -0
  120. package/dist/src/fetch/pb/proto.d.ts.map +1 -0
  121. package/dist/src/fetch/pb/proto.js +44 -0
  122. package/dist/src/fetch/pb/proto.js.map +1 -0
  123. package/dist/src/get-peer.d.ts +4 -11
  124. package/dist/src/get-peer.d.ts.map +1 -1
  125. package/dist/src/get-peer.js +43 -0
  126. package/dist/src/get-peer.js.map +1 -0
  127. package/dist/src/identify/consts.d.ts +9 -9
  128. package/dist/src/identify/consts.d.ts.map +1 -1
  129. package/dist/src/identify/consts.js +11 -0
  130. package/dist/src/identify/consts.js.map +1 -0
  131. package/dist/src/identify/index.d.ts +42 -96
  132. package/dist/src/identify/index.d.ts.map +1 -1
  133. package/dist/src/identify/index.js +322 -0
  134. package/dist/src/identify/index.js.map +1 -0
  135. package/dist/src/identify/pb/message.d.ts +15 -0
  136. package/dist/src/identify/pb/message.d.ts.map +1 -0
  137. package/dist/src/identify/pb/message.js +24 -0
  138. package/dist/src/identify/pb/message.js.map +1 -0
  139. package/dist/src/index.d.ts +162 -581
  140. package/dist/src/index.d.ts.map +1 -1
  141. package/dist/src/index.js +9 -0
  142. package/dist/src/index.js.map +1 -0
  143. package/dist/src/insecure/index.d.ts +9 -0
  144. package/dist/src/insecure/index.d.ts.map +1 -0
  145. package/dist/src/insecure/index.js +81 -0
  146. package/dist/src/insecure/index.js.map +1 -0
  147. package/dist/src/insecure/pb/proto.d.ts +28 -0
  148. package/dist/src/insecure/pb/proto.d.ts.map +1 -0
  149. package/dist/src/insecure/pb/proto.js +46 -0
  150. package/dist/src/insecure/pb/proto.js.map +1 -0
  151. package/dist/src/keychain/cms.d.ts +6 -14
  152. package/dist/src/keychain/cms.d.ts.map +1 -1
  153. package/dist/src/keychain/cms.js +129 -0
  154. package/dist/src/keychain/cms.js.map +1 -0
  155. package/dist/src/keychain/index.d.ts +61 -81
  156. package/dist/src/keychain/index.d.ts.map +1 -1
  157. package/dist/src/keychain/index.js +493 -0
  158. package/dist/src/keychain/index.js.map +1 -0
  159. package/dist/src/keychain/util.d.ts +3 -6
  160. package/dist/src/keychain/util.d.ts.map +1 -1
  161. package/dist/src/keychain/util.js +79 -0
  162. package/dist/src/keychain/util.js.map +1 -0
  163. package/dist/src/libp2p.d.ts +78 -0
  164. package/dist/src/libp2p.d.ts.map +1 -0
  165. package/dist/src/libp2p.js +375 -0
  166. package/dist/src/libp2p.js.map +1 -0
  167. package/dist/src/metrics/index.d.ts +47 -104
  168. package/dist/src/metrics/index.d.ts.map +1 -1
  169. package/dist/src/metrics/index.js +231 -0
  170. package/dist/src/metrics/index.js.map +1 -0
  171. package/dist/src/metrics/moving-average.d.ts +14 -0
  172. package/dist/src/metrics/moving-average.d.ts.map +1 -0
  173. package/dist/src/metrics/moving-average.js +40 -0
  174. package/dist/src/metrics/moving-average.js.map +1 -0
  175. package/dist/src/metrics/stats.d.ts +41 -93
  176. package/dist/src/metrics/stats.d.ts.map +1 -1
  177. package/dist/src/metrics/stats.js +183 -0
  178. package/dist/src/metrics/stats.js.map +1 -0
  179. package/dist/src/nat-manager.d.ts +42 -99
  180. package/dist/src/nat-manager.d.ts.map +1 -1
  181. package/dist/src/nat-manager.js +114 -0
  182. package/dist/src/nat-manager.js.map +1 -0
  183. package/dist/src/peer-record-updater.d.ts +15 -0
  184. package/dist/src/peer-record-updater.d.ts.map +1 -0
  185. package/dist/src/peer-record-updater.js +44 -0
  186. package/dist/src/peer-record-updater.js.map +1 -0
  187. package/dist/src/peer-routing.d.ts +39 -84
  188. package/dist/src/peer-routing.d.ts.map +1 -1
  189. package/dist/src/peer-routing.js +108 -0
  190. package/dist/src/peer-routing.js.map +1 -0
  191. package/dist/src/ping/constants.d.ts +4 -4
  192. package/dist/src/ping/constants.d.ts.map +1 -1
  193. package/dist/src/ping/constants.js +5 -0
  194. package/dist/src/ping/constants.js.map +1 -0
  195. package/dist/src/ping/index.d.ts +26 -33
  196. package/dist/src/ping/index.d.ts.map +1 -1
  197. package/dist/src/ping/index.js +56 -0
  198. package/dist/src/ping/index.js.map +1 -0
  199. package/dist/src/pnet/crypto.d.ts +15 -5
  200. package/dist/src/pnet/crypto.d.ts.map +1 -1
  201. package/dist/src/pnet/crypto.js +60 -0
  202. package/dist/src/pnet/crypto.js.map +1 -0
  203. package/dist/src/pnet/errors.d.ts +5 -5
  204. package/dist/src/pnet/errors.d.ts.map +1 -1
  205. package/dist/src/pnet/errors.js +6 -0
  206. package/dist/src/pnet/errors.js.map +1 -0
  207. package/dist/src/pnet/index.d.ts +11 -20
  208. package/dist/src/pnet/index.d.ts.map +1 -1
  209. package/dist/src/pnet/index.js +66 -0
  210. package/dist/src/pnet/index.js.map +1 -0
  211. package/dist/src/pnet/key-generator.d.ts +3 -7
  212. package/dist/src/pnet/key-generator.d.ts.map +1 -1
  213. package/dist/src/pnet/key-generator.js +25 -0
  214. package/dist/src/pnet/key-generator.js.map +1 -0
  215. package/dist/src/registrar.d.ts +27 -65
  216. package/dist/src/registrar.d.ts.map +1 -1
  217. package/dist/src/registrar.js +159 -0
  218. package/dist/src/registrar.js.map +1 -0
  219. package/dist/src/transport-manager.d.ts +34 -82
  220. package/dist/src/transport-manager.d.ts.map +1 -1
  221. package/dist/src/transport-manager.js +223 -0
  222. package/dist/src/transport-manager.js.map +1 -0
  223. package/dist/src/upgrader.d.ts +49 -129
  224. package/dist/src/upgrader.d.ts.map +1 -1
  225. package/dist/src/upgrader.js +402 -0
  226. package/dist/src/upgrader.js.map +1 -0
  227. package/dist/src/version.d.ts +3 -0
  228. package/dist/src/version.d.ts.map +1 -0
  229. package/dist/src/version.js +3 -0
  230. package/dist/src/version.js.map +1 -0
  231. package/package.json +150 -197
  232. package/src/address-manager/index.ts +129 -0
  233. package/src/circuit/README.md +16 -11
  234. package/src/circuit/auto-relay.ts +284 -0
  235. package/src/circuit/circuit/hop.ts +211 -0
  236. package/src/circuit/circuit/stop.ts +78 -0
  237. package/src/circuit/circuit/stream-handler.ts +86 -0
  238. package/src/circuit/circuit/{utils.js → utils.ts} +9 -25
  239. package/src/circuit/constants.ts +31 -0
  240. package/src/circuit/index.ts +120 -0
  241. package/src/circuit/{listener.js → listener.ts} +21 -27
  242. package/src/circuit/multicodec.ts +2 -0
  243. package/src/circuit/{protocol → pb}/index.proto +1 -1
  244. package/src/circuit/pb/index.ts +88 -0
  245. package/src/circuit/transport.ts +216 -0
  246. package/src/circuit/utils.ts +12 -0
  247. package/src/config.ts +101 -0
  248. package/src/connection-manager/auto-dialler.ts +154 -0
  249. package/src/connection-manager/index.ts +422 -0
  250. package/src/connection-manager/latency-monitor.ts +319 -0
  251. package/src/connection-manager/{visibility-change-emitter.js → visibility-change-emitter.ts} +48 -38
  252. package/src/constants.ts +31 -0
  253. package/src/content-routing/index.ts +143 -0
  254. package/src/content-routing/utils.ts +54 -0
  255. package/src/dht/dht-content-routing.ts +43 -0
  256. package/src/dht/dht-peer-routing.ts +35 -0
  257. package/src/dialer/auto-dialer.ts +40 -0
  258. package/src/dialer/{dial-request.js → dial-request.ts} +60 -51
  259. package/src/dialer/index.ts +371 -0
  260. package/src/errors.ts +71 -0
  261. package/src/fetch/README.md +1 -1
  262. package/src/fetch/constants.ts +3 -0
  263. package/src/fetch/index.ts +167 -0
  264. package/src/fetch/{proto.proto → pb/proto.proto} +0 -0
  265. package/src/fetch/pb/proto.ts +58 -0
  266. package/src/get-peer.ts +57 -0
  267. package/src/identify/consts.ts +13 -0
  268. package/src/identify/index.ts +445 -0
  269. package/src/identify/{message.proto → pb/message.proto} +0 -0
  270. package/src/identify/pb/message.ts +36 -0
  271. package/src/index.ts +242 -0
  272. package/src/insecure/index.ts +101 -0
  273. package/src/insecure/{proto.proto → pb/proto.proto} +0 -0
  274. package/src/insecure/pb/proto.ts +61 -0
  275. package/src/keychain/{cms.js → cms.ts} +62 -58
  276. package/src/keychain/index.ts +588 -0
  277. package/src/keychain/{util.js → util.ts} +7 -17
  278. package/src/libp2p.ts +513 -0
  279. package/src/metrics/index.ts +310 -0
  280. package/src/metrics/moving-average.ts +53 -0
  281. package/src/metrics/stats.ts +238 -0
  282. package/src/nat-manager.ts +194 -0
  283. package/src/peer-record-updater.ts +55 -0
  284. package/src/peer-routing.ts +185 -0
  285. package/src/ping/README.md +1 -1
  286. package/src/ping/constants.ts +5 -0
  287. package/src/ping/index.ts +83 -0
  288. package/src/pnet/README.md +2 -2
  289. package/src/pnet/crypto.ts +67 -0
  290. package/src/pnet/errors.ts +5 -0
  291. package/src/pnet/index.ts +95 -0
  292. package/src/pnet/key-generator.ts +28 -0
  293. package/src/registrar.ts +205 -0
  294. package/src/transport-manager.ts +279 -0
  295. package/src/upgrader.ts +499 -0
  296. package/src/version.ts +3 -0
  297. package/dist/index.min.js +0 -55
  298. package/dist/src/circuit/protocol/index.d.ts +0 -173
  299. package/dist/src/fetch/proto.d.ts +0 -134
  300. package/dist/src/identify/message.d.ts +0 -95
  301. package/dist/src/insecure/plaintext.d.ts +0 -12
  302. package/dist/src/insecure/plaintext.d.ts.map +0 -1
  303. package/dist/src/insecure/proto.d.ts +0 -128
  304. package/dist/src/metrics/old-peers.d.ts +0 -3
  305. package/dist/src/metrics/old-peers.d.ts.map +0 -1
  306. package/dist/src/metrics/tracked-map.d.ts +0 -8
  307. package/dist/src/metrics/tracked-map.d.ts.map +0 -1
  308. package/dist/src/peer-store/address-book.d.ts +0 -67
  309. package/dist/src/peer-store/address-book.d.ts.map +0 -1
  310. package/dist/src/peer-store/index.d.ts +0 -58
  311. package/dist/src/peer-store/index.d.ts.map +0 -1
  312. package/dist/src/peer-store/key-book.d.ts +0 -40
  313. package/dist/src/peer-store/key-book.d.ts.map +0 -1
  314. package/dist/src/peer-store/metadata-book.d.ts +0 -58
  315. package/dist/src/peer-store/metadata-book.d.ts.map +0 -1
  316. package/dist/src/peer-store/pb/peer.d.ts +0 -222
  317. package/dist/src/peer-store/proto-book.d.ts +0 -43
  318. package/dist/src/peer-store/proto-book.d.ts.map +0 -1
  319. package/dist/src/peer-store/store.d.ts +0 -73
  320. package/dist/src/peer-store/store.d.ts.map +0 -1
  321. package/dist/src/peer-store/types.d.ts +0 -202
  322. package/dist/src/peer-store/types.d.ts.map +0 -1
  323. package/dist/src/ping/util.d.ts +0 -5
  324. package/dist/src/ping/util.d.ts.map +0 -1
  325. package/dist/src/pubsub-adapter.d.ts +0 -22
  326. package/dist/src/pubsub-adapter.d.ts.map +0 -1
  327. package/dist/src/record/envelope/envelope.d.ts +0 -77
  328. package/dist/src/record/envelope/index.d.ts +0 -80
  329. package/dist/src/record/envelope/index.d.ts.map +0 -1
  330. package/dist/src/record/peer-record/consts.d.ts +0 -4
  331. package/dist/src/record/peer-record/consts.d.ts.map +0 -1
  332. package/dist/src/record/peer-record/index.d.ts +0 -60
  333. package/dist/src/record/peer-record/index.d.ts.map +0 -1
  334. package/dist/src/record/peer-record/peer-record.d.ts +0 -133
  335. package/dist/src/record/utils.d.ts +0 -12
  336. package/dist/src/record/utils.d.ts.map +0 -1
  337. package/dist/src/types.d.ts +0 -90
  338. package/dist/src/types.d.ts.map +0 -1
  339. package/src/address-manager/index.js +0 -96
  340. package/src/circuit/auto-relay.js +0 -302
  341. package/src/circuit/circuit/hop.js +0 -205
  342. package/src/circuit/circuit/stop.js +0 -81
  343. package/src/circuit/circuit/stream-handler.js +0 -94
  344. package/src/circuit/constants.js +0 -12
  345. package/src/circuit/index.js +0 -102
  346. package/src/circuit/multicodec.js +0 -5
  347. package/src/circuit/protocol/index.d.ts +0 -173
  348. package/src/circuit/protocol/index.js +0 -530
  349. package/src/circuit/transport.js +0 -229
  350. package/src/circuit/utils.js +0 -17
  351. package/src/config.js +0 -114
  352. package/src/connection-manager/auto-dialler.js +0 -132
  353. package/src/connection-manager/index.js +0 -363
  354. package/src/connection-manager/latency-monitor.js +0 -264
  355. package/src/constants.js +0 -18
  356. package/src/content-routing/index.js +0 -163
  357. package/src/content-routing/utils.js +0 -89
  358. package/src/dht/dht-content-routing.js +0 -44
  359. package/src/dht/dht-peer-routing.js +0 -51
  360. package/src/dialer/index.js +0 -376
  361. package/src/errors.js +0 -66
  362. package/src/fetch/constants.js +0 -6
  363. package/src/fetch/index.js +0 -159
  364. package/src/fetch/proto.d.ts +0 -134
  365. package/src/fetch/proto.js +0 -333
  366. package/src/get-peer.js +0 -49
  367. package/src/identify/consts.js +0 -15
  368. package/src/identify/index.js +0 -384
  369. package/src/identify/message.d.ts +0 -95
  370. package/src/identify/message.js +0 -328
  371. package/src/index.js +0 -811
  372. package/src/insecure/plaintext.js +0 -95
  373. package/src/insecure/proto.d.ts +0 -128
  374. package/src/insecure/proto.js +0 -371
  375. package/src/keychain/index.js +0 -561
  376. package/src/metrics/index.js +0 -290
  377. package/src/metrics/old-peers.js +0 -16
  378. package/src/metrics/stats.js +0 -270
  379. package/src/metrics/tracked-map.js +0 -94
  380. package/src/nat-manager.js +0 -197
  381. package/src/peer-routing.js +0 -176
  382. package/src/peer-store/README.md +0 -145
  383. package/src/peer-store/address-book.js +0 -382
  384. package/src/peer-store/index.js +0 -121
  385. package/src/peer-store/key-book.js +0 -141
  386. package/src/peer-store/metadata-book.js +0 -250
  387. package/src/peer-store/pb/peer.d.ts +0 -222
  388. package/src/peer-store/pb/peer.js +0 -643
  389. package/src/peer-store/pb/peer.proto +0 -31
  390. package/src/peer-store/proto-book.js +0 -237
  391. package/src/peer-store/store.js +0 -263
  392. package/src/peer-store/types.ts +0 -245
  393. package/src/ping/constants.js +0 -8
  394. package/src/ping/index.js +0 -85
  395. package/src/ping/util.js +0 -18
  396. package/src/pnet/crypto.js +0 -84
  397. package/src/pnet/errors.js +0 -7
  398. package/src/pnet/index.js +0 -86
  399. package/src/pnet/key-generator.js +0 -33
  400. package/src/pubsub-adapter.js +0 -61
  401. package/src/record/README.md +0 -130
  402. package/src/record/envelope/envelope.d.ts +0 -77
  403. package/src/record/envelope/envelope.js +0 -243
  404. package/src/record/envelope/envelope.proto +0 -19
  405. package/src/record/envelope/index.js +0 -183
  406. package/src/record/peer-record/consts.js +0 -14
  407. package/src/record/peer-record/index.js +0 -113
  408. package/src/record/peer-record/peer-record.d.ts +0 -133
  409. package/src/record/peer-record/peer-record.js +0 -367
  410. package/src/record/peer-record/peer-record.proto +0 -18
  411. package/src/record/utils.js +0 -25
  412. package/src/registrar.js +0 -127
  413. package/src/transport-manager.js +0 -269
  414. package/src/types.ts +0 -98
  415. package/src/upgrader.js +0 -492
@@ -1,113 +0,0 @@
1
- 'use strict'
2
-
3
- const { Multiaddr } = require('multiaddr')
4
- const PeerId = require('peer-id')
5
- const arrayEquals = require('libp2p-utils/src/array-equals')
6
-
7
- const { PeerRecord: Protobuf } = require('./peer-record')
8
- const {
9
- ENVELOPE_DOMAIN_PEER_RECORD,
10
- ENVELOPE_PAYLOAD_TYPE_PEER_RECORD
11
- } = require('./consts')
12
-
13
- /**
14
- * @typedef {import('../../peer-store/types').Address} Address
15
- * @typedef {import('libp2p-interfaces/src/record/types').Record} Record
16
- */
17
-
18
- /**
19
- * @implements {Record}
20
- */
21
- class PeerRecord {
22
- /**
23
- * The PeerRecord is used for distributing peer routing records across the network.
24
- * It contains the peer's reachable listen addresses.
25
- *
26
- * @class
27
- * @param {Object} params
28
- * @param {PeerId} params.peerId
29
- * @param {Multiaddr[]} params.multiaddrs - addresses of the associated peer.
30
- * @param {number} [params.seqNumber] - monotonically-increasing sequence counter that's used to order PeerRecords in time.
31
- */
32
- constructor ({ peerId, multiaddrs = [], seqNumber = Date.now() }) {
33
- this.domain = ENVELOPE_DOMAIN_PEER_RECORD
34
- this.codec = ENVELOPE_PAYLOAD_TYPE_PEER_RECORD
35
-
36
- this.peerId = peerId
37
- this.multiaddrs = multiaddrs
38
- this.seqNumber = seqNumber
39
-
40
- // Cache
41
- this._marshal = undefined
42
- }
43
-
44
- /**
45
- * Marshal a record to be used in an envelope.
46
- *
47
- * @returns {Uint8Array}
48
- */
49
- marshal () {
50
- if (this._marshal) {
51
- return this._marshal
52
- }
53
-
54
- this._marshal = Protobuf.encode({
55
- peerId: this.peerId.toBytes(),
56
- seq: this.seqNumber,
57
- addresses: this.multiaddrs.map((m) => ({
58
- multiaddr: m.bytes
59
- }))
60
- }).finish()
61
-
62
- return this._marshal
63
- }
64
-
65
- /**
66
- * Returns true if `this` record equals the `other`.
67
- *
68
- * @param {unknown} other
69
- * @returns {boolean}
70
- */
71
- equals (other) {
72
- if (!(other instanceof PeerRecord)) {
73
- return false
74
- }
75
-
76
- // Validate PeerId
77
- if (!this.peerId.equals(other.peerId)) {
78
- return false
79
- }
80
-
81
- // Validate seqNumber
82
- if (this.seqNumber !== other.seqNumber) {
83
- return false
84
- }
85
-
86
- // Validate multiaddrs
87
- if (!arrayEquals(this.multiaddrs, other.multiaddrs)) {
88
- return false
89
- }
90
-
91
- return true
92
- }
93
- }
94
-
95
- /**
96
- * Unmarshal Peer Record Protobuf.
97
- *
98
- * @param {Uint8Array} buf - marshaled peer record.
99
- * @returns {PeerRecord}
100
- */
101
- PeerRecord.createFromProtobuf = (buf) => {
102
- const peerRecord = Protobuf.decode(buf)
103
-
104
- const peerId = PeerId.createFromBytes(peerRecord.peerId)
105
- const multiaddrs = (peerRecord.addresses || []).map((a) => new Multiaddr(a.multiaddr))
106
- const seqNumber = Number(peerRecord.seq)
107
-
108
- return new PeerRecord({ peerId, multiaddrs, seqNumber })
109
- }
110
-
111
- PeerRecord.DOMAIN = ENVELOPE_DOMAIN_PEER_RECORD
112
-
113
- module.exports = PeerRecord
@@ -1,133 +0,0 @@
1
- import * as $protobuf from "protobufjs";
2
- /** Properties of a PeerRecord. */
3
- export interface IPeerRecord {
4
-
5
- /** PeerRecord peerId */
6
- peerId?: (Uint8Array|null);
7
-
8
- /** PeerRecord seq */
9
- seq?: (number|null);
10
-
11
- /** PeerRecord addresses */
12
- addresses?: (PeerRecord.IAddressInfo[]|null);
13
- }
14
-
15
- /** Represents a PeerRecord. */
16
- export class PeerRecord implements IPeerRecord {
17
-
18
- /**
19
- * Constructs a new PeerRecord.
20
- * @param [p] Properties to set
21
- */
22
- constructor(p?: IPeerRecord);
23
-
24
- /** PeerRecord peerId. */
25
- public peerId: Uint8Array;
26
-
27
- /** PeerRecord seq. */
28
- public seq: number;
29
-
30
- /** PeerRecord addresses. */
31
- public addresses: PeerRecord.IAddressInfo[];
32
-
33
- /**
34
- * Encodes the specified PeerRecord message. Does not implicitly {@link PeerRecord.verify|verify} messages.
35
- * @param m PeerRecord message or plain object to encode
36
- * @param [w] Writer to encode to
37
- * @returns Writer
38
- */
39
- public static encode(m: IPeerRecord, w?: $protobuf.Writer): $protobuf.Writer;
40
-
41
- /**
42
- * Decodes a PeerRecord message from the specified reader or buffer.
43
- * @param r Reader or buffer to decode from
44
- * @param [l] Message length if known beforehand
45
- * @returns PeerRecord
46
- * @throws {Error} If the payload is not a reader or valid buffer
47
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
48
- */
49
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): PeerRecord;
50
-
51
- /**
52
- * Creates a PeerRecord message from a plain object. Also converts values to their respective internal types.
53
- * @param d Plain object
54
- * @returns PeerRecord
55
- */
56
- public static fromObject(d: { [k: string]: any }): PeerRecord;
57
-
58
- /**
59
- * Creates a plain object from a PeerRecord message. Also converts values to other types if specified.
60
- * @param m PeerRecord
61
- * @param [o] Conversion options
62
- * @returns Plain object
63
- */
64
- public static toObject(m: PeerRecord, o?: $protobuf.IConversionOptions): { [k: string]: any };
65
-
66
- /**
67
- * Converts this PeerRecord to JSON.
68
- * @returns JSON object
69
- */
70
- public toJSON(): { [k: string]: any };
71
- }
72
-
73
- export namespace PeerRecord {
74
-
75
- /** Properties of an AddressInfo. */
76
- interface IAddressInfo {
77
-
78
- /** AddressInfo multiaddr */
79
- multiaddr?: (Uint8Array|null);
80
- }
81
-
82
- /** Represents an AddressInfo. */
83
- class AddressInfo implements IAddressInfo {
84
-
85
- /**
86
- * Constructs a new AddressInfo.
87
- * @param [p] Properties to set
88
- */
89
- constructor(p?: PeerRecord.IAddressInfo);
90
-
91
- /** AddressInfo multiaddr. */
92
- public multiaddr: Uint8Array;
93
-
94
- /**
95
- * Encodes the specified AddressInfo message. Does not implicitly {@link PeerRecord.AddressInfo.verify|verify} messages.
96
- * @param m AddressInfo message or plain object to encode
97
- * @param [w] Writer to encode to
98
- * @returns Writer
99
- */
100
- public static encode(m: PeerRecord.IAddressInfo, w?: $protobuf.Writer): $protobuf.Writer;
101
-
102
- /**
103
- * Decodes an AddressInfo message from the specified reader or buffer.
104
- * @param r Reader or buffer to decode from
105
- * @param [l] Message length if known beforehand
106
- * @returns AddressInfo
107
- * @throws {Error} If the payload is not a reader or valid buffer
108
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
109
- */
110
- public static decode(r: ($protobuf.Reader|Uint8Array), l?: number): PeerRecord.AddressInfo;
111
-
112
- /**
113
- * Creates an AddressInfo message from a plain object. Also converts values to their respective internal types.
114
- * @param d Plain object
115
- * @returns AddressInfo
116
- */
117
- public static fromObject(d: { [k: string]: any }): PeerRecord.AddressInfo;
118
-
119
- /**
120
- * Creates a plain object from an AddressInfo message. Also converts values to other types if specified.
121
- * @param m AddressInfo
122
- * @param [o] Conversion options
123
- * @returns Plain object
124
- */
125
- public static toObject(m: PeerRecord.AddressInfo, o?: $protobuf.IConversionOptions): { [k: string]: any };
126
-
127
- /**
128
- * Converts this AddressInfo to JSON.
129
- * @returns JSON object
130
- */
131
- public toJSON(): { [k: string]: any };
132
- }
133
- }
@@ -1,367 +0,0 @@
1
- /*eslint-disable*/
2
- "use strict";
3
-
4
- var $protobuf = require("protobufjs/minimal");
5
-
6
- // Common aliases
7
- var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
8
-
9
- // Exported root namespace
10
- var $root = $protobuf.roots["libp2p-peer-record"] || ($protobuf.roots["libp2p-peer-record"] = {});
11
-
12
- $root.PeerRecord = (function() {
13
-
14
- /**
15
- * Properties of a PeerRecord.
16
- * @exports IPeerRecord
17
- * @interface IPeerRecord
18
- * @property {Uint8Array|null} [peerId] PeerRecord peerId
19
- * @property {number|null} [seq] PeerRecord seq
20
- * @property {Array.<PeerRecord.IAddressInfo>|null} [addresses] PeerRecord addresses
21
- */
22
-
23
- /**
24
- * Constructs a new PeerRecord.
25
- * @exports PeerRecord
26
- * @classdesc Represents a PeerRecord.
27
- * @implements IPeerRecord
28
- * @constructor
29
- * @param {IPeerRecord=} [p] Properties to set
30
- */
31
- function PeerRecord(p) {
32
- this.addresses = [];
33
- if (p)
34
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
35
- if (p[ks[i]] != null)
36
- this[ks[i]] = p[ks[i]];
37
- }
38
-
39
- /**
40
- * PeerRecord peerId.
41
- * @member {Uint8Array} peerId
42
- * @memberof PeerRecord
43
- * @instance
44
- */
45
- PeerRecord.prototype.peerId = $util.newBuffer([]);
46
-
47
- /**
48
- * PeerRecord seq.
49
- * @member {number} seq
50
- * @memberof PeerRecord
51
- * @instance
52
- */
53
- PeerRecord.prototype.seq = $util.Long ? $util.Long.fromBits(0,0,true) : 0;
54
-
55
- /**
56
- * PeerRecord addresses.
57
- * @member {Array.<PeerRecord.IAddressInfo>} addresses
58
- * @memberof PeerRecord
59
- * @instance
60
- */
61
- PeerRecord.prototype.addresses = $util.emptyArray;
62
-
63
- /**
64
- * Encodes the specified PeerRecord message. Does not implicitly {@link PeerRecord.verify|verify} messages.
65
- * @function encode
66
- * @memberof PeerRecord
67
- * @static
68
- * @param {IPeerRecord} m PeerRecord message or plain object to encode
69
- * @param {$protobuf.Writer} [w] Writer to encode to
70
- * @returns {$protobuf.Writer} Writer
71
- */
72
- PeerRecord.encode = function encode(m, w) {
73
- if (!w)
74
- w = $Writer.create();
75
- if (m.peerId != null && Object.hasOwnProperty.call(m, "peerId"))
76
- w.uint32(10).bytes(m.peerId);
77
- if (m.seq != null && Object.hasOwnProperty.call(m, "seq"))
78
- w.uint32(16).uint64(m.seq);
79
- if (m.addresses != null && m.addresses.length) {
80
- for (var i = 0; i < m.addresses.length; ++i)
81
- $root.PeerRecord.AddressInfo.encode(m.addresses[i], w.uint32(26).fork()).ldelim();
82
- }
83
- return w;
84
- };
85
-
86
- /**
87
- * Decodes a PeerRecord message from the specified reader or buffer.
88
- * @function decode
89
- * @memberof PeerRecord
90
- * @static
91
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
92
- * @param {number} [l] Message length if known beforehand
93
- * @returns {PeerRecord} PeerRecord
94
- * @throws {Error} If the payload is not a reader or valid buffer
95
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
96
- */
97
- PeerRecord.decode = function decode(r, l) {
98
- if (!(r instanceof $Reader))
99
- r = $Reader.create(r);
100
- var c = l === undefined ? r.len : r.pos + l, m = new $root.PeerRecord();
101
- while (r.pos < c) {
102
- var t = r.uint32();
103
- switch (t >>> 3) {
104
- case 1:
105
- m.peerId = r.bytes();
106
- break;
107
- case 2:
108
- m.seq = r.uint64();
109
- break;
110
- case 3:
111
- if (!(m.addresses && m.addresses.length))
112
- m.addresses = [];
113
- m.addresses.push($root.PeerRecord.AddressInfo.decode(r, r.uint32()));
114
- break;
115
- default:
116
- r.skipType(t & 7);
117
- break;
118
- }
119
- }
120
- return m;
121
- };
122
-
123
- /**
124
- * Creates a PeerRecord message from a plain object. Also converts values to their respective internal types.
125
- * @function fromObject
126
- * @memberof PeerRecord
127
- * @static
128
- * @param {Object.<string,*>} d Plain object
129
- * @returns {PeerRecord} PeerRecord
130
- */
131
- PeerRecord.fromObject = function fromObject(d) {
132
- if (d instanceof $root.PeerRecord)
133
- return d;
134
- var m = new $root.PeerRecord();
135
- if (d.peerId != null) {
136
- if (typeof d.peerId === "string")
137
- $util.base64.decode(d.peerId, m.peerId = $util.newBuffer($util.base64.length(d.peerId)), 0);
138
- else if (d.peerId.length)
139
- m.peerId = d.peerId;
140
- }
141
- if (d.seq != null) {
142
- if ($util.Long)
143
- (m.seq = $util.Long.fromValue(d.seq)).unsigned = true;
144
- else if (typeof d.seq === "string")
145
- m.seq = parseInt(d.seq, 10);
146
- else if (typeof d.seq === "number")
147
- m.seq = d.seq;
148
- else if (typeof d.seq === "object")
149
- m.seq = new $util.LongBits(d.seq.low >>> 0, d.seq.high >>> 0).toNumber(true);
150
- }
151
- if (d.addresses) {
152
- if (!Array.isArray(d.addresses))
153
- throw TypeError(".PeerRecord.addresses: array expected");
154
- m.addresses = [];
155
- for (var i = 0; i < d.addresses.length; ++i) {
156
- if (typeof d.addresses[i] !== "object")
157
- throw TypeError(".PeerRecord.addresses: object expected");
158
- m.addresses[i] = $root.PeerRecord.AddressInfo.fromObject(d.addresses[i]);
159
- }
160
- }
161
- return m;
162
- };
163
-
164
- /**
165
- * Creates a plain object from a PeerRecord message. Also converts values to other types if specified.
166
- * @function toObject
167
- * @memberof PeerRecord
168
- * @static
169
- * @param {PeerRecord} m PeerRecord
170
- * @param {$protobuf.IConversionOptions} [o] Conversion options
171
- * @returns {Object.<string,*>} Plain object
172
- */
173
- PeerRecord.toObject = function toObject(m, o) {
174
- if (!o)
175
- o = {};
176
- var d = {};
177
- if (o.arrays || o.defaults) {
178
- d.addresses = [];
179
- }
180
- if (o.defaults) {
181
- if (o.bytes === String)
182
- d.peerId = "";
183
- else {
184
- d.peerId = [];
185
- if (o.bytes !== Array)
186
- d.peerId = $util.newBuffer(d.peerId);
187
- }
188
- if ($util.Long) {
189
- var n = new $util.Long(0, 0, true);
190
- d.seq = o.longs === String ? n.toString() : o.longs === Number ? n.toNumber() : n;
191
- } else
192
- d.seq = o.longs === String ? "0" : 0;
193
- }
194
- if (m.peerId != null && m.hasOwnProperty("peerId")) {
195
- d.peerId = o.bytes === String ? $util.base64.encode(m.peerId, 0, m.peerId.length) : o.bytes === Array ? Array.prototype.slice.call(m.peerId) : m.peerId;
196
- }
197
- if (m.seq != null && m.hasOwnProperty("seq")) {
198
- if (typeof m.seq === "number")
199
- d.seq = o.longs === String ? String(m.seq) : m.seq;
200
- else
201
- d.seq = o.longs === String ? $util.Long.prototype.toString.call(m.seq) : o.longs === Number ? new $util.LongBits(m.seq.low >>> 0, m.seq.high >>> 0).toNumber(true) : m.seq;
202
- }
203
- if (m.addresses && m.addresses.length) {
204
- d.addresses = [];
205
- for (var j = 0; j < m.addresses.length; ++j) {
206
- d.addresses[j] = $root.PeerRecord.AddressInfo.toObject(m.addresses[j], o);
207
- }
208
- }
209
- return d;
210
- };
211
-
212
- /**
213
- * Converts this PeerRecord to JSON.
214
- * @function toJSON
215
- * @memberof PeerRecord
216
- * @instance
217
- * @returns {Object.<string,*>} JSON object
218
- */
219
- PeerRecord.prototype.toJSON = function toJSON() {
220
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
221
- };
222
-
223
- PeerRecord.AddressInfo = (function() {
224
-
225
- /**
226
- * Properties of an AddressInfo.
227
- * @memberof PeerRecord
228
- * @interface IAddressInfo
229
- * @property {Uint8Array|null} [multiaddr] AddressInfo multiaddr
230
- */
231
-
232
- /**
233
- * Constructs a new AddressInfo.
234
- * @memberof PeerRecord
235
- * @classdesc Represents an AddressInfo.
236
- * @implements IAddressInfo
237
- * @constructor
238
- * @param {PeerRecord.IAddressInfo=} [p] Properties to set
239
- */
240
- function AddressInfo(p) {
241
- if (p)
242
- for (var ks = Object.keys(p), i = 0; i < ks.length; ++i)
243
- if (p[ks[i]] != null)
244
- this[ks[i]] = p[ks[i]];
245
- }
246
-
247
- /**
248
- * AddressInfo multiaddr.
249
- * @member {Uint8Array} multiaddr
250
- * @memberof PeerRecord.AddressInfo
251
- * @instance
252
- */
253
- AddressInfo.prototype.multiaddr = $util.newBuffer([]);
254
-
255
- /**
256
- * Encodes the specified AddressInfo message. Does not implicitly {@link PeerRecord.AddressInfo.verify|verify} messages.
257
- * @function encode
258
- * @memberof PeerRecord.AddressInfo
259
- * @static
260
- * @param {PeerRecord.IAddressInfo} m AddressInfo message or plain object to encode
261
- * @param {$protobuf.Writer} [w] Writer to encode to
262
- * @returns {$protobuf.Writer} Writer
263
- */
264
- AddressInfo.encode = function encode(m, w) {
265
- if (!w)
266
- w = $Writer.create();
267
- if (m.multiaddr != null && Object.hasOwnProperty.call(m, "multiaddr"))
268
- w.uint32(10).bytes(m.multiaddr);
269
- return w;
270
- };
271
-
272
- /**
273
- * Decodes an AddressInfo message from the specified reader or buffer.
274
- * @function decode
275
- * @memberof PeerRecord.AddressInfo
276
- * @static
277
- * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from
278
- * @param {number} [l] Message length if known beforehand
279
- * @returns {PeerRecord.AddressInfo} AddressInfo
280
- * @throws {Error} If the payload is not a reader or valid buffer
281
- * @throws {$protobuf.util.ProtocolError} If required fields are missing
282
- */
283
- AddressInfo.decode = function decode(r, l) {
284
- if (!(r instanceof $Reader))
285
- r = $Reader.create(r);
286
- var c = l === undefined ? r.len : r.pos + l, m = new $root.PeerRecord.AddressInfo();
287
- while (r.pos < c) {
288
- var t = r.uint32();
289
- switch (t >>> 3) {
290
- case 1:
291
- m.multiaddr = r.bytes();
292
- break;
293
- default:
294
- r.skipType(t & 7);
295
- break;
296
- }
297
- }
298
- return m;
299
- };
300
-
301
- /**
302
- * Creates an AddressInfo message from a plain object. Also converts values to their respective internal types.
303
- * @function fromObject
304
- * @memberof PeerRecord.AddressInfo
305
- * @static
306
- * @param {Object.<string,*>} d Plain object
307
- * @returns {PeerRecord.AddressInfo} AddressInfo
308
- */
309
- AddressInfo.fromObject = function fromObject(d) {
310
- if (d instanceof $root.PeerRecord.AddressInfo)
311
- return d;
312
- var m = new $root.PeerRecord.AddressInfo();
313
- if (d.multiaddr != null) {
314
- if (typeof d.multiaddr === "string")
315
- $util.base64.decode(d.multiaddr, m.multiaddr = $util.newBuffer($util.base64.length(d.multiaddr)), 0);
316
- else if (d.multiaddr.length)
317
- m.multiaddr = d.multiaddr;
318
- }
319
- return m;
320
- };
321
-
322
- /**
323
- * Creates a plain object from an AddressInfo message. Also converts values to other types if specified.
324
- * @function toObject
325
- * @memberof PeerRecord.AddressInfo
326
- * @static
327
- * @param {PeerRecord.AddressInfo} m AddressInfo
328
- * @param {$protobuf.IConversionOptions} [o] Conversion options
329
- * @returns {Object.<string,*>} Plain object
330
- */
331
- AddressInfo.toObject = function toObject(m, o) {
332
- if (!o)
333
- o = {};
334
- var d = {};
335
- if (o.defaults) {
336
- if (o.bytes === String)
337
- d.multiaddr = "";
338
- else {
339
- d.multiaddr = [];
340
- if (o.bytes !== Array)
341
- d.multiaddr = $util.newBuffer(d.multiaddr);
342
- }
343
- }
344
- if (m.multiaddr != null && m.hasOwnProperty("multiaddr")) {
345
- d.multiaddr = o.bytes === String ? $util.base64.encode(m.multiaddr, 0, m.multiaddr.length) : o.bytes === Array ? Array.prototype.slice.call(m.multiaddr) : m.multiaddr;
346
- }
347
- return d;
348
- };
349
-
350
- /**
351
- * Converts this AddressInfo to JSON.
352
- * @function toJSON
353
- * @memberof PeerRecord.AddressInfo
354
- * @instance
355
- * @returns {Object.<string,*>} JSON object
356
- */
357
- AddressInfo.prototype.toJSON = function toJSON() {
358
- return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
359
- };
360
-
361
- return AddressInfo;
362
- })();
363
-
364
- return PeerRecord;
365
- })();
366
-
367
- module.exports = $root;
@@ -1,18 +0,0 @@
1
- syntax = "proto3";
2
-
3
- message PeerRecord {
4
- // AddressInfo is a wrapper around a binary multiaddr. It is defined as a
5
- // separate message to allow us to add per-address metadata in the future.
6
- message AddressInfo {
7
- bytes multiaddr = 1;
8
- }
9
-
10
- // peer_id contains a libp2p peer id in its binary representation.
11
- bytes peer_id = 1;
12
-
13
- // seq contains a monotonically-increasing sequence counter to order PeerRecords in time.
14
- uint64 seq = 2;
15
-
16
- // addresses is a list of public listen addresses for the peer.
17
- repeated AddressInfo addresses = 3;
18
- }
@@ -1,25 +0,0 @@
1
- 'use strict'
2
-
3
- const Envelope = require('./envelope')
4
- const PeerRecord = require('./peer-record')
5
-
6
- /**
7
- * @typedef {import('../')} Libp2p
8
- */
9
-
10
- /**
11
- * Create (or update if existing) self peer record and store it in the AddressBook.
12
- *
13
- * @param {Libp2p} libp2p
14
- * @returns {Promise<void>}
15
- */
16
- async function updateSelfPeerRecord (libp2p) {
17
- const peerRecord = new PeerRecord({
18
- peerId: libp2p.peerId,
19
- multiaddrs: libp2p.multiaddrs
20
- })
21
- const envelope = await Envelope.seal(peerRecord, libp2p.peerId)
22
- await libp2p.peerStore.addressBook.consumePeerRecord(envelope)
23
- }
24
-
25
- module.exports.updateSelfPeerRecord = updateSelfPeerRecord