@streamr/dht 100.0.0-testnet-one.3 → 100.0.0-testnet-two.0

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 (307) hide show
  1. package/dist/src/connection/ConnectionLockHandler.d.ts +11 -11
  2. package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
  3. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
  4. package/dist/src/connection/ConnectionLockRpcLocal.js +4 -4
  5. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  6. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -5
  7. package/dist/src/connection/ConnectionLockRpcRemote.js +4 -7
  8. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  9. package/dist/src/connection/ConnectionManager.d.ts +4 -6
  10. package/dist/src/connection/ConnectionManager.js +48 -46
  11. package/dist/src/connection/ConnectionManager.js.map +1 -1
  12. package/dist/src/connection/ConnectorFacade.d.ts +2 -2
  13. package/dist/src/connection/ConnectorFacade.js +2 -1
  14. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  15. package/dist/src/connection/ManagedConnection.d.ts +3 -6
  16. package/dist/src/connection/ManagedConnection.js +6 -10
  17. package/dist/src/connection/ManagedConnection.js.map +1 -1
  18. package/dist/src/connection/connectivityChecker.js +1 -0
  19. package/dist/src/connection/connectivityChecker.js.map +1 -1
  20. package/dist/src/connection/simulator/Simulator.d.ts +0 -3
  21. package/dist/src/connection/simulator/Simulator.js +3 -51
  22. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  23. package/dist/src/connection/simulator/SimulatorConnector.js +5 -5
  24. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  25. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +2 -2
  26. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  27. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -1
  28. package/dist/src/connection/webrtc/WebrtcConnector.js +7 -9
  29. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  30. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -2
  31. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +11 -12
  32. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  33. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +2 -5
  34. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +1 -4
  35. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
  36. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
  37. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +3 -4
  38. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
  39. package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
  40. package/dist/src/connection/websocket/WebsocketConnector.d.ts +2 -7
  41. package/dist/src/connection/websocket/WebsocketConnector.js +32 -38
  42. package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
  43. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +3 -2
  44. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +8 -10
  45. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
  46. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +3 -6
  47. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +0 -3
  48. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
  49. package/dist/src/connection/websocket/WebsocketServer.d.ts +1 -4
  50. package/dist/src/connection/websocket/WebsocketServer.js +11 -12
  51. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
  52. package/dist/src/dht/DhtNode.d.ts +10 -13
  53. package/dist/src/dht/DhtNode.js +39 -52
  54. package/dist/src/dht/DhtNode.js.map +1 -1
  55. package/dist/src/dht/DhtNodeRpcLocal.d.ts +0 -1
  56. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  57. package/dist/src/dht/DhtNodeRpcRemote.d.ts +7 -7
  58. package/dist/src/dht/DhtNodeRpcRemote.js +8 -7
  59. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
  60. package/dist/src/dht/ExternalApiRpcLocal.d.ts +5 -4
  61. package/dist/src/dht/ExternalApiRpcLocal.js +3 -2
  62. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  63. package/dist/src/dht/ExternalApiRpcRemote.d.ts +2 -2
  64. package/dist/src/dht/ExternalApiRpcRemote.js +2 -0
  65. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  66. package/dist/src/dht/PeerManager.d.ts +13 -14
  67. package/dist/src/dht/PeerManager.js +45 -60
  68. package/dist/src/dht/PeerManager.js.map +1 -1
  69. package/dist/src/dht/contact/Contact.d.ts +2 -2
  70. package/dist/src/dht/contact/Contact.js +2 -2
  71. package/dist/src/dht/contact/Contact.js.map +1 -1
  72. package/dist/src/dht/contact/ContactList.d.ts +7 -7
  73. package/dist/src/dht/contact/ContactList.js +3 -3
  74. package/dist/src/dht/contact/ContactList.js.map +1 -1
  75. package/dist/src/dht/contact/RandomContactList.d.ts +4 -4
  76. package/dist/src/dht/contact/RandomContactList.js +12 -11
  77. package/dist/src/dht/contact/RandomContactList.js.map +1 -1
  78. package/dist/src/dht/contact/RpcRemote.d.ts +7 -4
  79. package/dist/src/dht/contact/RpcRemote.js +5 -2
  80. package/dist/src/dht/contact/RpcRemote.js.map +1 -1
  81. package/dist/src/dht/contact/SortedContactList.d.ts +13 -13
  82. package/dist/src/dht/contact/SortedContactList.js +33 -29
  83. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  84. package/dist/src/dht/discovery/DiscoverySession.d.ts +2 -4
  85. package/dist/src/dht/discovery/DiscoverySession.js +19 -20
  86. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  87. package/dist/src/dht/discovery/PeerDiscovery.d.ts +2 -5
  88. package/dist/src/dht/discovery/PeerDiscovery.js +12 -20
  89. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  90. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
  91. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +165 -0
  92. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -0
  93. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +14 -0
  94. package/dist/src/dht/{find/FindRpcLocal.js → recursive-operation/RecursiveOperationRpcLocal.js} +7 -7
  95. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -0
  96. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +6 -0
  97. package/dist/src/dht/{routing/FindRpcRemote.js → recursive-operation/RecursiveOperationRpcRemote.js} +11 -11
  98. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
  99. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +42 -0
  100. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +182 -0
  101. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
  102. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +12 -0
  103. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +17 -0
  104. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -0
  105. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +6 -0
  106. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +21 -0
  107. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +1 -0
  108. package/dist/src/dht/routing/Router.d.ts +4 -19
  109. package/dist/src/dht/routing/Router.js +41 -33
  110. package/dist/src/dht/routing/Router.js.map +1 -1
  111. package/dist/src/dht/routing/RouterRpcLocal.js +6 -5
  112. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  113. package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
  114. package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
  115. package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
  116. package/dist/src/dht/routing/RoutingSession.d.ts +20 -16
  117. package/dist/src/dht/routing/RoutingSession.js +37 -45
  118. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  119. package/dist/src/dht/store/LocalDataStore.d.ts +11 -13
  120. package/dist/src/dht/store/LocalDataStore.js +36 -56
  121. package/dist/src/dht/store/LocalDataStore.js.map +1 -1
  122. package/dist/src/dht/store/StoreManager.d.ts +33 -0
  123. package/dist/src/dht/store/StoreManager.js +186 -0
  124. package/dist/src/dht/store/StoreManager.js.map +1 -0
  125. package/dist/src/dht/store/StoreRpcLocal.d.ts +8 -40
  126. package/dist/src/dht/store/StoreRpcLocal.js +13 -229
  127. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  128. package/dist/src/dht/store/StoreRpcRemote.d.ts +5 -5
  129. package/dist/src/dht/store/StoreRpcRemote.js +4 -5
  130. package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
  131. package/dist/src/exports.d.ts +2 -0
  132. package/dist/src/exports.js.map +1 -1
  133. package/dist/src/helpers/MapWithTtl.d.ts +14 -0
  134. package/dist/src/helpers/MapWithTtl.js +59 -0
  135. package/dist/src/helpers/MapWithTtl.js.map +1 -0
  136. package/dist/src/helpers/PeerID.d.ts +2 -0
  137. package/dist/src/helpers/PeerID.js +4 -0
  138. package/dist/src/helpers/PeerID.js.map +1 -1
  139. package/dist/src/helpers/nodeId.d.ts +5 -0
  140. package/dist/src/helpers/nodeId.js +18 -1
  141. package/dist/src/helpers/nodeId.js.map +1 -1
  142. package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +2 -1
  143. package/dist/src/helpers/peerIdFromPeerDescriptor.js +2 -1
  144. package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
  145. package/dist/src/helpers/protoClasses.js +2 -3
  146. package/dist/src/helpers/protoClasses.js.map +1 -1
  147. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +21 -22
  148. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +18 -18
  149. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  150. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +36 -60
  151. package/dist/src/proto/packages/dht/protos/DhtRpc.js +34 -53
  152. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  153. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +11 -12
  154. package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -1
  155. package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
  156. package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +2 -1
  157. package/dist/src/transport/ITransport.d.ts +9 -1
  158. package/dist/src/transport/ITransport.js +5 -0
  159. package/dist/src/transport/ITransport.js.map +1 -1
  160. package/dist/src/transport/ListeningRpcCommunicator.js +1 -1
  161. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  162. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
  163. package/dist/src/transport/RoutingRpcCommunicator.js +16 -11
  164. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  165. package/jest.config.js +4 -1
  166. package/karma-setup.js +2 -0
  167. package/karma.config.js +11 -7
  168. package/package.json +6 -7
  169. package/protos/DhtRpc.proto +17 -23
  170. package/src/connection/ConnectionLockHandler.ts +15 -15
  171. package/src/connection/ConnectionLockRpcLocal.ts +8 -9
  172. package/src/connection/ConnectionLockRpcRemote.ts +7 -16
  173. package/src/connection/ConnectionManager.ts +58 -55
  174. package/src/connection/ConnectorFacade.ts +3 -0
  175. package/src/connection/ManagedConnection.ts +12 -30
  176. package/src/connection/connectivityChecker.ts +1 -0
  177. package/src/connection/simulator/Simulator.ts +5 -36
  178. package/src/connection/simulator/SimulatorConnector.ts +8 -8
  179. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -3
  180. package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -4
  181. package/src/connection/webrtc/WebrtcConnector.ts +11 -13
  182. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +16 -16
  183. package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +3 -13
  184. package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
  185. package/src/connection/websocket/ClientWebsocket.ts +1 -0
  186. package/src/connection/websocket/WebsocketConnector.ts +43 -56
  187. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +11 -13
  188. package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +4 -15
  189. package/src/connection/websocket/WebsocketServer.ts +14 -17
  190. package/src/dht/DhtNode.ts +67 -69
  191. package/src/dht/DhtNodeRpcLocal.ts +0 -1
  192. package/src/dht/DhtNodeRpcRemote.ts +13 -13
  193. package/src/dht/ExternalApiRpcLocal.ts +16 -6
  194. package/src/dht/ExternalApiRpcRemote.ts +5 -3
  195. package/src/dht/PeerManager.ts +73 -90
  196. package/src/dht/contact/Contact.ts +5 -4
  197. package/src/dht/contact/ContactList.ts +9 -9
  198. package/src/dht/contact/RandomContactList.ts +14 -14
  199. package/src/dht/contact/RpcRemote.ts +10 -7
  200. package/src/dht/contact/SortedContactList.ts +48 -45
  201. package/src/dht/discovery/DiscoverySession.ts +25 -25
  202. package/src/dht/discovery/PeerDiscovery.ts +16 -37
  203. package/src/dht/recursive-operation/RecursiveOperationManager.ts +240 -0
  204. package/src/dht/{find/FindRpcLocal.ts → recursive-operation/RecursiveOperationRpcLocal.ts} +9 -9
  205. package/src/dht/{routing/FindRpcRemote.ts → recursive-operation/RecursiveOperationRpcRemote.ts} +10 -10
  206. package/src/dht/recursive-operation/RecursiveOperationSession.ts +224 -0
  207. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +25 -0
  208. package/src/dht/{find/FindSessionRpcRemote.ts → recursive-operation/RecursiveOperationSessionRpcRemote.ts} +8 -8
  209. package/src/dht/routing/Router.ts +45 -64
  210. package/src/dht/routing/RouterRpcLocal.ts +7 -6
  211. package/src/dht/routing/RouterRpcRemote.ts +9 -10
  212. package/src/dht/routing/RoutingSession.ts +59 -68
  213. package/src/dht/store/LocalDataStore.ts +47 -66
  214. package/src/dht/store/StoreManager.ts +217 -0
  215. package/src/dht/store/StoreRpcLocal.ts +26 -302
  216. package/src/dht/store/StoreRpcRemote.ts +9 -11
  217. package/src/exports.ts +2 -0
  218. package/src/helpers/MapWithTtl.ts +71 -0
  219. package/src/helpers/PeerID.ts +5 -0
  220. package/src/helpers/nodeId.ts +20 -0
  221. package/src/helpers/peerIdFromPeerDescriptor.ts +5 -3
  222. package/src/helpers/protoClasses.ts +4 -6
  223. package/src/proto/packages/dht/protos/DhtRpc.client.ts +31 -32
  224. package/src/proto/packages/dht/protos/DhtRpc.server.ts +11 -12
  225. package/src/proto/packages/dht/protos/DhtRpc.ts +49 -80
  226. package/src/rpc-protocol/DhtCallContext.ts +2 -1
  227. package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
  228. package/src/transport/ITransport.ts +10 -1
  229. package/src/transport/ListeningRpcCommunicator.ts +1 -1
  230. package/src/transport/RoutingRpcCommunicator.ts +18 -12
  231. package/test/benchmark/Find.test.ts +8 -21
  232. package/test/benchmark/KademliaCorrectness.test.ts +11 -20
  233. package/test/benchmark/SortedContactListBenchmark.test.ts +9 -9
  234. package/test/benchmark/kademlia-simulation/Contact.ts +9 -8
  235. package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +2 -2
  236. package/test/benchmark/kademlia-simulation/SimulationNode.ts +17 -17
  237. package/test/end-to-end/Layer0-Layer1.test.ts +10 -14
  238. package/test/end-to-end/Layer0.test.ts +15 -18
  239. package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +7 -9
  240. package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +4 -10
  241. package/test/end-to-end/Layer0Webrtc.test.ts +5 -6
  242. package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -16
  243. package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +6 -13
  244. package/test/end-to-end/WebsocketConnectionRequest.test.ts +5 -6
  245. package/test/end-to-end/memory-leak.test.ts +6 -8
  246. package/test/integration/ConnectionLocking.test.ts +6 -13
  247. package/test/integration/ConnectionManager.test.ts +26 -43
  248. package/test/integration/DhtJoinPeerDiscovery.test.ts +5 -10
  249. package/test/integration/DhtNodeExternalAPI.test.ts +16 -22
  250. package/test/integration/DhtNodeRpcRemote.test.ts +13 -22
  251. package/test/integration/DhtRpc.test.ts +13 -18
  252. package/test/integration/Find.test.ts +10 -10
  253. package/test/integration/Layer1-scale.test.ts +17 -28
  254. package/test/integration/Mock-Layer1-Layer0.test.ts +25 -43
  255. package/test/integration/MultipleEntryPointJoining.test.ts +7 -7
  256. package/test/integration/ReplicateData.test.ts +28 -30
  257. package/test/integration/RouteMessage.test.ts +30 -27
  258. package/test/integration/RouterRpcRemote.test.ts +12 -18
  259. package/test/integration/RpcErrors.test.ts +8 -21
  260. package/test/integration/ScaleDownDht.test.ts +11 -10
  261. package/test/integration/SimultaneousConnections.test.ts +43 -67
  262. package/test/integration/Store.test.ts +23 -36
  263. package/test/integration/StoreAndDelete.test.ts +30 -50
  264. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +16 -37
  265. package/test/integration/StoreRpcRemote.test.ts +20 -30
  266. package/test/integration/WebrtcConnectionManagement.test.ts +3 -13
  267. package/test/integration/WebrtcConnectorRpc.test.ts +3 -9
  268. package/test/integration/WebsocketConnectionManagement.test.ts +7 -10
  269. package/test/integration/WebsocketConnectorRpc.test.ts +8 -17
  270. package/test/unit/ConnectivityHelpers.test.ts +9 -17
  271. package/test/unit/DuplicateDetector.test.ts +7 -4
  272. package/test/unit/LocalDataStore.test.ts +66 -77
  273. package/test/unit/PeerManager.test.ts +31 -0
  274. package/test/unit/RandomContactList.test.ts +13 -8
  275. package/test/unit/{Finder.test.ts → RecursiveOperationManager.test.ts} +38 -43
  276. package/test/unit/RecursiveOperationSession.test.ts +68 -0
  277. package/test/unit/Router.test.ts +15 -22
  278. package/test/unit/RoutingSession.test.ts +23 -25
  279. package/test/unit/SortedContactList.test.ts +41 -26
  280. package/test/unit/StoreManager.test.ts +132 -0
  281. package/test/unit/WebsocketConnector.test.ts +27 -35
  282. package/test/unit/customMatchers.test.ts +16 -0
  283. package/test/utils/FakeTransport.ts +44 -0
  284. package/test/utils/customMatchers.ts +70 -0
  285. package/test/utils/mock/MockRpcCommunicator.ts +7 -0
  286. package/test/utils/mock/Router.ts +3 -2
  287. package/test/utils/mock/mockDataEntry.ts +36 -0
  288. package/test/utils/utils.ts +49 -87
  289. package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
  290. package/dist/src/dht/find/FindRpcLocal.js.map +0 -1
  291. package/dist/src/dht/find/FindSession.d.ts +0 -44
  292. package/dist/src/dht/find/FindSession.js +0 -150
  293. package/dist/src/dht/find/FindSession.js.map +0 -1
  294. package/dist/src/dht/find/FindSessionRpcLocal.d.ts +0 -12
  295. package/dist/src/dht/find/FindSessionRpcLocal.js +0 -17
  296. package/dist/src/dht/find/FindSessionRpcLocal.js.map +0 -1
  297. package/dist/src/dht/find/FindSessionRpcRemote.d.ts +0 -6
  298. package/dist/src/dht/find/FindSessionRpcRemote.js +0 -21
  299. package/dist/src/dht/find/FindSessionRpcRemote.js.map +0 -1
  300. package/dist/src/dht/find/Finder.d.ts +0 -49
  301. package/dist/src/dht/find/Finder.js +0 -197
  302. package/dist/src/dht/find/Finder.js.map +0 -1
  303. package/dist/src/dht/routing/FindRpcRemote.d.ts +0 -6
  304. package/dist/src/dht/routing/FindRpcRemote.js.map +0 -1
  305. package/src/dht/find/FindSession.ts +0 -183
  306. package/src/dht/find/FindSessionRpcLocal.ts +0 -25
  307. package/src/dht/find/Finder.ts +0 -295
@@ -1,27 +1,27 @@
1
- import { PeerID, PeerIDKey } from '../../helpers/PeerID'
2
1
  import { ContactState, Events } from './ContactList'
3
2
  import { sortedIndexBy } from 'lodash'
4
3
  import EventEmitter from 'eventemitter3'
5
4
  import { getDistance } from '../PeerManager'
5
+ import { NodeID, areEqualNodeIds } from '../../helpers/nodeId'
6
6
 
7
7
  export interface SortedContactListConfig {
8
- referenceId: PeerID // all contacts in this list are in sorted by the distance to this ID
8
+ referenceId: NodeID // all contacts in this list are in sorted by the distance to this ID
9
9
  allowToContainReferenceId: boolean
10
10
  // TODO could maybe optimize this by removing the flag and then we'd check whether we have
11
11
  // any listeners before we emit the event
12
12
  emitEvents: boolean
13
13
  maxSize?: number
14
14
  // if set, the list can't contain any contacts which are futher away than this limit
15
- peerIdDistanceLimit?: PeerID
15
+ nodeIdDistanceLimit?: NodeID
16
16
  // if set, the list can't contain contacts with these ids
17
- excludedPeerIDs?: PeerID[]
17
+ excludedNodeIds?: Set<NodeID>
18
18
  }
19
19
 
20
- export class SortedContactList<C extends { getPeerId: () => PeerID }> extends EventEmitter<Events<C>> {
20
+ export class SortedContactList<C extends { getNodeId: () => NodeID }> extends EventEmitter<Events<C>> {
21
21
 
22
22
  private config: SortedContactListConfig
23
- private contactsById: Map<PeerIDKey, ContactState<C>> = new Map()
24
- private contactIds: PeerID[] = []
23
+ private contactsById: Map<NodeID, ContactState<C>> = new Map()
24
+ private contactIds: NodeID[] = []
25
25
 
26
26
  constructor(
27
27
  config: SortedContactListConfig
@@ -31,38 +31,39 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
31
31
  this.compareIds = this.compareIds.bind(this)
32
32
  }
33
33
 
34
- public getClosestContactId(): PeerID {
34
+ public getClosestContactId(): NodeID {
35
35
  return this.contactIds[0]
36
36
  }
37
37
 
38
- public getContactIds(): PeerID[] {
38
+ public getContactIds(): NodeID[] {
39
39
  return this.contactIds
40
40
  }
41
41
 
42
42
  public addContact(contact: C): void {
43
- if (this.config.excludedPeerIDs !== undefined
44
- && this.config.excludedPeerIDs.some((peerId) => contact.getPeerId().equals(peerId))) {
43
+ if (this.config.excludedNodeIds !== undefined && this.config.excludedNodeIds.has(contact.getNodeId())) {
45
44
  return
46
45
  }
47
46
 
48
- if ((!this.config.allowToContainReferenceId && this.config.referenceId.equals(contact.getPeerId())) ||
49
- (this.config.peerIdDistanceLimit !== undefined && this.compareIds(this.config.peerIdDistanceLimit, contact.getPeerId()) < 0)) {
47
+ if ((!this.config.allowToContainReferenceId && areEqualNodeIds(this.config.referenceId, contact.getNodeId())) ||
48
+ (this.config.nodeIdDistanceLimit !== undefined && this.compareIds(this.config.nodeIdDistanceLimit, contact.getNodeId()) < 0)) {
50
49
  return
51
50
  }
52
- if (!this.contactsById.has(contact.getPeerId().toKey())) {
51
+ if (!this.contactsById.has(contact.getNodeId())) {
53
52
  if ((this.config.maxSize === undefined) || (this.contactIds.length < this.config.maxSize)) {
54
- this.contactsById.set(contact.getPeerId().toKey(), new ContactState(contact))
53
+ this.contactsById.set(contact.getNodeId(), new ContactState(contact))
55
54
 
56
- const index = sortedIndexBy(this.contactIds, contact.getPeerId(), (id: PeerID) => { return this.distanceToReferenceId(id) })
57
- this.contactIds.splice(index, 0, contact.getPeerId())
58
- } else if (this.compareIds(this.contactIds[this.config.maxSize - 1], contact.getPeerId()) > 0) {
55
+ // eslint-disable-next-line max-len
56
+ const index = sortedIndexBy(this.contactIds, contact.getNodeId(), (id: NodeID) => { return this.distanceToReferenceId(id) })
57
+ this.contactIds.splice(index, 0, contact.getNodeId())
58
+ } else if (this.compareIds(this.contactIds[this.config.maxSize - 1], contact.getNodeId()) > 0) {
59
59
  const removedId = this.contactIds.pop()
60
- const removedContact = this.contactsById.get(removedId!.toKey())!.contact
61
- this.contactsById.delete(removedId!.toKey())
62
- this.contactsById.set(contact.getPeerId().toKey(), new ContactState(contact))
60
+ const removedContact = this.contactsById.get(removedId!)!.contact
61
+ this.contactsById.delete(removedId!)
62
+ this.contactsById.set(contact.getNodeId(), new ContactState(contact))
63
63
 
64
- const index = sortedIndexBy(this.contactIds, contact.getPeerId(), (id: PeerID) => { return this.distanceToReferenceId(id) })
65
- this.contactIds.splice(index, 0, contact.getPeerId())
64
+ // eslint-disable-next-line max-len
65
+ const index = sortedIndexBy(this.contactIds, contact.getNodeId(), (id: NodeID) => { return this.distanceToReferenceId(id) })
66
+ this.contactIds.splice(index, 0, contact.getNodeId())
66
67
  if (this.config.emitEvents) {
67
68
  this.emit(
68
69
  'contactRemoved',
@@ -85,26 +86,26 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
85
86
  contacts.forEach((contact) => this.addContact(contact))
86
87
  }
87
88
 
88
- public getContact(id: PeerID): ContactState<C> | undefined {
89
- return this.contactsById.get(id.toKey())
89
+ public getContact(id: NodeID): ContactState<C> | undefined {
90
+ return this.contactsById.get(id)
90
91
  }
91
92
 
92
- public setContacted(contactId: PeerID): void {
93
- if (this.contactsById.has(contactId.toKey())) {
94
- this.contactsById.get(contactId.toKey())!.contacted = true
93
+ public setContacted(contactId: NodeID): void {
94
+ if (this.contactsById.has(contactId)) {
95
+ this.contactsById.get(contactId)!.contacted = true
95
96
  }
96
97
  }
97
98
 
98
- public setActive(contactId: PeerID): void {
99
- if (this.contactsById.has(contactId.toKey())) {
100
- this.contactsById.get(contactId.toKey())!.active = true
99
+ public setActive(contactId: NodeID): void {
100
+ if (this.contactsById.has(contactId)) {
101
+ this.contactsById.get(contactId)!.active = true
101
102
  }
102
103
  }
103
104
 
104
105
  public getClosestContacts(limit?: number): C[] {
105
106
  const ret: C[] = []
106
107
  this.contactIds.forEach((contactId) => {
107
- const contact = this.contactsById.get(contactId.toKey())
108
+ const contact = this.contactsById.get(contactId)
108
109
  if (contact) {
109
110
  ret.push(contact.contact)
110
111
  }
@@ -119,7 +120,7 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
119
120
  public getUncontactedContacts(num: number): C[] {
120
121
  const ret: C[] = []
121
122
  for (const contactId of this.contactIds) {
122
- const contact = this.contactsById.get(contactId.toKey())
123
+ const contact = this.contactsById.get(contactId)
123
124
  if (contact && !contact.contacted) {
124
125
  ret.push(contact.contact)
125
126
  if (ret.length >= num) {
@@ -133,7 +134,7 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
133
134
  public getActiveContacts(limit?: number): C[] {
134
135
  const ret: C[] = []
135
136
  this.contactIds.forEach((contactId) => {
136
- const contact = this.contactsById.get(contactId.toKey())
137
+ const contact = this.contactsById.get(contactId)
137
138
  if (contact && contact.active) {
138
139
  ret.push(contact.contact)
139
140
  }
@@ -145,23 +146,25 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
145
146
  }
146
147
  }
147
148
 
148
- public compareIds(id1: PeerID, id2: PeerID): number {
149
+ public compareIds(id1: NodeID, id2: NodeID): number {
149
150
  const distance1 = this.distanceToReferenceId(id1)
150
151
  const distance2 = this.distanceToReferenceId(id2)
151
152
  return distance1 - distance2
152
153
  }
153
154
 
154
155
  // TODO inline this method?
155
- private distanceToReferenceId(id: PeerID): number {
156
- return getDistance(this.config.referenceId.value, id.value)
156
+ private distanceToReferenceId(id: NodeID): number {
157
+ // TODO maybe this class should store the referenceId also as UInt8Array so that we don't need to convert it here?
158
+ return getDistance(this.config.referenceId, id)
157
159
  }
158
160
 
159
- public removeContact(id: PeerID): boolean {
160
- if (this.contactsById.has(id.toKey())) {
161
- const removed = this.contactsById.get(id.toKey())!.contact
162
- const index = this.contactIds.findIndex((element) => element.equals(id))
161
+ public removeContact(id: NodeID): boolean {
162
+ if (this.contactsById.has(id)) {
163
+ const removed = this.contactsById.get(id)!.contact
164
+ // TODO use sortedIndexBy?
165
+ const index = this.contactIds.findIndex((nodeId) => areEqualNodeIds(nodeId, id))
163
166
  this.contactIds.splice(index, 1)
164
- this.contactsById.delete(id.toKey())
167
+ this.contactsById.delete(id)
165
168
  if (this.config.emitEvents) {
166
169
  this.emit(
167
170
  'contactRemoved',
@@ -174,12 +177,12 @@ export class SortedContactList<C extends { getPeerId: () => PeerID }> extends Ev
174
177
  return false
175
178
  }
176
179
 
177
- public isActive(id: PeerID): boolean {
178
- return this.contactsById.has(id.toKey()) ? this.contactsById.get(id.toKey())!.active : false
180
+ public isActive(id: NodeID): boolean {
181
+ return this.contactsById.has(id) ? this.contactsById.get(id)!.active : false
179
182
  }
180
183
 
181
184
  public getAllContacts(): C[] {
182
- return this.contactIds.map((peerId) => this.contactsById.get(peerId.toKey())!.contact)
185
+ return this.contactIds.map((nodeId) => this.contactsById.get(nodeId)!.contact)
183
186
  }
184
187
 
185
188
  public getSize(): number {
@@ -1,11 +1,11 @@
1
1
  import { Logger, runAndWaitForEvents3 } from '@streamr/utils'
2
2
  import EventEmitter from 'eventemitter3'
3
3
  import { v4 } from 'uuid'
4
- import { PeerID, PeerIDKey } from '../../helpers/PeerID'
5
4
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
6
5
  import { PeerManager, getDistance } from '../PeerManager'
7
6
  import { DhtNodeRpcRemote } from '../DhtNodeRpcRemote'
8
7
  import { getNodeIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
8
+ import { NodeID, getNodeIdFromBinary } from '../../helpers/nodeId'
9
9
 
10
10
  const logger = new Logger(module)
11
11
 
@@ -18,18 +18,16 @@ interface DiscoverySessionConfig {
18
18
  parallelism: number
19
19
  noProgressLimit: number
20
20
  peerManager: PeerManager
21
- // Note that contacted peers will be mutated by the DiscoverySession or other parallel sessions
22
- contactedPeers: Set<PeerIDKey>
23
21
  }
24
22
 
25
23
  export class DiscoverySession {
26
- public readonly sessionId = v4()
27
-
24
+
25
+ public readonly id = v4()
28
26
  private stopped = false
29
27
  private emitter = new EventEmitter<DiscoverySessionEvents>()
30
- private outgoingClosestPeersRequestsCounter = 0
31
28
  private noProgressCounter = 0
32
- private ongoingClosestPeersRequests: Set<string> = new Set()
29
+ private ongoingClosestPeersRequests: Set<NodeID> = new Set()
30
+ private contactedPeers: Set<NodeID> = new Set()
33
31
  private readonly config: DiscoverySessionConfig
34
32
 
35
33
  constructor(config: DiscoverySessionConfig) {
@@ -48,23 +46,22 @@ export class DiscoverySession {
48
46
  return []
49
47
  }
50
48
  logger.trace(`Getting closest peers from contact: ${getNodeIdFromPeerDescriptor(contact.getPeerDescriptor())}`)
51
- this.outgoingClosestPeersRequestsCounter++
52
- this.config.contactedPeers.add(contact.getPeerId().toKey())
49
+ this.contactedPeers.add(contact.getNodeId())
53
50
  const returnedContacts = await contact.getClosestPeers(this.config.targetId)
54
- this.config.peerManager.handlePeerActive(contact.getPeerId())
51
+ this.config.peerManager.handlePeerActive(contact.getNodeId())
55
52
  return returnedContacts
56
53
  }
57
54
 
58
- private onClosestPeersRequestSucceeded(peerId: PeerID, contacts: PeerDescriptor[]) {
59
- if (!this.ongoingClosestPeersRequests.has(peerId.toKey())) {
55
+ private onClosestPeersRequestSucceeded(nodeId: NodeID, contacts: PeerDescriptor[]) {
56
+ if (!this.ongoingClosestPeersRequests.has(nodeId)) {
60
57
  return
61
58
  }
62
- this.ongoingClosestPeersRequests.delete(peerId.toKey())
63
- const oldClosestNeighbor = this.config.peerManager.getClosestNeighborsTo(this.config.targetId, 1)[0]
64
- const oldClosestDistance = getDistance(this.config.targetId, oldClosestNeighbor.getPeerId().value)
59
+ this.ongoingClosestPeersRequests.delete(nodeId)
60
+ const oldClosestNeighbor = this.config.peerManager.getClosestNeighborsTo(getNodeIdFromBinary(this.config.targetId), 1)[0]
61
+ const oldClosestDistance = getDistance(getNodeIdFromBinary(this.config.targetId), oldClosestNeighbor.getNodeId())
65
62
  this.addNewContacts(contacts)
66
- const newClosestNeighbor = this.config.peerManager.getClosestNeighborsTo(this.config.targetId, 1)[0]
67
- const newClosestDistance = getDistance(this.config.targetId, newClosestNeighbor.getPeerId().value)
63
+ const newClosestNeighbor = this.config.peerManager.getClosestNeighborsTo(getNodeIdFromBinary(this.config.targetId), 1)[0]
64
+ const newClosestDistance = getDistance(getNodeIdFromBinary(this.config.targetId), newClosestNeighbor.getNodeId())
68
65
  if (newClosestDistance >= oldClosestDistance) {
69
66
  this.noProgressCounter++
70
67
  } else {
@@ -73,18 +70,22 @@ export class DiscoverySession {
73
70
  }
74
71
 
75
72
  private onClosestPeersRequestFailed(peer: DhtNodeRpcRemote) {
76
- if (!this.ongoingClosestPeersRequests.has(peer.getPeerId().toKey())) {
73
+ if (!this.ongoingClosestPeersRequests.has(peer.getNodeId())) {
77
74
  return
78
75
  }
79
- this.ongoingClosestPeersRequests.delete(peer.getPeerId().toKey())
80
- this.config.peerManager.handlePeerUnresponsive(peer.getPeerId())
76
+ this.ongoingClosestPeersRequests.delete(peer.getNodeId())
77
+ this.config.peerManager.handlePeerUnresponsive(peer.getNodeId())
81
78
  }
82
79
 
83
80
  private findMoreContacts(): void {
84
81
  if (this.stopped) {
85
82
  return
86
83
  }
87
- const uncontacted = this.config.peerManager.getClosestContactsTo(this.config.targetId, this.config.parallelism, this.config.contactedPeers)
84
+ const uncontacted = this.config.peerManager.getClosestContactsTo(
85
+ getNodeIdFromBinary(this.config.targetId),
86
+ this.config.parallelism,
87
+ this.contactedPeers
88
+ )
88
89
  if (uncontacted.length === 0 || this.noProgressCounter >= this.config.noProgressLimit) {
89
90
  this.emitter.emit('discoveryCompleted')
90
91
  this.stopped = true
@@ -94,20 +95,19 @@ export class DiscoverySession {
94
95
  if (this.ongoingClosestPeersRequests.size >= this.config.parallelism) {
95
96
  break
96
97
  }
97
- this.ongoingClosestPeersRequests.add(nextPeer.getPeerId().toKey())
98
+ this.ongoingClosestPeersRequests.add(nextPeer.getNodeId())
98
99
  // eslint-disable-next-line promise/catch-or-return
99
100
  this.getClosestPeersFromContact(nextPeer)
100
- .then((contacts) => this.onClosestPeersRequestSucceeded(nextPeer.getPeerId(), contacts))
101
+ .then((contacts) => this.onClosestPeersRequestSucceeded(nextPeer.getNodeId(), contacts))
101
102
  .catch(() => this.onClosestPeersRequestFailed(nextPeer))
102
103
  .finally(() => {
103
- this.outgoingClosestPeersRequestsCounter--
104
104
  this.findMoreContacts()
105
105
  })
106
106
  }
107
107
  }
108
108
 
109
109
  public async findClosestNodes(timeout: number): Promise<void> {
110
- if (this.config.peerManager.getNumberOfContacts(this.config.contactedPeers) === 0) {
110
+ if (this.config.peerManager.getNumberOfContacts(this.contactedPeers) === 0) {
111
111
  return
112
112
  }
113
113
  // TODO add abortController and signal it in stop()
@@ -7,7 +7,6 @@ import { ConnectionManager } from '../../connection/ConnectionManager'
7
7
  import { PeerManager } from '../PeerManager'
8
8
  import { createRandomNodeId } from '../../helpers/nodeId'
9
9
  import { ServiceID } from '../../types/ServiceID'
10
- import { PeerIDKey } from '../../helpers/PeerID'
11
10
 
12
11
  interface PeerDiscoveryConfig {
13
12
  localPeerDescriptor: PeerDescriptor
@@ -24,40 +23,19 @@ const logger = new Logger(module)
24
23
 
25
24
  export class PeerDiscovery {
26
25
 
27
- private readonly config: PeerDiscoveryConfig
28
26
  private ongoingDiscoverySessions: Map<string, DiscoverySession> = new Map()
29
27
  private rejoinOngoing = false
30
28
  private joinCalled = false
31
- private rejoinTimeoutRef?: NodeJS.Timeout
32
29
  private readonly abortController: AbortController
33
30
  private recoveryIntervalStarted = false
31
+ private readonly config: PeerDiscoveryConfig
34
32
 
35
33
  constructor(config: PeerDiscoveryConfig) {
36
34
  this.config = config
37
35
  this.abortController = new AbortController()
38
36
  }
39
37
 
40
- async joinDht(
41
- entryPoints: PeerDescriptor[],
42
- doAdditionalRandomPeerDiscovery = true,
43
- retry = true
44
- ): Promise<void> {
45
- const contactedPeers = new Set<PeerIDKey>()
46
- await Promise.all(entryPoints.map((entryPoint) => this.joinThroughEntryPoint(
47
- entryPoint,
48
- contactedPeers,
49
- doAdditionalRandomPeerDiscovery,
50
- retry
51
- )))
52
- }
53
-
54
- async joinThroughEntryPoint(
55
- entryPointDescriptor: PeerDescriptor,
56
- // Note that this set is mutated by DiscoverySession
57
- contactedPeers: Set<PeerIDKey>,
58
- doAdditionalRandomPeerDiscovery = true,
59
- retry = true
60
- ): Promise<void> {
38
+ async joinDht(entryPointDescriptor: PeerDescriptor, doAdditionalRandomPeerDiscovery = true, retry = true): Promise<void> {
61
39
  if (this.isStopped()) {
62
40
  return
63
41
  }
@@ -72,22 +50,21 @@ export class PeerDiscovery {
72
50
  this.config.connectionManager?.lockConnection(entryPointDescriptor, `${this.config.serviceId}::joinDht`)
73
51
  this.config.peerManager.handleNewPeers([entryPointDescriptor])
74
52
  const targetId = peerIdFromPeerDescriptor(this.config.localPeerDescriptor).value
75
- const sessions = [this.createSession(targetId, contactedPeers)]
53
+ const sessions = [this.createSession(targetId)]
76
54
  if (doAdditionalRandomPeerDiscovery) {
77
- sessions.push(this.createSession(createRandomNodeId(), contactedPeers))
55
+ sessions.push(this.createSession(createRandomNodeId()))
78
56
  }
79
57
  await this.runSessions(sessions, entryPointDescriptor, retry)
80
58
  this.config.connectionManager?.unlockConnection(entryPointDescriptor, `${this.config.serviceId}::joinDht`)
81
59
 
82
60
  }
83
61
 
84
- private createSession(targetId: Uint8Array, contactedPeers: Set<PeerIDKey>): DiscoverySession {
62
+ private createSession(targetId: Uint8Array): DiscoverySession {
85
63
  const sessionOptions = {
86
64
  targetId,
87
65
  parallelism: this.config.parallelism,
88
66
  noProgressLimit: this.config.joinNoProgressLimit,
89
- peerManager: this.config.peerManager,
90
- contactedPeers
67
+ peerManager: this.config.peerManager
91
68
  }
92
69
  return new DiscoverySession(sessionOptions)
93
70
  }
@@ -95,7 +72,7 @@ export class PeerDiscovery {
95
72
  private async runSessions(sessions: DiscoverySession[], entryPointDescriptor: PeerDescriptor, retry: boolean): Promise<void> {
96
73
  try {
97
74
  for (const session of sessions) {
98
- this.ongoingDiscoverySessions.set(session.sessionId, session)
75
+ this.ongoingDiscoverySessions.set(session.id, session)
99
76
  await session.findClosestNodes(this.config.joinTimeout)
100
77
  }
101
78
  } catch (_e) {
@@ -105,13 +82,14 @@ export class PeerDiscovery {
105
82
  if (this.config.peerManager.getNumberOfNeighbors() === 0) {
106
83
  if (retry) {
107
84
  // TODO should we catch possible promise rejection?
85
+ // TODO use config option or named constant?
108
86
  setAbortableTimeout(() => this.rejoinDht(entryPointDescriptor), 1000, this.abortController.signal)
109
87
  }
110
88
  } else {
111
89
  await this.ensureRecoveryIntervalIsRunning()
112
90
  }
113
91
  }
114
- sessions.forEach((session) => this.ongoingDiscoverySessions.delete(session.sessionId))
92
+ sessions.forEach((session) => this.ongoingDiscoverySessions.delete(session.id))
115
93
  }
116
94
  }
117
95
 
@@ -122,12 +100,13 @@ export class PeerDiscovery {
122
100
  logger.debug(`Rejoining DHT ${this.config.serviceId}`)
123
101
  this.rejoinOngoing = true
124
102
  try {
125
- await this.joinThroughEntryPoint(entryPoint, new Set())
103
+ await this.joinDht(entryPoint)
126
104
  logger.debug(`Rejoined DHT successfully ${this.config.serviceId}!`)
127
105
  } catch (err) {
128
106
  logger.warn(`Rejoining DHT ${this.config.serviceId} failed`)
129
107
  if (!this.isStopped()) {
130
108
  // TODO should we catch possible promise rejection?
109
+ // TODO use config option or named constant?
131
110
  setAbortableTimeout(() => this.rejoinDht(entryPoint), 5000, this.abortController.signal)
132
111
  }
133
112
  } finally {
@@ -138,6 +117,7 @@ export class PeerDiscovery {
138
117
  private async ensureRecoveryIntervalIsRunning(): Promise<void> {
139
118
  if (!this.recoveryIntervalStarted) {
140
119
  this.recoveryIntervalStarted = true
120
+ // TODO use config option or named constant?
141
121
  await scheduleAtInterval(() => this.fetchClosestPeersFromBucket(), 60000, true, this.abortController.signal)
142
122
  }
143
123
  }
@@ -146,7 +126,10 @@ export class PeerDiscovery {
146
126
  if (this.isStopped()) {
147
127
  return
148
128
  }
149
- const nodes = this.config.peerManager.getClosestNeighborsTo(this.config.localPeerDescriptor.nodeId, this.config.parallelism)
129
+ const nodes = this.config.peerManager.getClosestNeighborsTo(
130
+ getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor),
131
+ this.config.parallelism
132
+ )
150
133
  await Promise.allSettled(
151
134
  nodes.map(async (peer: DhtNodeRpcRemote) => {
152
135
  const contacts = await peer.getClosestPeers(this.config.localPeerDescriptor.nodeId!)
@@ -169,10 +152,6 @@ export class PeerDiscovery {
169
152
 
170
153
  public stop(): void {
171
154
  this.abortController.abort()
172
- if (this.rejoinTimeoutRef) {
173
- clearTimeout(this.rejoinTimeoutRef)
174
- this.rejoinTimeoutRef = undefined
175
- }
176
155
  this.ongoingDiscoverySessions.forEach((session) => {
177
156
  session.stop()
178
157
  })