@streamr/dht 101.1.2 → 102.0.0-beta.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 (346) hide show
  1. package/.eslintignore +1 -1
  2. package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
  3. package/dist/generated/google/protobuf/any.js.map +1 -0
  4. package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
  5. package/dist/generated/google/protobuf/empty.js.map +1 -0
  6. package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
  7. package/dist/generated/google/protobuf/timestamp.js.map +1 -0
  8. package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
  9. package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
  10. package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
  11. package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +16 -0
  12. package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +16 -2
  13. package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
  14. package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
  15. package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
  16. package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
  17. package/dist/package.json +11 -11
  18. package/dist/src/connection/Connection.d.ts +1 -1
  19. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
  20. package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
  21. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  22. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
  23. package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
  24. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  25. package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
  26. package/dist/src/connection/ConnectionLockStates.js +14 -0
  27. package/dist/src/connection/ConnectionLockStates.js.map +1 -1
  28. package/dist/src/connection/ConnectionManager.d.ts +8 -1
  29. package/dist/src/connection/ConnectionManager.js +78 -24
  30. package/dist/src/connection/ConnectionManager.js.map +1 -1
  31. package/dist/src/connection/ConnectionsView.d.ts +1 -1
  32. package/dist/src/connection/ConnectorFacade.d.ts +1 -1
  33. package/dist/src/connection/Handshaker.d.ts +1 -1
  34. package/dist/src/connection/Handshaker.js +2 -2
  35. package/dist/src/connection/Handshaker.js.map +1 -1
  36. package/dist/src/connection/ManagedConnection.d.ts +7 -1
  37. package/dist/src/connection/ManagedConnection.js +24 -1
  38. package/dist/src/connection/ManagedConnection.js.map +1 -1
  39. package/dist/src/connection/PendingConnection.d.ts +1 -1
  40. package/dist/src/connection/connectivityChecker.d.ts +1 -1
  41. package/dist/src/connection/connectivityChecker.js +2 -1
  42. package/dist/src/connection/connectivityChecker.js.map +1 -1
  43. package/dist/src/connection/connectivityRequestHandler.js +1 -1
  44. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  45. package/dist/src/connection/simulator/Simulator.d.ts +1 -1
  46. package/dist/src/connection/simulator/Simulator.js +2 -2
  47. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  48. package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
  49. package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
  50. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
  51. package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
  52. package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
  53. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  54. package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
  55. package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
  56. package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
  57. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
  58. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -6
  59. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  60. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
  61. package/dist/src/connection/webrtc/WebrtcConnector.js +9 -8
  62. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  63. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
  64. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
  65. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  66. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
  67. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +1 -0
  68. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
  69. package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
  70. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
  71. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -3
  72. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
  73. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
  74. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
  75. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
  76. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
  77. package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
  78. package/dist/src/connection/websocket/WebsocketServerConnector.js +7 -7
  79. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
  80. package/dist/src/dht/DhtNode.d.ts +4 -2
  81. package/dist/src/dht/DhtNode.js +17 -6
  82. package/dist/src/dht/DhtNode.js.map +1 -1
  83. package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
  84. package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
  85. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  86. package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
  87. package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
  88. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
  89. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  90. package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
  91. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  92. package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
  93. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  94. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  95. package/dist/src/dht/PeerManager.d.ts +1 -1
  96. package/dist/src/dht/PeerManager.js +10 -10
  97. package/dist/src/dht/PeerManager.js.map +1 -1
  98. package/dist/src/dht/contact/Contact.d.ts +1 -1
  99. package/dist/src/dht/contact/Contact.js +1 -1
  100. package/dist/src/dht/contact/Contact.js.map +1 -1
  101. package/dist/src/dht/contact/RingContactList.d.ts +1 -1
  102. package/dist/src/dht/contact/RingContactList.js +1 -1
  103. package/dist/src/dht/contact/RingContactList.js.map +1 -1
  104. package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
  105. package/dist/src/dht/contact/SortedContactList.js +1 -1
  106. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  107. package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
  108. package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
  109. package/dist/src/dht/discovery/DiscoverySession.js +3 -3
  110. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  111. package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -1
  112. package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
  113. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  114. package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
  115. package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
  116. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
  117. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
  118. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  119. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
  120. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
  121. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
  122. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
  123. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
  124. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
  125. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
  126. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
  127. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  128. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
  129. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
  130. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
  131. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
  132. package/dist/src/dht/routing/Router.d.ts +4 -1
  133. package/dist/src/dht/routing/Router.js +17 -9
  134. package/dist/src/dht/routing/Router.js.map +1 -1
  135. package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
  136. package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
  137. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  138. package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
  139. package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
  140. package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
  141. package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
  142. package/dist/src/dht/routing/RoutingSession.js +5 -6
  143. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  144. package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
  145. package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
  146. package/dist/src/dht/store/LocalDataStore.js +2 -2
  147. package/dist/src/dht/store/LocalDataStore.js.map +1 -1
  148. package/dist/src/dht/store/StoreManager.d.ts +2 -2
  149. package/dist/src/dht/store/StoreManager.js +8 -8
  150. package/dist/src/dht/store/StoreManager.js.map +1 -1
  151. package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
  152. package/dist/src/dht/store/StoreRpcLocal.js +4 -4
  153. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  154. package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
  155. package/dist/src/dht/store/StoreRpcRemote.js +7 -4
  156. package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
  157. package/dist/src/exports.d.ts +2 -2
  158. package/dist/src/exports.js +6 -6
  159. package/dist/src/exports.js.map +1 -1
  160. package/dist/src/helpers/Connectivity.d.ts +1 -1
  161. package/dist/src/helpers/Connectivity.js +1 -1
  162. package/dist/src/helpers/Connectivity.js.map +1 -1
  163. package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
  164. package/dist/src/helpers/createPeerDescriptor.js +2 -2
  165. package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
  166. package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
  167. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
  168. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
  169. package/dist/src/helpers/protoClasses.js +1 -1
  170. package/dist/src/helpers/protoClasses.js.map +1 -1
  171. package/dist/src/identifiers.d.ts +5 -5
  172. package/dist/src/identifiers.js +11 -11
  173. package/dist/src/identifiers.js.map +1 -1
  174. package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
  175. package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
  176. package/dist/src/transport/ITransport.d.ts +2 -1
  177. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
  178. package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
  179. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  180. package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
  181. package/{src/proto → generated}/google/protobuf/any.ts +11 -4
  182. package/{src/proto → generated}/google/protobuf/empty.ts +0 -1
  183. package/{src/proto → generated}/google/protobuf/timestamp.ts +9 -3
  184. package/{src/proto → generated}/packages/dht/protos/DhtRpc.client.ts +12 -0
  185. package/{src/proto → generated}/packages/dht/protos/DhtRpc.server.ts +5 -0
  186. package/{src/proto → generated}/packages/dht/protos/DhtRpc.ts +23 -1
  187. package/package.json +11 -11
  188. package/proto.sh +2 -3
  189. package/protos/DhtRpc.proto +5 -0
  190. package/src/connection/Connection.ts +1 -1
  191. package/src/connection/ConnectionLockRpcLocal.ts +16 -7
  192. package/src/connection/ConnectionLockRpcRemote.ts +18 -6
  193. package/src/connection/ConnectionLockStates.ts +18 -0
  194. package/src/connection/ConnectionManager.ts +92 -26
  195. package/src/connection/ConnectionsView.ts +1 -1
  196. package/src/connection/ConnectorFacade.ts +1 -1
  197. package/src/connection/Handshaker.ts +3 -3
  198. package/src/connection/ManagedConnection.ts +28 -3
  199. package/src/connection/PendingConnection.ts +1 -1
  200. package/src/connection/connectivityChecker.ts +2 -1
  201. package/src/connection/connectivityRequestHandler.ts +1 -1
  202. package/src/connection/simulator/Simulator.ts +4 -4
  203. package/src/connection/simulator/SimulatorConnection.ts +10 -10
  204. package/src/connection/simulator/SimulatorConnector.ts +5 -5
  205. package/src/connection/simulator/SimulatorTransport.ts +3 -2
  206. package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
  207. package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -9
  208. package/src/connection/webrtc/WebrtcConnector.ts +10 -8
  209. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
  210. package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
  211. package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
  212. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
  213. package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
  214. package/src/connection/websocket/WebsocketServerConnector.ts +8 -8
  215. package/src/dht/DhtNode.ts +21 -8
  216. package/src/dht/DhtNodeRpcLocal.ts +7 -7
  217. package/src/dht/DhtNodeRpcRemote.ts +5 -5
  218. package/src/dht/ExternalApiRpcLocal.ts +8 -8
  219. package/src/dht/ExternalApiRpcRemote.ts +6 -6
  220. package/src/dht/PeerManager.ts +12 -12
  221. package/src/dht/contact/Contact.ts +3 -3
  222. package/src/dht/contact/RingContactList.ts +3 -3
  223. package/src/dht/contact/RpcRemote.ts +1 -1
  224. package/src/dht/contact/SortedContactList.ts +2 -2
  225. package/src/dht/contact/ringIdentifiers.ts +1 -1
  226. package/src/dht/discovery/DiscoverySession.ts +5 -5
  227. package/src/dht/discovery/PeerDiscovery.ts +12 -12
  228. package/src/dht/discovery/RingDiscoverySession.ts +3 -3
  229. package/src/dht/recursive-operation/RecursiveOperationManager.ts +9 -9
  230. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
  231. package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
  232. package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
  233. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
  234. package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
  235. package/src/dht/routing/Router.ts +19 -10
  236. package/src/dht/routing/RouterRpcLocal.ts +7 -7
  237. package/src/dht/routing/RouterRpcRemote.ts +9 -9
  238. package/src/dht/routing/RoutingSession.ts +7 -8
  239. package/src/dht/routing/getPreviousPeer.ts +1 -1
  240. package/src/dht/store/LocalDataStore.ts +4 -4
  241. package/src/dht/store/StoreManager.ts +12 -12
  242. package/src/dht/store/StoreRpcLocal.ts +8 -8
  243. package/src/dht/store/StoreRpcRemote.ts +10 -7
  244. package/src/exports.ts +5 -5
  245. package/src/helpers/Connectivity.ts +1 -1
  246. package/src/helpers/createPeerDescriptor.ts +3 -3
  247. package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
  248. package/src/helpers/protoClasses.ts +1 -1
  249. package/src/identifiers.ts +7 -7
  250. package/src/rpc-protocol/DhtCallContext.ts +1 -1
  251. package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
  252. package/src/transport/ITransport.ts +2 -1
  253. package/src/transport/ListeningRpcCommunicator.ts +14 -6
  254. package/src/transport/RoutingRpcCommunicator.ts +2 -2
  255. package/test/benchmark/Find.test.ts +6 -6
  256. package/test/benchmark/KademliaCorrectness.test.ts +5 -5
  257. package/test/benchmark/RingCorrectness.test.ts +5 -5
  258. package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
  259. package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +1 -1
  260. package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
  261. package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
  262. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
  263. package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
  264. package/test/end-to-end/memory-leak.test.ts +4 -4
  265. package/test/integration/ConnectionLocking.test.ts +16 -15
  266. package/test/integration/ConnectionManager.test.ts +62 -6
  267. package/test/integration/ConnectivityChecking.test.ts +2 -1
  268. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
  269. package/test/integration/DhtNode.test.ts +4 -4
  270. package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
  271. package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
  272. package/test/integration/DhtRpc.test.ts +12 -13
  273. package/test/integration/Find.test.ts +5 -5
  274. package/test/integration/GeoIpConnectivityChecking.test.ts +2 -1
  275. package/test/integration/Layer1-scale.test.ts +2 -2
  276. package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
  277. package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
  278. package/test/integration/ReplicateData.test.ts +10 -11
  279. package/test/integration/RouteMessage.test.ts +9 -9
  280. package/test/integration/RouterRpcRemote.test.ts +7 -7
  281. package/test/integration/SimultaneousConnections.test.ts +13 -12
  282. package/test/integration/Store.test.ts +9 -9
  283. package/test/integration/StoreAndDelete.test.ts +10 -10
  284. package/test/integration/StoreOnDhtWithThreeNodes.test.ts +9 -9
  285. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
  286. package/test/integration/StoreRpcRemote.test.ts +10 -10
  287. package/test/integration/WebrtcConnectionManagement.test.ts +4 -3
  288. package/test/integration/WebrtcConnectorRpc.test.ts +9 -9
  289. package/test/integration/Websocket.test.ts +0 -2
  290. package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
  291. package/test/integration/WebsocketConnectionManagement.test.ts +8 -9
  292. package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +4 -3
  293. package/test/unit/ConnectionManager.test.ts +4 -3
  294. package/test/unit/ConnectivityHelpers.test.ts +1 -1
  295. package/test/unit/DiscoverySession.test.ts +6 -6
  296. package/test/unit/Handshaker.test.ts +1 -1
  297. package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
  298. package/test/unit/LocalDataStore.test.ts +21 -21
  299. package/test/unit/PeerManager.test.ts +13 -13
  300. package/test/unit/PendingConnection.test.ts +1 -1
  301. package/test/unit/ProtobufMessage.test.ts +1 -1
  302. package/test/unit/RandomContactList.test.ts +2 -2
  303. package/test/unit/RecursiveOperationManager.test.ts +3 -3
  304. package/test/unit/RecursiveOperationSession.test.ts +4 -4
  305. package/test/unit/Router.test.ts +6 -6
  306. package/test/unit/RoutingSession.test.ts +6 -6
  307. package/test/unit/SortedContactList.test.ts +5 -5
  308. package/test/unit/StoreManager.test.ts +10 -10
  309. package/test/unit/StoreRpcLocal.test.ts +9 -9
  310. package/test/unit/WebrtcConnection.test.ts +29 -0
  311. package/test/unit/WebsocketClientConnector.test.ts +1 -1
  312. package/test/unit/WebsocketServerConnector.test.ts +1 -1
  313. package/test/unit/connectivityRequestHandler.test.ts +1 -1
  314. package/test/unit/createPeerDescriptor.test.ts +4 -4
  315. package/test/unit/getClosestNodes.test.ts +5 -5
  316. package/test/utils/FakeConnectorFacade.ts +1 -1
  317. package/test/utils/FakeTransport.ts +12 -9
  318. package/test/utils/customMatchers.ts +3 -3
  319. package/test/utils/mock/MockConnectionsView.ts +1 -1
  320. package/test/utils/mock/MockRouter.ts +5 -1
  321. package/test/utils/mock/MockTransport.ts +6 -1
  322. package/test/utils/mock/mockDataEntry.ts +6 -6
  323. package/test/utils/topology.ts +3 -3
  324. package/test/utils/utils.ts +9 -9
  325. package/tsconfig.jest.json +2 -1
  326. package/tsconfig.node.json +1 -0
  327. package/dist/src/proto/google/protobuf/any.js.map +0 -1
  328. package/dist/src/proto/google/protobuf/empty.js.map +0 -1
  329. package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
  330. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
  331. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
  332. package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
  333. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
  334. package/dist/src/proto/tests.d.ts +0 -39
  335. package/dist/src/proto/tests.js +0 -34
  336. package/dist/src/proto/tests.js.map +0 -1
  337. package/src/proto/tests.ts +0 -52
  338. package/test/benchmark/any.test.ts +0 -28
  339. /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
  340. /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
  341. /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
  342. /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
  343. /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
  344. /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
  345. /package/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.ts +0 -0
  346. /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
@@ -1,9 +1,9 @@
1
- import { getNodeIdFromPeerDescriptor } from '../../identifiers'
1
+ import { toNodeId } from '../../identifiers'
2
2
  import {
3
3
  ReplicateDataRequest,
4
4
  StoreDataRequest
5
- } from '../../proto/packages/dht/protos/DhtRpc'
6
- import { StoreRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
5
+ } from '../../../generated/packages/dht/protos/DhtRpc'
6
+ import { StoreRpcClient } from '../../../generated/packages/dht/protos/DhtRpc.client'
7
7
  import { EXISTING_CONNECTION_TIMEOUT, RpcRemote } from '../contact/RpcRemote'
8
8
 
9
9
  export class StoreRpcRemote extends RpcRemote<StoreRpcClient> {
@@ -13,15 +13,18 @@ export class StoreRpcRemote extends RpcRemote<StoreRpcClient> {
13
13
  try {
14
14
  await this.getClient().storeData(request, options)
15
15
  } catch (err) {
16
- const to = getNodeIdFromPeerDescriptor(this.getPeerDescriptor())
17
- const from = getNodeIdFromPeerDescriptor(this.getLocalPeerDescriptor())
16
+ const to = toNodeId(this.getPeerDescriptor())
17
+ const from = toNodeId(this.getLocalPeerDescriptor())
18
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
18
19
  throw new Error(`Could not store data to ${to} from ${from} ${err}`)
19
20
  }
20
21
  }
21
22
 
22
- async replicateData(request: ReplicateDataRequest): Promise<void> {
23
+ async replicateData(request: ReplicateDataRequest, connect: boolean): Promise<void> {
23
24
  const options = this.formDhtRpcOptions({
24
- timeout: EXISTING_CONNECTION_TIMEOUT
25
+ timeout: EXISTING_CONNECTION_TIMEOUT,
26
+ notification: true,
27
+ connect
25
28
  })
26
29
  return this.getClient().replicateData(request, options)
27
30
  }
package/src/exports.ts CHANGED
@@ -4,7 +4,7 @@ export { RoutingRpcCommunicator } from './transport/RoutingRpcCommunicator'
4
4
  export { Simulator, LatencyType } from './connection/simulator/Simulator'
5
5
  export { SimulatorTransport } from './connection/simulator/SimulatorTransport'
6
6
  export { getRandomRegion, getRegionDelayMatrix } from './connection/simulator/pings'
7
- export { PeerDescriptor, Message, NodeType, DataEntry } from './proto/packages/dht/protos/DhtRpc'
7
+ export { PeerDescriptor, Message, NodeType, DataEntry } from '../generated/packages/dht/protos/DhtRpc'
8
8
  export { ITransport, TransportEvents } from './transport/ITransport'
9
9
  export { ConnectionManager, ConnectionLocker, PortRange, TlsCertificate } from './connection/ConnectionManager'
10
10
  export { ConnectionsView } from './connection/ConnectionsView'
@@ -25,9 +25,9 @@ export { createOutgoingHandshaker } from './connection/Handshaker'
25
25
  export {
26
26
  DhtAddress,
27
27
  DhtAddressRaw,
28
- getDhtAddressFromRaw,
29
- getRawFromDhtAddress,
30
- createRandomDhtAddress,
28
+ toDhtAddress,
29
+ toDhtAddressRaw,
30
+ randomDhtAddress,
31
31
  areEqualPeerDescriptors,
32
- getNodeIdFromPeerDescriptor
32
+ toNodeId
33
33
  } from './identifiers'
@@ -1,5 +1,5 @@
1
1
  import { ConnectionType } from '../connection/IConnection'
2
- import { ConnectivityMethod, NodeType, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
2
+ import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
3
3
  import { isPrivateIPv4 } from './AddressTools'
4
4
 
5
5
  export const canOpenConnectionFromBrowser = (websocketServer: ConnectivityMethod): boolean => {
@@ -5,12 +5,12 @@ import {
5
5
  import crypto from 'crypto'
6
6
  import { isBrowserEnvironment } from '../helpers/browser/isBrowserEnvironment'
7
7
  import { createPeerDescriptorSignaturePayload } from '../helpers/createPeerDescriptorSignaturePayload'
8
- import { DhtAddress, DhtAddressRaw, getRawFromDhtAddress } from '../identifiers'
8
+ import { DhtAddress, DhtAddressRaw, toDhtAddressRaw } from '../identifiers'
9
9
  import {
10
10
  ConnectivityResponse,
11
11
  NodeType,
12
12
  PeerDescriptor
13
- } from '../proto/packages/dht/protos/DhtRpc'
13
+ } from '../../generated/packages/dht/protos/DhtRpc'
14
14
 
15
15
  const calculateNodeIdRaw = (ipAddress: number, privateKey: Uint8Array): DhtAddressRaw => {
16
16
  // nodeId is calculated as
@@ -34,7 +34,7 @@ export const createPeerDescriptor = (connectivityResponse: ConnectivityResponse,
34
34
  const publicKey = crypto.randomBytes(20) // TODO calculate publicKey from privateKey
35
35
  let nodeIdRaw: DhtAddressRaw
36
36
  if (nodeId !== undefined) {
37
- nodeIdRaw = getRawFromDhtAddress(nodeId)
37
+ nodeIdRaw = toDhtAddressRaw(nodeId)
38
38
  } else {
39
39
  nodeIdRaw = calculateNodeIdRaw(connectivityResponse.ipAddress, privateKey)
40
40
  }
@@ -1,4 +1,4 @@
1
- import { ConnectivityMethod, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
1
+ import { ConnectivityMethod, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
2
2
 
3
3
  function convertUnsignedIntegerToBuffer(number: number): Buffer {
4
4
  const buffer = Buffer.alloc(4)
@@ -26,7 +26,7 @@ import {
26
26
  UnlockRequest,
27
27
  LockResponse
28
28
 
29
- } from '../proto/packages/dht/protos/DhtRpc'
29
+ } from '../../generated/packages/dht/protos/DhtRpc'
30
30
 
31
31
  export const protoClasses: Array<IMessageType<any>> = [
32
32
  ClosestPeersRequest,
@@ -1,6 +1,6 @@
1
1
  import { BrandedString, areEqualBinaries, binaryToHex, hexToBinary } from '@streamr/utils'
2
2
  import crypto from 'crypto'
3
- import { PeerDescriptor } from './proto/packages/dht/protos/DhtRpc'
3
+ import { PeerDescriptor } from '../generated/packages/dht/protos/DhtRpc'
4
4
 
5
5
  // https://www.scs.stanford.edu/~dm/home/papers/kpos.pdf
6
6
  export const KADEMLIA_ID_LENGTH_IN_BYTES = 20
@@ -8,22 +8,22 @@ export const KADEMLIA_ID_LENGTH_IN_BYTES = 20
8
8
  export type DhtAddress = BrandedString<'DhtAddress'>
9
9
  export type DhtAddressRaw = Uint8Array
10
10
 
11
- export const getDhtAddressFromRaw = (raw: DhtAddressRaw): DhtAddress => {
11
+ export const toDhtAddress = (raw: DhtAddressRaw): DhtAddress => {
12
12
  return binaryToHex(raw) as unknown as DhtAddress
13
13
  }
14
14
 
15
- export const getRawFromDhtAddress = (address: DhtAddress): DhtAddressRaw => {
15
+ export const toDhtAddressRaw = (address: DhtAddress): DhtAddressRaw => {
16
16
  return hexToBinary(address) as unknown as DhtAddressRaw
17
17
  }
18
18
 
19
- export const getNodeIdFromPeerDescriptor = (peerDescriptor: PeerDescriptor): DhtAddress => {
20
- return getDhtAddressFromRaw(peerDescriptor.nodeId)
19
+ export const toNodeId = (peerDescriptor: PeerDescriptor): DhtAddress => {
20
+ return toDhtAddress(peerDescriptor.nodeId)
21
21
  }
22
22
 
23
23
  export const areEqualPeerDescriptors = (peerDescriptor1: PeerDescriptor, peerDescriptor2: PeerDescriptor): boolean => {
24
24
  return areEqualBinaries(peerDescriptor1.nodeId, peerDescriptor2.nodeId)
25
25
  }
26
26
 
27
- export const createRandomDhtAddress = (): DhtAddress => {
28
- return getDhtAddressFromRaw(crypto.randomBytes(KADEMLIA_ID_LENGTH_IN_BYTES))
27
+ export const randomDhtAddress = (): DhtAddress => {
28
+ return toDhtAddress(crypto.randomBytes(KADEMLIA_ID_LENGTH_IN_BYTES))
29
29
  }
@@ -1,5 +1,5 @@
1
1
  import { ProtoCallContext } from '@streamr/proto-rpc'
2
- import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
2
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
3
3
  import { DhtRpcOptions } from './DhtRpcOptions'
4
4
 
5
5
  export class DhtCallContext extends ProtoCallContext implements DhtRpcOptions {
@@ -1,5 +1,5 @@
1
1
  import { ProtoRpcOptions } from '@streamr/proto-rpc'
2
- import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
2
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
3
3
 
4
4
  export interface DhtRpcOptions extends ProtoRpcOptions {
5
5
  targetDescriptor?: PeerDescriptor
@@ -1,4 +1,4 @@
1
- import { Message, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
1
+ import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
2
2
 
3
3
  export interface TransportEvents {
4
4
  disconnected: (peerDescriptor: PeerDescriptor, gracefulLeave: boolean) => void
@@ -33,4 +33,5 @@ export interface ITransport {
33
33
  send(msg: Message, opts?: SendOptions): Promise<void>
34
34
  getLocalPeerDescriptor(): PeerDescriptor
35
35
  stop(): void | Promise<void>
36
+ getDiagnosticInfo(): Record<string, unknown>
36
37
  }
@@ -1,24 +1,32 @@
1
1
  import { ITransport } from './ITransport'
2
2
  import { RoutingRpcCommunicator } from './RoutingRpcCommunicator'
3
- import { RpcCommunicatorOptions } from '@streamr/proto-rpc'
4
- import { Message } from '../proto/packages/dht/protos/DhtRpc'
3
+ import { RpcCommunicatorOptions, RpcError } from '@streamr/proto-rpc'
4
+ import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
5
5
  import { ServiceID } from '../types/ServiceID'
6
+ import { areEqualPeerDescriptors } from '../identifiers'
6
7
 
7
8
  export class ListeningRpcCommunicator extends RoutingRpcCommunicator {
8
9
  private readonly transport: ITransport
9
- private readonly listener: (msg: Message) => void
10
+ private readonly messageListener: (msg: Message) => void
11
+ private readonly disconnectedListener: (peerDescriptor: PeerDescriptor) => void
10
12
 
11
13
  constructor(ownServiceId: ServiceID, transport: ITransport, options?: RpcCommunicatorOptions) {
12
14
  super(ownServiceId, (msg, opts) => transport.send(msg, opts), options)
13
- this.listener = (msg: Message) => {
15
+ this.messageListener = (msg: Message) => {
14
16
  this.handleMessageFromPeer(msg)
15
17
  }
18
+ this.disconnectedListener = (peerDescriptor: PeerDescriptor) => {
19
+ const requests = this.getRequestIds((request) => areEqualPeerDescriptors(peerDescriptor, request.getCallContext().targetDescriptor!))
20
+ requests.forEach((id) => this.handleClientError(id, new RpcError.Disconnected('Peer disconnected')))
21
+ }
16
22
  this.transport = transport
17
- transport.on('message', this.listener)
23
+ transport.on('message', this.messageListener)
24
+ transport.on('disconnected', this.disconnectedListener)
18
25
  }
19
26
 
20
27
  destroy(): void {
21
- this.transport.off('message', this.listener)
28
+ this.transport.off('message', this.messageListener)
29
+ this.transport.off('disconnected', this.disconnectedListener)
22
30
  this.stop()
23
31
  }
24
32
  }
@@ -1,8 +1,8 @@
1
- import { Message, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
1
+ import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
2
2
  import { v4 } from 'uuid'
3
3
  import { RpcCommunicator, RpcCommunicatorOptions } from '@streamr/proto-rpc'
4
4
  import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
5
- import { RpcMessage } from '../proto/packages/proto-rpc/protos/ProtoRpc'
5
+ import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
6
6
  import { ServiceID } from '../types/ServiceID'
7
7
  import { DEFAULT_SEND_OPTIONS, SendOptions } from './ITransport'
8
8
 
@@ -6,7 +6,7 @@ import { execSync } from 'child_process'
6
6
  import fs from 'fs'
7
7
  import { Logger, wait } from '@streamr/utils'
8
8
  import { debugVars } from '../../src/helpers/debugHelpers'
9
- import { getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
9
+ import { toDhtAddress, toNodeId } from '../../src/identifiers'
10
10
 
11
11
  const logger = new Logger(module)
12
12
 
@@ -26,10 +26,10 @@ describe('Find correctness', () => {
26
26
  beforeEach(async () => {
27
27
 
28
28
  nodes = []
29
- entryPoint = await createMockConnectionDhtNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[0].data)), undefined)
29
+ entryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), undefined)
30
30
 
31
31
  for (let i = 1; i < NUM_NODES; i++) {
32
- const node = await createMockConnectionDhtNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[i].data)), undefined)
32
+ const node = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)), undefined)
33
33
  nodes.push(node)
34
34
  }
35
35
  })
@@ -55,7 +55,7 @@ describe('Find correctness', () => {
55
55
  debugVars['waiting'] = false
56
56
  logger.info('waiting over')
57
57
 
58
- nodes.forEach((node) => logger.info(getNodeIdFromPeerDescriptor(node.getLocalPeerDescriptor()) + ': connections:' +
58
+ nodes.forEach((node) => logger.info(toNodeId(node.getLocalPeerDescriptor()) + ': connections:' +
59
59
  node.getConnectionsView().getConnectionCount() + ', kbucket: ' + node.getNeighborCount()
60
60
  + ', localLocked: ' + node.getLocalLockedConnectionCount()
61
61
  + ', remoteLocked: ' + node.getRemoteLockedConnectionCount()
@@ -63,10 +63,10 @@ describe('Find correctness', () => {
63
63
 
64
64
  logger.info('starting find')
65
65
  const targetId = Uint8Array.from(dhtIds[9].data)
66
- const closestNodes = await nodes[159].findClosestNodesFromDht(getDhtAddressFromRaw(targetId))
66
+ const closestNodes = await nodes[159].findClosestNodesFromDht(toDhtAddress(targetId))
67
67
  logger.info('find over')
68
68
  expect(closestNodes).toBeGreaterThanOrEqual(5)
69
- expect(getDhtAddressFromRaw(targetId)).toEqual(getNodeIdFromPeerDescriptor(closestNodes[0]))
69
+ expect(toDhtAddress(targetId)).toEqual(toNodeId(closestNodes[0]))
70
70
 
71
71
  }, 180000)
72
72
  })
@@ -4,7 +4,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
4
4
  import { createMockConnectionDhtNode } from '../utils/utils'
5
5
  import { execSync } from 'child_process'
6
6
  import fs from 'fs'
7
- import { DhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
7
+ import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
8
8
  import { Logger } from '@streamr/utils'
9
9
 
10
10
  const logger = new Logger(module)
@@ -28,12 +28,12 @@ describe('Kademlia correctness', () => {
28
28
 
29
29
  beforeEach(async () => {
30
30
  nodes = []
31
- entryPoint = await createMockConnectionDhtNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[0].data)), 8)
31
+ entryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), 8)
32
32
  nodes.push(entryPoint)
33
33
  nodeIndicesById[entryPoint.getNodeId()] = 0
34
34
 
35
35
  for (let i = 1; i < NUM_NODES; i++) {
36
- const node = await createMockConnectionDhtNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[i].data)))
36
+ const node = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)))
37
37
  nodeIndicesById[node.getNodeId()] = i
38
38
  nodes.push(node)
39
39
  }
@@ -68,7 +68,7 @@ describe('Kademlia correctness', () => {
68
68
  groundTruthString += groundTruth[i + ''][j].name + ','
69
69
  }
70
70
 
71
- const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => getNodeIdFromPeerDescriptor(p))
71
+ const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => toNodeId(p))
72
72
 
73
73
  let kadString = 'kademliaNeighbors: '
74
74
  kademliaNeighbors.forEach((neighbor) => {
@@ -84,7 +84,7 @@ describe('Kademlia correctness', () => {
84
84
  correctNeighbors++
85
85
  }
86
86
  } catch {
87
- console.error('Node ' + getNodeIdFromPeerDescriptor(nodes[i].getLocalPeerDescriptor()) + ' had only '
87
+ console.error('Node ' + toNodeId(nodes[i].getLocalPeerDescriptor()) + ' had only '
88
88
  + kademliaNeighbors.length + ' kademlia neighbors')
89
89
  }
90
90
  if (correctNeighbors === 0) {
@@ -4,7 +4,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
4
4
  import { createMockRingNode } from '../utils/utils'
5
5
  import { execSync } from 'child_process'
6
6
  import fs from 'fs'
7
- import { DhtAddress, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
7
+ import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
8
8
  import { Logger } from '@streamr/utils'
9
9
  import { getRingIdRawFromPeerDescriptor } from '../../src/dht/contact/ringIdentifiers'
10
10
 
@@ -43,12 +43,12 @@ describe('Ring correctness', () => {
43
43
  beforeEach(async () => {
44
44
  jest.setTimeout(60000)
45
45
  nodes = []
46
- entryPoint = await createMockRingNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[0].data)), regions[0])
46
+ entryPoint = await createMockRingNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), regions[0])
47
47
  nodes.push(entryPoint)
48
48
  nodeIndicesById[entryPoint.getNodeId()] = 0
49
49
 
50
50
  for (let i = 1; i < NUM_NODES; i++) {
51
- const node = await createMockRingNode(simulator, getDhtAddressFromRaw(Uint8Array.from(dhtIds[i].data)), regions[i + 1])
51
+ const node = await createMockRingNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)), regions[i + 1])
52
52
  nodeIndicesById[node.getNodeId()] = i
53
53
  nodes.push(node)
54
54
  }
@@ -111,7 +111,7 @@ describe('Ring correctness', () => {
111
111
  groundTruthString += groundTruth[i + ''][j].name + ','
112
112
  }
113
113
 
114
- const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => getNodeIdFromPeerDescriptor(p))
114
+ const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => toNodeId(p))
115
115
 
116
116
  let kadString = 'kademliaNeighbors: '
117
117
  kademliaNeighbors.forEach((neighbor) => {
@@ -127,7 +127,7 @@ describe('Ring correctness', () => {
127
127
  correctNeighbors++
128
128
  }
129
129
  } catch {
130
- console.error('Node ' + getNodeIdFromPeerDescriptor(nodes[i].getLocalPeerDescriptor()) + ' had only '
130
+ console.error('Node ' + toNodeId(nodes[i].getLocalPeerDescriptor()) + ' had only '
131
131
  + kademliaNeighbors.length + ' kademlia neighbors')
132
132
  }
133
133
  if (correctNeighbors === 0) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import KBucket from 'k-bucket'
4
4
  import { SortedContactList } from '../../src/dht/contact/SortedContactList'
5
- import { DhtAddress, DhtAddressRaw, createRandomDhtAddress, getRawFromDhtAddress } from '../../src/identifiers'
5
+ import { DhtAddress, DhtAddressRaw, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
6
6
 
7
7
  const NUM_ADDS = 1000
8
8
 
@@ -13,8 +13,8 @@ interface Item {
13
13
  }
14
14
 
15
15
  const createRandomItem = (index: number): Item => {
16
- const nodeId = createRandomDhtAddress()
17
- const nodeIdRaw = getRawFromDhtAddress(nodeId)
16
+ const nodeId = randomDhtAddress()
17
+ const nodeIdRaw = toDhtAddressRaw(nodeId)
18
18
  return {
19
19
  getNodeId: () => nodeId,
20
20
  id: nodeIdRaw,
@@ -38,7 +38,7 @@ describe('SortedContactListBenchmark', () => {
38
38
  randomIds.push(createRandomItem(i))
39
39
  }
40
40
  const list = new SortedContactList({
41
- referenceId: createRandomDhtAddress(),
41
+ referenceId: randomDhtAddress(),
42
42
  allowToContainReferenceId: true
43
43
  })
44
44
 
@@ -48,7 +48,7 @@ describe('SortedContactListBenchmark', () => {
48
48
  }
49
49
  console.timeEnd('SortedContactList.addContact()')
50
50
 
51
- const kBucket = new KBucket<Item>({ localNodeId: getRawFromDhtAddress(createRandomDhtAddress()) })
51
+ const kBucket = new KBucket<Item>({ localNodeId: toDhtAddressRaw(randomDhtAddress()) })
52
52
  console.time('KBucket.add()')
53
53
  for (let i = 0; i < NUM_ADDS; i++) {
54
54
  kBucket.add(randomIds[i])
@@ -64,14 +64,14 @@ describe('SortedContactListBenchmark', () => {
64
64
 
65
65
  console.time('kBucket closest()')
66
66
  for (let i = 0; i < NUM_ADDS; i++) {
67
- kBucket.closest(getRawFromDhtAddress(createRandomDhtAddress()), 20)
67
+ kBucket.closest(toDhtAddressRaw(randomDhtAddress()), 20)
68
68
  }
69
69
  console.timeEnd('kBucket closest()')
70
70
 
71
71
  console.time('SortedContactList.getClosestContacts()')
72
72
  for (let i = 0; i < NUM_ADDS; i++) {
73
73
  const closest = new SortedContactList<Item>({
74
- referenceId: createRandomDhtAddress(),
74
+ referenceId: randomDhtAddress(),
75
75
  allowToContainReferenceId: true
76
76
  })
77
77
 
@@ -84,7 +84,7 @@ describe('SortedContactListBenchmark', () => {
84
84
  console.time('SortedContactList.getClosestContacts() and addContacts()')
85
85
  for (let i = 0; i < NUM_ADDS; i++) {
86
86
  const closest = new SortedContactList<Item>({
87
- referenceId: createRandomDhtAddress(),
87
+ referenceId: randomDhtAddress(),
88
88
  allowToContainReferenceId: true
89
89
  })
90
90
 
@@ -97,10 +97,10 @@ describe('SortedContactListBenchmark', () => {
97
97
  const shuffled = shuffleArray(kBucket.toArray())
98
98
  console.time('kbucket add and closest')
99
99
  for (let i = 0; i < NUM_ADDS; i++) {
100
- const bucket2 = new KBucket<Item>({ localNodeId: getRawFromDhtAddress(createRandomDhtAddress()) })
100
+ const bucket2 = new KBucket<Item>({ localNodeId: toDhtAddressRaw(randomDhtAddress()) })
101
101
 
102
102
  shuffled.forEach((contact) => bucket2.add(contact))
103
- bucket2.closest(getRawFromDhtAddress(createRandomDhtAddress()), 20)
103
+ bucket2.closest(toDhtAddressRaw(randomDhtAddress()), 20)
104
104
  }
105
105
  console.timeEnd('kbucket add and closest')
106
106
 
@@ -1,4 +1,4 @@
1
- import { ConnectivityResponse, PeerDescriptor } from '../../../src/proto/packages/dht/protos/DhtRpc'
1
+ import { ConnectivityResponse, PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
2
2
  import { createPeerDescriptor } from '../../../src/helpers/createPeerDescriptor'
3
3
  import { NatType } from '../../../src/connection/ConnectionManager'
4
4
  import { ipv4ToNumber, Logger } from '@streamr/utils'
@@ -1,5 +1,5 @@
1
1
  import { DhtNode } from '../../src/dht/DhtNode'
2
- import { createRandomDhtAddress, getNodeIdFromPeerDescriptor } from '../../src/identifiers'
2
+ import { randomDhtAddress, toNodeId } from '../../src/identifiers'
3
3
  import { createMockPeerDescriptor } from '../utils/utils'
4
4
 
5
5
  describe('Layer 1 on Layer 0 with mocked connections', () => {
@@ -26,25 +26,25 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
26
26
 
27
27
  layer0EntryPoint = new DhtNode({ peerDescriptor: entrypointDescriptor, websocketServerEnableTls: false })
28
28
 
29
- const layer0Node1Id = createRandomDhtAddress()
29
+ const layer0Node1Id = randomDhtAddress()
30
30
  layer0Node1 = new DhtNode({
31
31
  nodeId: layer0Node1Id,
32
32
  entryPoints: [entrypointDescriptor]
33
33
  })
34
34
 
35
- const layer0Node2Id = createRandomDhtAddress()
35
+ const layer0Node2Id = randomDhtAddress()
36
36
  layer0Node2 = new DhtNode({
37
37
  nodeId: layer0Node2Id,
38
38
  entryPoints: [entrypointDescriptor]
39
39
  })
40
40
 
41
- const layer0Node3Id = createRandomDhtAddress()
41
+ const layer0Node3Id = randomDhtAddress()
42
42
  layer0Node3 = new DhtNode({
43
43
  nodeId: layer0Node3Id,
44
44
  entryPoints: [entrypointDescriptor]
45
45
  })
46
46
 
47
- const layer0Node4Id = createRandomDhtAddress()
47
+ const layer0Node4Id = randomDhtAddress()
48
48
  layer0Node4 = new DhtNode({
49
49
  nodeId: layer0Node4Id,
50
50
  entryPoints: [entrypointDescriptor]
@@ -57,7 +57,7 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
57
57
  await layer0Node4.start()
58
58
 
59
59
  layer1EntryPoint = new DhtNode({
60
- nodeId: getNodeIdFromPeerDescriptor(entrypointDescriptor),
60
+ nodeId: toNodeId(entrypointDescriptor),
61
61
  transport: layer0EntryPoint,
62
62
  connectionsView: layer0EntryPoint.getConnectionsView(),
63
63
  serviceId: 'layer1'
@@ -1,9 +1,9 @@
1
1
  import { areEqualBinaries, waitForEvent3 } from '@streamr/utils'
2
2
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
3
3
  import { DhtNode } from '../../src/dht/DhtNode'
4
- import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
4
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
5
5
  import { createMockPeerDescriptor } from '../utils/utils'
6
- import { getNodeIdFromPeerDescriptor } from '../../src/exports'
6
+ import { toNodeId } from '../../src/exports'
7
7
 
8
8
  describe('Layer0 with WebRTC connections', () => {
9
9
 
@@ -64,8 +64,8 @@ describe('Layer0 with WebRTC connections', () => {
64
64
  node2.joinDht([epPeerDescriptor]),
65
65
  node1.joinDht([epPeerDescriptor])
66
66
  ])
67
- const nodeId1 = getNodeIdFromPeerDescriptor(node1.getLocalPeerDescriptor())
68
- const nodeId2 = getNodeIdFromPeerDescriptor(node2.getLocalPeerDescriptor())
67
+ const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
68
+ const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
69
69
  expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
70
70
  expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
71
71
  }, 60000)
@@ -77,8 +77,8 @@ describe('Layer0 with WebRTC connections', () => {
77
77
  node3.joinDht([epPeerDescriptor]),
78
78
  node4.joinDht([epPeerDescriptor])
79
79
  ])
80
- const nodeId1 = getNodeIdFromPeerDescriptor(node1.getLocalPeerDescriptor())
81
- const nodeId2 = getNodeIdFromPeerDescriptor(node2.getLocalPeerDescriptor())
80
+ const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
81
+ const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
82
82
  expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
83
83
  expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
84
84
  })
@@ -1,5 +1,5 @@
1
1
  import { DhtNode } from '../../src/dht/DhtNode'
2
- import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
2
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
3
3
  import os from 'os'
4
4
 
5
5
  describe('Failed autocertification', () => {
@@ -1,4 +1,4 @@
1
- import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
1
+ import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
2
2
  import { DhtNode } from '../../src/dht/DhtNode'
3
3
  import { ConnectionManager } from '../../src/connection/ConnectionManager'
4
4
  import { waitForCondition } from '@streamr/utils'
@@ -1,10 +1,10 @@
1
1
  import LeakDetector from 'jest-leak-detector'
2
2
  import { waitForCondition } from '@streamr/utils'
3
3
  import { DhtNode } from '../../src/dht/DhtNode'
4
- import { Message } from '../../src/proto/packages/dht/protos/DhtRpc'
5
- import { RpcMessage } from '../../src/proto/packages/proto-rpc/protos/ProtoRpc'
4
+ import { Message } from '../../generated/packages/dht/protos/DhtRpc'
5
+ import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
6
6
  import { createMockPeerDescriptor } from '../utils/utils'
7
- import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
7
+ import { toNodeId } from '../../src/identifiers'
8
8
 
9
9
  const MESSAGE_ID = 'mock-message-id'
10
10
 
@@ -19,7 +19,7 @@ describe('memory leak', () => {
19
19
  }
20
20
  })
21
21
  let entryPoint: DhtNode | undefined = new DhtNode({
22
- nodeId: getNodeIdFromPeerDescriptor(entryPointDescriptor),
22
+ nodeId: toNodeId(entryPointDescriptor),
23
23
  websocketHost: entryPointDescriptor.websocket!.host,
24
24
  websocketPortRange: {
25
25
  min: entryPointDescriptor.websocket!.port,