@streamr/dht 103.1.2 → 103.2.0-experiment.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 (303) hide show
  1. package/dist/exports-browser.cjs +7636 -0
  2. package/dist/exports-browser.cjs.map +1 -0
  3. package/dist/exports-browser.d.ts +1321 -0
  4. package/dist/exports-browser.js +7611 -0
  5. package/dist/exports-browser.js.map +1 -0
  6. package/dist/exports-nodejs.cjs +7833 -0
  7. package/dist/exports-nodejs.cjs.map +1 -0
  8. package/dist/exports-nodejs.d.ts +1321 -0
  9. package/dist/exports-nodejs.js +7808 -0
  10. package/dist/exports-nodejs.js.map +1 -0
  11. package/package.json +41 -25
  12. package/dist/generated/google/protobuf/any.d.ts +0 -180
  13. package/dist/generated/google/protobuf/any.js +0 -155
  14. package/dist/generated/google/protobuf/any.js.map +0 -1
  15. package/dist/generated/google/protobuf/empty.d.ts +0 -31
  16. package/dist/generated/google/protobuf/empty.js +0 -45
  17. package/dist/generated/google/protobuf/empty.js.map +0 -1
  18. package/dist/generated/google/protobuf/timestamp.d.ts +0 -156
  19. package/dist/generated/google/protobuf/timestamp.js +0 -136
  20. package/dist/generated/google/protobuf/timestamp.js.map +0 -1
  21. package/dist/generated/packages/dht/protos/DhtRpc.client.d.ts +0 -371
  22. package/dist/generated/packages/dht/protos/DhtRpc.client.js +0 -292
  23. package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +0 -1
  24. package/dist/generated/packages/dht/protos/DhtRpc.d.ts +0 -1031
  25. package/dist/generated/packages/dht/protos/DhtRpc.js +0 -702
  26. package/dist/generated/packages/dht/protos/DhtRpc.js.map +0 -1
  27. package/dist/generated/packages/dht/protos/DhtRpc.server.d.ts +0 -168
  28. package/dist/generated/packages/dht/protos/DhtRpc.server.js +0 -3
  29. package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +0 -1
  30. package/dist/generated/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -87
  31. package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js +0 -66
  32. package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
  33. package/dist/package.json +0 -61
  34. package/dist/src/connection/Connection.d.ts +0 -12
  35. package/dist/src/connection/Connection.js +0 -30
  36. package/dist/src/connection/Connection.js.map +0 -1
  37. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +0 -22
  38. package/dist/src/connection/ConnectionLockRpcLocal.js +0 -54
  39. package/dist/src/connection/ConnectionLockRpcLocal.js.map +0 -1
  40. package/dist/src/connection/ConnectionLockRpcRemote.d.ts +0 -10
  41. package/dist/src/connection/ConnectionLockRpcRemote.js +0 -61
  42. package/dist/src/connection/ConnectionLockRpcRemote.js.map +0 -1
  43. package/dist/src/connection/ConnectionLockStates.d.ts +0 -27
  44. package/dist/src/connection/ConnectionLockStates.js +0 -114
  45. package/dist/src/connection/ConnectionLockStates.js.map +0 -1
  46. package/dist/src/connection/ConnectionManager.d.ts +0 -85
  47. package/dist/src/connection/ConnectionManager.js +0 -569
  48. package/dist/src/connection/ConnectionManager.js.map +0 -1
  49. package/dist/src/connection/ConnectionsView.d.ts +0 -7
  50. package/dist/src/connection/ConnectionsView.js +0 -3
  51. package/dist/src/connection/ConnectionsView.js.map +0 -1
  52. package/dist/src/connection/ConnectorFacade.d.ts +0 -58
  53. package/dist/src/connection/ConnectorFacade.js +0 -154
  54. package/dist/src/connection/ConnectorFacade.js.map +0 -1
  55. package/dist/src/connection/Handshaker.d.ts +0 -27
  56. package/dist/src/connection/Handshaker.js +0 -179
  57. package/dist/src/connection/Handshaker.js.map +0 -1
  58. package/dist/src/connection/IConnection.d.ts +0 -32
  59. package/dist/src/connection/IConnection.js +0 -12
  60. package/dist/src/connection/IConnection.js.map +0 -1
  61. package/dist/src/connection/ManagedConnection.d.ts +0 -30
  62. package/dist/src/connection/ManagedConnection.js +0 -129
  63. package/dist/src/connection/ManagedConnection.js.map +0 -1
  64. package/dist/src/connection/OutputBuffer.d.ts +0 -9
  65. package/dist/src/connection/OutputBuffer.js +0 -26
  66. package/dist/src/connection/OutputBuffer.js.map +0 -1
  67. package/dist/src/connection/PendingConnection.d.ts +0 -19
  68. package/dist/src/connection/PendingConnection.js +0 -59
  69. package/dist/src/connection/PendingConnection.js.map +0 -1
  70. package/dist/src/connection/connectivityChecker.d.ts +0 -9
  71. package/dist/src/connection/connectivityChecker.js +0 -138
  72. package/dist/src/connection/connectivityChecker.js.map +0 -1
  73. package/dist/src/connection/connectivityRequestHandler.d.ts +0 -4
  74. package/dist/src/connection/connectivityRequestHandler.js +0 -108
  75. package/dist/src/connection/connectivityRequestHandler.js.map +0 -1
  76. package/dist/src/connection/simulator/Simulator.d.ts +0 -36
  77. package/dist/src/connection/simulator/Simulator.js +0 -290
  78. package/dist/src/connection/simulator/Simulator.js.map +0 -1
  79. package/dist/src/connection/simulator/SimulatorConnection.d.ts +0 -18
  80. package/dist/src/connection/simulator/SimulatorConnection.js +0 -123
  81. package/dist/src/connection/simulator/SimulatorConnection.js.map +0 -1
  82. package/dist/src/connection/simulator/SimulatorConnector.d.ts +0 -16
  83. package/dist/src/connection/simulator/SimulatorConnector.js +0 -80
  84. package/dist/src/connection/simulator/SimulatorConnector.js.map +0 -1
  85. package/dist/src/connection/simulator/SimulatorTransport.d.ts +0 -6
  86. package/dist/src/connection/simulator/SimulatorTransport.js +0 -17
  87. package/dist/src/connection/simulator/SimulatorTransport.js.map +0 -1
  88. package/dist/src/connection/simulator/pings.d.ts +0 -21
  89. package/dist/src/connection/simulator/pings.js +0 -61
  90. package/dist/src/connection/simulator/pings.js.map +0 -1
  91. package/dist/src/connection/webrtc/BrowserWebrtcConnection.d.ts +0 -37
  92. package/dist/src/connection/webrtc/BrowserWebrtcConnection.js +0 -229
  93. package/dist/src/connection/webrtc/BrowserWebrtcConnection.js.map +0 -1
  94. package/dist/src/connection/webrtc/IWebrtcConnection.d.ts +0 -21
  95. package/dist/src/connection/webrtc/IWebrtcConnection.js +0 -9
  96. package/dist/src/connection/webrtc/IWebrtcConnection.js.map +0 -1
  97. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +0 -45
  98. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +0 -229
  99. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +0 -1
  100. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -43
  101. package/dist/src/connection/webrtc/WebrtcConnector.js +0 -208
  102. package/dist/src/connection/webrtc/WebrtcConnector.js.map +0 -1
  103. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +0 -26
  104. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +0 -82
  105. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +0 -1
  106. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +0 -8
  107. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +0 -50
  108. package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +0 -1
  109. package/dist/src/connection/webrtc/iceServerAsString.d.ts +0 -2
  110. package/dist/src/connection/webrtc/iceServerAsString.js +0 -17
  111. package/dist/src/connection/webrtc/iceServerAsString.js.map +0 -1
  112. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +0 -27
  113. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +0 -107
  114. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +0 -1
  115. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +0 -26
  116. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +0 -39
  117. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +0 -1
  118. package/dist/src/connection/websocket/BrowserWebsocketClientConnection.d.ts +0 -7
  119. package/dist/src/connection/websocket/BrowserWebsocketClientConnection.js +0 -44
  120. package/dist/src/connection/websocket/BrowserWebsocketClientConnection.js.map +0 -1
  121. package/dist/src/connection/websocket/NodeWebsocketClientConnection.d.ts +0 -7
  122. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +0 -39
  123. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +0 -1
  124. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +0 -26
  125. package/dist/src/connection/websocket/WebsocketClientConnector.js +0 -86
  126. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +0 -1
  127. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +0 -18
  128. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +0 -23
  129. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +0 -1
  130. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +0 -5
  131. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +0 -17
  132. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +0 -1
  133. package/dist/src/connection/websocket/WebsocketServer.d.ts +0 -25
  134. package/dist/src/connection/websocket/WebsocketServer.js +0 -146
  135. package/dist/src/connection/websocket/WebsocketServer.js.map +0 -1
  136. package/dist/src/connection/websocket/WebsocketServerConnection.d.ts +0 -22
  137. package/dist/src/connection/websocket/WebsocketServerConnection.js +0 -101
  138. package/dist/src/connection/websocket/WebsocketServerConnection.js.map +0 -1
  139. package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +0 -44
  140. package/dist/src/connection/websocket/WebsocketServerConnector.js +0 -279
  141. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +0 -1
  142. package/dist/src/dht/DhtNode.d.ts +0 -119
  143. package/dist/src/dht/DhtNode.js +0 -500
  144. package/dist/src/dht/DhtNode.js.map +0 -1
  145. package/dist/src/dht/DhtNodeRpcLocal.d.ts +0 -23
  146. package/dist/src/dht/DhtNodeRpcLocal.js +0 -54
  147. package/dist/src/dht/DhtNodeRpcLocal.js.map +0 -1
  148. package/dist/src/dht/DhtNodeRpcRemote.d.ts +0 -25
  149. package/dist/src/dht/DhtNodeRpcRemote.js +0 -83
  150. package/dist/src/dht/DhtNodeRpcRemote.js.map +0 -1
  151. package/dist/src/dht/ExternalApiRpcLocal.d.ts +0 -18
  152. package/dist/src/dht/ExternalApiRpcLocal.js +0 -32
  153. package/dist/src/dht/ExternalApiRpcLocal.js.map +0 -1
  154. package/dist/src/dht/ExternalApiRpcRemote.d.ts +0 -10
  155. package/dist/src/dht/ExternalApiRpcRemote.js +0 -58
  156. package/dist/src/dht/ExternalApiRpcRemote.js.map +0 -1
  157. package/dist/src/dht/PeerManager.d.ts +0 -63
  158. package/dist/src/dht/PeerManager.js +0 -251
  159. package/dist/src/dht/PeerManager.js.map +0 -1
  160. package/dist/src/dht/contact/Contact.d.ts +0 -8
  161. package/dist/src/dht/contact/Contact.js +0 -18
  162. package/dist/src/dht/contact/Contact.js.map +0 -1
  163. package/dist/src/dht/contact/ContactList.d.ts +0 -19
  164. package/dist/src/dht/contact/ContactList.js +0 -35
  165. package/dist/src/dht/contact/ContactList.js.map +0 -1
  166. package/dist/src/dht/contact/RandomContactList.d.ts +0 -11
  167. package/dist/src/dht/contact/RandomContactList.js +0 -47
  168. package/dist/src/dht/contact/RandomContactList.js.map +0 -1
  169. package/dist/src/dht/contact/RingContactList.d.ts +0 -28
  170. package/dist/src/dht/contact/RingContactList.js +0 -126
  171. package/dist/src/dht/contact/RingContactList.js.map +0 -1
  172. package/dist/src/dht/contact/RpcRemote.d.ts +0 -19
  173. package/dist/src/dht/contact/RpcRemote.js +0 -61
  174. package/dist/src/dht/contact/RpcRemote.js.map +0 -1
  175. package/dist/src/dht/contact/SortedContactList.d.ts +0 -37
  176. package/dist/src/dht/contact/SortedContactList.js +0 -134
  177. package/dist/src/dht/contact/SortedContactList.js.map +0 -1
  178. package/dist/src/dht/contact/getClosestNodes.d.ts +0 -6
  179. package/dist/src/dht/contact/getClosestNodes.js +0 -19
  180. package/dist/src/dht/contact/getClosestNodes.js.map +0 -1
  181. package/dist/src/dht/contact/ringIdentifiers.d.ts +0 -16
  182. package/dist/src/dht/contact/ringIdentifiers.js +0 -54
  183. package/dist/src/dht/contact/ringIdentifiers.js.map +0 -1
  184. package/dist/src/dht/discovery/DiscoverySession.d.ts +0 -29
  185. package/dist/src/dht/discovery/DiscoverySession.js +0 -102
  186. package/dist/src/dht/discovery/DiscoverySession.js.map +0 -1
  187. package/dist/src/dht/discovery/PeerDiscovery.d.ts +0 -42
  188. package/dist/src/dht/discovery/PeerDiscovery.js +0 -193
  189. package/dist/src/dht/discovery/PeerDiscovery.js.map +0 -1
  190. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +0 -28
  191. package/dist/src/dht/discovery/RingDiscoverySession.js +0 -116
  192. package/dist/src/dht/discovery/RingDiscoverySession.js.map +0 -1
  193. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +0 -38
  194. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +0 -165
  195. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +0 -1
  196. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +0 -14
  197. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +0 -26
  198. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +0 -1
  199. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +0 -6
  200. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +0 -44
  201. package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +0 -1
  202. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +0 -45
  203. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +0 -185
  204. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +0 -1
  205. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +0 -14
  206. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +0 -20
  207. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +0 -1
  208. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +0 -6
  209. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +0 -21
  210. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +0 -1
  211. package/dist/src/dht/routing/DuplicateDetector.d.ts +0 -10
  212. package/dist/src/dht/routing/DuplicateDetector.js +0 -31
  213. package/dist/src/dht/routing/DuplicateDetector.js.map +0 -1
  214. package/dist/src/dht/routing/Router.d.ts +0 -35
  215. package/dist/src/dht/routing/Router.js +0 -204
  216. package/dist/src/dht/routing/Router.js.map +0 -1
  217. package/dist/src/dht/routing/RouterRpcLocal.d.ts +0 -20
  218. package/dist/src/dht/routing/RouterRpcLocal.js +0 -67
  219. package/dist/src/dht/routing/RouterRpcLocal.js.map +0 -1
  220. package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -8
  221. package/dist/src/dht/routing/RouterRpcRemote.js +0 -81
  222. package/dist/src/dht/routing/RouterRpcRemote.js.map +0 -1
  223. package/dist/src/dht/routing/RoutingSession.d.ts +0 -56
  224. package/dist/src/dht/routing/RoutingSession.js +0 -201
  225. package/dist/src/dht/routing/RoutingSession.js.map +0 -1
  226. package/dist/src/dht/routing/RoutingTablesCache.d.ts +0 -24
  227. package/dist/src/dht/routing/RoutingTablesCache.js +0 -46
  228. package/dist/src/dht/routing/RoutingTablesCache.js.map +0 -1
  229. package/dist/src/dht/routing/getPreviousPeer.d.ts +0 -2
  230. package/dist/src/dht/routing/getPreviousPeer.js +0 -12
  231. package/dist/src/dht/routing/getPreviousPeer.js.map +0 -1
  232. package/dist/src/dht/store/LocalDataStore.d.ts +0 -14
  233. package/dist/src/dht/store/LocalDataStore.js +0 -78
  234. package/dist/src/dht/store/LocalDataStore.js.map +0 -1
  235. package/dist/src/dht/store/StoreManager.d.ts +0 -32
  236. package/dist/src/dht/store/StoreManager.js +0 -126
  237. package/dist/src/dht/store/StoreManager.js.map +0 -1
  238. package/dist/src/dht/store/StoreRpcLocal.d.ts +0 -21
  239. package/dist/src/dht/store/StoreRpcLocal.js +0 -65
  240. package/dist/src/dht/store/StoreRpcLocal.js.map +0 -1
  241. package/dist/src/dht/store/StoreRpcRemote.d.ts +0 -7
  242. package/dist/src/dht/store/StoreRpcRemote.js +0 -29
  243. package/dist/src/dht/store/StoreRpcRemote.js.map +0 -1
  244. package/dist/src/exports.d.ts +0 -25
  245. package/dist/src/exports.js +0 -48
  246. package/dist/src/exports.js.map +0 -1
  247. package/dist/src/helpers/AddressTools.d.ts +0 -2
  248. package/dist/src/helpers/AddressTools.js +0 -32
  249. package/dist/src/helpers/AddressTools.js.map +0 -1
  250. package/dist/src/helpers/Connectivity.d.ts +0 -4
  251. package/dist/src/helpers/Connectivity.js +0 -24
  252. package/dist/src/helpers/Connectivity.js.map +0 -1
  253. package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +0 -1
  254. package/dist/src/helpers/browser/isBrowserEnvironment.js +0 -6
  255. package/dist/src/helpers/browser/isBrowserEnvironment.js.map +0 -1
  256. package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +0 -1
  257. package/dist/src/helpers/browser/isBrowserEnvironment_override.js +0 -7
  258. package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +0 -1
  259. package/dist/src/helpers/createPeerDescriptor.d.ts +0 -3
  260. package/dist/src/helpers/createPeerDescriptor.js +0 -58
  261. package/dist/src/helpers/createPeerDescriptor.js.map +0 -1
  262. package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +0 -2
  263. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +0 -30
  264. package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +0 -1
  265. package/dist/src/helpers/debugHelpers.d.ts +0 -3
  266. package/dist/src/helpers/debugHelpers.js +0 -11
  267. package/dist/src/helpers/debugHelpers.js.map +0 -1
  268. package/dist/src/helpers/errors.d.ts +0 -72
  269. package/dist/src/helpers/errors.js +0 -97
  270. package/dist/src/helpers/errors.js.map +0 -1
  271. package/dist/src/helpers/offering.d.ts +0 -4
  272. package/dist/src/helpers/offering.js +0 -18
  273. package/dist/src/helpers/offering.js.map +0 -1
  274. package/dist/src/helpers/protoClasses.d.ts +0 -2
  275. package/dist/src/helpers/protoClasses.js +0 -32
  276. package/dist/src/helpers/protoClasses.js.map +0 -1
  277. package/dist/src/helpers/protoToString.d.ts +0 -2
  278. package/dist/src/helpers/protoToString.js +0 -19
  279. package/dist/src/helpers/protoToString.js.map +0 -1
  280. package/dist/src/helpers/version.d.ts +0 -6
  281. package/dist/src/helpers/version.js +0 -38
  282. package/dist/src/helpers/version.js.map +0 -1
  283. package/dist/src/identifiers.d.ts +0 -10
  284. package/dist/src/identifiers.js +0 -31
  285. package/dist/src/identifiers.js.map +0 -1
  286. package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -12
  287. package/dist/src/rpc-protocol/DhtCallContext.js +0 -17
  288. package/dist/src/rpc-protocol/DhtCallContext.js.map +0 -1
  289. package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +0 -10
  290. package/dist/src/rpc-protocol/DhtRpcOptions.js +0 -3
  291. package/dist/src/rpc-protocol/DhtRpcOptions.js.map +0 -1
  292. package/dist/src/transport/ITransport.d.ts +0 -31
  293. package/dist/src/transport/ITransport.js +0 -9
  294. package/dist/src/transport/ITransport.js.map +0 -1
  295. package/dist/src/transport/ListeningRpcCommunicator.d.ts +0 -11
  296. package/dist/src/transport/ListeningRpcCommunicator.js +0 -31
  297. package/dist/src/transport/ListeningRpcCommunicator.js.map +0 -1
  298. package/dist/src/transport/RoutingRpcCommunicator.d.ts +0 -10
  299. package/dist/src/transport/RoutingRpcCommunicator.js +0 -60
  300. package/dist/src/transport/RoutingRpcCommunicator.js.map +0 -1
  301. package/dist/src/types/ServiceID.d.ts +0 -1
  302. package/dist/src/types/ServiceID.js +0 -3
  303. package/dist/src/types/ServiceID.js.map +0 -1
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DhtNodeRpcRemote = void 0;
4
- const utils_1 = require("@streamr/utils");
5
- const uuid_1 = require("uuid");
6
- const identifiers_1 = require("../identifiers");
7
- const DhtRpc_client_1 = require("../../generated/packages/dht/protos/DhtRpc.client");
8
- const RpcRemote_1 = require("./contact/RpcRemote");
9
- const logger = new utils_1.Logger(module);
10
- class DhtNodeRpcRemote extends RpcRemote_1.RpcRemote {
11
- static counter = 0;
12
- vectorClock;
13
- id;
14
- serviceId;
15
- constructor(localPeerDescriptor, peerDescriptor, serviceId, rpcCommunicator, rpcRequestTimeout) {
16
- super(localPeerDescriptor, peerDescriptor, rpcCommunicator, DhtRpc_client_1.DhtNodeRpcClient, rpcRequestTimeout);
17
- this.id = this.getPeerDescriptor().nodeId;
18
- this.vectorClock = DhtNodeRpcRemote.counter++;
19
- this.serviceId = serviceId;
20
- }
21
- async getClosestPeers(nodeId) {
22
- logger.trace(`Requesting getClosestPeers on ${this.serviceId} from ${this.getNodeId()}`);
23
- const request = {
24
- nodeId: (0, identifiers_1.toDhtAddressRaw)(nodeId),
25
- requestId: (0, uuid_1.v4)()
26
- };
27
- try {
28
- const peers = await this.getClient().getClosestPeers(request, this.formDhtRpcOptions());
29
- return peers.peers;
30
- }
31
- catch (err) {
32
- logger.trace(`getClosestPeers error ${this.serviceId}`, { err });
33
- throw err;
34
- }
35
- }
36
- // TODO rename to getClosestRingContacts (breaking change)
37
- async getClosestRingPeers(ringIdRaw) {
38
- logger.trace(`Requesting getClosestRingPeers on ${this.serviceId} from ${this.getNodeId()}`);
39
- const request = {
40
- ringId: ringIdRaw,
41
- requestId: (0, uuid_1.v4)()
42
- };
43
- try {
44
- const response = await this.getClient().getClosestRingPeers(request, this.formDhtRpcOptions());
45
- return { left: response.leftPeers ?? [], right: response.rightPeers ?? [] };
46
- }
47
- catch (err) {
48
- logger.trace(`getClosestRingPeers error ${this.serviceId}`, { err });
49
- throw err;
50
- }
51
- }
52
- async ping() {
53
- logger.trace(`Requesting ping on ${this.serviceId} from ${this.getNodeId()}`);
54
- const request = {
55
- requestId: (0, uuid_1.v4)()
56
- };
57
- const options = this.formDhtRpcOptions();
58
- try {
59
- const pong = await this.getClient().ping(request, options);
60
- if (pong.requestId === request.requestId) {
61
- return true;
62
- }
63
- }
64
- catch (err) {
65
- logger.trace(`ping failed on ${this.serviceId} to ${this.getNodeId()}`, { err });
66
- }
67
- return false;
68
- }
69
- leaveNotice() {
70
- logger.trace(`Sending leaveNotice on ${this.serviceId} from ${this.getNodeId()}`);
71
- const options = this.formDhtRpcOptions({
72
- notification: true
73
- });
74
- this.getClient().leaveNotice({}, options).catch((e) => {
75
- logger.trace('Failed to send leaveNotice' + e);
76
- });
77
- }
78
- getNodeId() {
79
- return (0, identifiers_1.toNodeId)(this.getPeerDescriptor());
80
- }
81
- }
82
- exports.DhtNodeRpcRemote = DhtNodeRpcRemote;
83
- //# sourceMappingURL=DhtNodeRpcRemote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DhtNodeRpcRemote.js","sourceRoot":"","sources":["../../../src/dht/DhtNodeRpcRemote.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,+BAAyB;AACzB,gDAAqF;AAOrF,qFAAoF;AAEpF,mDAA+C;AAK/C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAQjC,MAAa,gBAAiB,SAAQ,qBAA2B;IAErD,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;IACnB,WAAW,CAAQ;IACV,EAAE,CAAe;IAChB,SAAS,CAAW;IAErC,YACI,mBAAmC,EACnC,cAA8B,EAC9B,SAAoB,EACpB,eAAgD,EAChD,iBAA0B;QAE1B,KAAK,CAAC,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,gCAAgB,EAAE,iBAAiB,CAAC,CAAA;QAChG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAA;QACzC,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,OAA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,CAAC,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACN,CAAC;IAED,SAAS;QACL,OAAO,IAAA,sBAAQ,EAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;IAC7C,CAAC;;AAhFL,4CAiFC"}
@@ -1,18 +0,0 @@
1
- import { IExternalApiRpc } from '../../generated/packages/dht/protos/DhtRpc.server';
2
- import { ExternalFetchDataRequest, ExternalFetchDataResponse, ExternalStoreDataRequest, ExternalStoreDataResponse, RecursiveOperation, PeerDescriptor, ExternalFindClosestNodesRequest, ExternalFindClosestNodesResponse } from '../../generated/packages/dht/protos/DhtRpc';
3
- import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
4
- import { RecursiveOperationResult } from './recursive-operation/RecursiveOperationManager';
5
- import { Any } from '../../generated/google/protobuf/any';
6
- import { DhtAddress } from '../identifiers';
7
- interface ExternalApiRpcLocalOptions {
8
- executeRecursiveOperation: (targetId: DhtAddress, operation: RecursiveOperation, excludedPeer: DhtAddress) => Promise<RecursiveOperationResult>;
9
- storeDataToDht: (key: DhtAddress, data: Any, creator: DhtAddress) => Promise<PeerDescriptor[]>;
10
- }
11
- export declare class ExternalApiRpcLocal implements IExternalApiRpc {
12
- private readonly options;
13
- constructor(options: ExternalApiRpcLocalOptions);
14
- externalFetchData(request: ExternalFetchDataRequest, context: ServerCallContext): Promise<ExternalFetchDataResponse>;
15
- externalStoreData(request: ExternalStoreDataRequest, context: ServerCallContext): Promise<ExternalStoreDataResponse>;
16
- externalFindClosestNodes(request: ExternalFindClosestNodesRequest, context: ServerCallContext): Promise<ExternalFindClosestNodesResponse>;
17
- }
18
- export {};
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExternalApiRpcLocal = void 0;
4
- const DhtRpc_1 = require("../../generated/packages/dht/protos/DhtRpc");
5
- const identifiers_1 = require("../identifiers");
6
- class ExternalApiRpcLocal {
7
- options;
8
- constructor(options) {
9
- this.options = options;
10
- }
11
- async externalFetchData(request, context) {
12
- const senderPeerDescriptor = context.incomingSourceDescriptor;
13
- const result = await this.options.executeRecursiveOperation((0, identifiers_1.toDhtAddress)(request.key), DhtRpc_1.RecursiveOperation.FETCH_DATA, (0, identifiers_1.toNodeId)(senderPeerDescriptor));
14
- return DhtRpc_1.ExternalFetchDataResponse.create({ entries: result.dataEntries ?? [] });
15
- }
16
- async externalStoreData(request, context) {
17
- const senderPeerDescriptor = context.incomingSourceDescriptor;
18
- const result = await this.options.storeDataToDht((0, identifiers_1.toDhtAddress)(request.key), request.data, (0, identifiers_1.toNodeId)(senderPeerDescriptor));
19
- return DhtRpc_1.ExternalStoreDataResponse.create({
20
- storers: result
21
- });
22
- }
23
- async externalFindClosestNodes(request, context) {
24
- const senderPeerDescriptor = context.incomingSourceDescriptor;
25
- const result = await this.options.executeRecursiveOperation((0, identifiers_1.toDhtAddress)(request.nodeId), DhtRpc_1.RecursiveOperation.FIND_CLOSEST_NODES, (0, identifiers_1.toNodeId)(senderPeerDescriptor));
26
- return DhtRpc_1.ExternalFindClosestNodesResponse.create({
27
- closestNodes: result.closestNodes
28
- });
29
- }
30
- }
31
- exports.ExternalApiRpcLocal = ExternalApiRpcLocal;
32
- //# sourceMappingURL=ExternalApiRpcLocal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExternalApiRpcLocal.js","sourceRoot":"","sources":["../../../src/dht/ExternalApiRpcLocal.ts"],"names":[],"mappings":";;;AACA,uEASmD;AAKnD,gDAAmE;AAenE,MAAa,mBAAmB;IAEX,OAAO,CAA4B;IAEpD,YAAY,OAAmC;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAAiC,EAAE,OAA0B;QACjF,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,yBAAyB,CACvD,IAAA,0BAAY,EAAC,OAAO,CAAC,GAAG,CAAC,EACzB,2BAAkB,CAAC,UAAU,EAC7B,IAAA,sBAAQ,EAAC,oBAAoB,CAAC,CACjC,CAAA;QACD,OAAO,kCAAyB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAAiC,EAAE,OAA0B;QACjF,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAC5C,IAAA,0BAAY,EAAC,OAAO,CAAC,GAAG,CAAC,EACzB,OAAO,CAAC,IAAK,EACb,IAAA,sBAAQ,EAAC,oBAAoB,CAAC,CACjC,CAAA;QACD,OAAO,kCAAyB,CAAC,MAAM,CAAC;YACpC,OAAO,EAAE,MAAM;SAClB,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,OAAwC,EAAE,OAA0B;QAC/F,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,yBAAyB,CACvD,IAAA,0BAAY,EAAC,OAAO,CAAC,MAAM,CAAC,EAC5B,2BAAkB,CAAC,kBAAkB,EACrC,IAAA,sBAAQ,EAAC,oBAAoB,CAAC,CACjC,CAAA;QACD,OAAO,yCAAgC,CAAC,MAAM,CAAC;YAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;SACpC,CAAC,CAAA;IACN,CAAC;CAEJ;AA1CD,kDA0CC"}
@@ -1,10 +0,0 @@
1
- import { DhtAddress } from '../identifiers';
2
- import { Any } from '../../generated/google/protobuf/any';
3
- import { DataEntry, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc';
4
- import { ExternalApiRpcClient } from '../../generated/packages/dht/protos/DhtRpc.client';
5
- import { RpcRemote } from './contact/RpcRemote';
6
- export declare class ExternalApiRpcRemote extends RpcRemote<ExternalApiRpcClient> {
7
- externalFetchData(key: DhtAddress): Promise<DataEntry[]>;
8
- storeData(key: DhtAddress, data: Any): Promise<PeerDescriptor[]>;
9
- externalFindClosestNode(key: DhtAddress): Promise<PeerDescriptor[]>;
10
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExternalApiRpcRemote = void 0;
4
- const identifiers_1 = require("../identifiers");
5
- const RpcRemote_1 = require("./contact/RpcRemote");
6
- const DEFAULT_TIMEOUT = 10000;
7
- class ExternalApiRpcRemote extends RpcRemote_1.RpcRemote {
8
- async externalFetchData(key) {
9
- const request = {
10
- key: (0, identifiers_1.toDhtAddressRaw)(key)
11
- };
12
- const options = this.formDhtRpcOptions({
13
- // TODO use options option or named constant?
14
- timeout: DEFAULT_TIMEOUT
15
- });
16
- try {
17
- const data = await this.getClient().externalFetchData(request, options);
18
- return data.entries;
19
- }
20
- catch {
21
- return [];
22
- }
23
- }
24
- async storeData(key, data) {
25
- const request = {
26
- key: (0, identifiers_1.toDhtAddressRaw)(key),
27
- data
28
- };
29
- const options = this.formDhtRpcOptions({
30
- // TODO use options option or named constant?
31
- timeout: DEFAULT_TIMEOUT
32
- });
33
- try {
34
- const response = await this.getClient().externalStoreData(request, options);
35
- return response.storers;
36
- }
37
- catch {
38
- return [];
39
- }
40
- }
41
- async externalFindClosestNode(key) {
42
- const request = {
43
- nodeId: (0, identifiers_1.toDhtAddressRaw)(key)
44
- };
45
- const options = this.formDhtRpcOptions({
46
- timeout: DEFAULT_TIMEOUT
47
- });
48
- try {
49
- const response = await this.getClient().externalFindClosestNodes(request, options);
50
- return response.closestNodes;
51
- }
52
- catch {
53
- return [];
54
- }
55
- }
56
- }
57
- exports.ExternalApiRpcRemote = ExternalApiRpcRemote;
58
- //# sourceMappingURL=ExternalApiRpcRemote.js.map
@@ -1 +0,0 @@
1
- {"version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A,6BAAe,EAAC,GAAG,CAAC;SAC/B,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnC,OAAO,EAAE,eAAe;SAC3B,CAAC,CAAA;QACF,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAClF,OAAO,QAAQ,CAAC,YAAY,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;CACJ;AAjDD,oDAiDC"}
@@ -1,63 +0,0 @@
1
- import EventEmitter from 'eventemitter3';
2
- import { LockID } from '../connection/ConnectionLockStates';
3
- import { ConnectionLocker } from '../connection/ConnectionManager';
4
- import { DhtAddress, DhtAddressRaw } from '../identifiers';
5
- import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc';
6
- import { DhtNodeRpcRemote } from './DhtNodeRpcRemote';
7
- import { RandomContactList } from './contact/RandomContactList';
8
- import { RingContactList } from './contact/RingContactList';
9
- import { ReadonlySortedContactList } from './contact/SortedContactList';
10
- import { RingIdRaw } from './contact/ringIdentifiers';
11
- interface PeerManagerOptions {
12
- numberOfNodesPerKBucket: number;
13
- maxContactCount: number;
14
- localNodeId: DhtAddress;
15
- localPeerDescriptor: PeerDescriptor;
16
- connectionLocker?: ConnectionLocker;
17
- neighborPingLimit?: number;
18
- lockId: LockID;
19
- createDhtNodeRpcRemote: (peerDescriptor: PeerDescriptor) => DhtNodeRpcRemote;
20
- hasConnection: (nodeId: DhtAddress) => boolean;
21
- }
22
- export interface PeerManagerEvents {
23
- nearbyContactAdded: (peerDescriptor: PeerDescriptor) => void;
24
- nearbyContactRemoved: (peerDescriptor: PeerDescriptor) => void;
25
- randomContactAdded: (peerDescriptor: PeerDescriptor) => void;
26
- randomContactRemoved: (peerDescriptor: PeerDescriptor) => void;
27
- ringContactAdded: (peerDescriptor: PeerDescriptor) => void;
28
- ringContactRemoved: (peerDescriptor: PeerDescriptor) => void;
29
- kBucketEmpty: () => void;
30
- }
31
- export declare const getDistance: (nodeIdOrDataKeyRaw1: DhtAddressRaw, nodeIdOrDataKeyRaw2: DhtAddressRaw) => number;
32
- export declare class PeerManager extends EventEmitter<PeerManagerEvents> {
33
- private neighbors;
34
- private nearbyContacts;
35
- private activeContacts;
36
- private ringContacts;
37
- private randomContacts;
38
- private stopped;
39
- private readonly options;
40
- constructor(options: PeerManagerOptions);
41
- private onKBucketPing;
42
- private onKBucketRemoved;
43
- private onKBucketAdded;
44
- private addNearbyContactToNeighbors;
45
- private getNearbyActiveContactNotInNeighbors;
46
- removeContact(nodeId: DhtAddress): void;
47
- removeNeighbor(nodeId: DhtAddress): void;
48
- pruneOfflineNodes(nodes: DhtNodeRpcRemote[]): Promise<void>;
49
- stop(): void;
50
- getNearbyContacts(): ReadonlySortedContactList<DhtNodeRpcRemote>;
51
- getClosestRingContactsTo(ringIdRaw: RingIdRaw, limit?: number, excludedIds?: Set<DhtAddress>): {
52
- left: DhtNodeRpcRemote[];
53
- right: DhtNodeRpcRemote[];
54
- };
55
- getRandomContacts(): RandomContactList<DhtNodeRpcRemote>;
56
- getRingContacts(): RingContactList<DhtNodeRpcRemote>;
57
- getNearbyContactCount(excludedNodeIds?: Set<DhtAddress>): number;
58
- getNeighborCount(): number;
59
- getNeighbors(): readonly DhtNodeRpcRemote[];
60
- setContactActive(nodeId: DhtAddress): void;
61
- addContact(peerDescriptor: PeerDescriptor): void;
62
- }
63
- export {};
@@ -1,251 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PeerManager = exports.getDistance = void 0;
7
- const utils_1 = require("@streamr/utils");
8
- const eventemitter3_1 = __importDefault(require("eventemitter3"));
9
- const k_bucket_1 = __importDefault(require("k-bucket"));
10
- const identifiers_1 = require("../identifiers");
11
- const RandomContactList_1 = require("./contact/RandomContactList");
12
- const RingContactList_1 = require("./contact/RingContactList");
13
- const SortedContactList_1 = require("./contact/SortedContactList");
14
- const ringIdentifiers_1 = require("./contact/ringIdentifiers");
15
- const logger = new utils_1.Logger(module);
16
- // Returns all offline nodes, sets contacts as active if they are online
17
- const pingNodes = async (nodes, activeContacts) => {
18
- const offlineNeighbors = [];
19
- await Promise.allSettled(nodes.map(async (contact) => {
20
- const isOnline = await contact.ping();
21
- if (!isOnline) {
22
- activeContacts.delete(contact.getNodeId());
23
- offlineNeighbors.push(contact.getPeerDescriptor());
24
- }
25
- else {
26
- activeContacts.add(contact.getNodeId());
27
- }
28
- }));
29
- return offlineNeighbors;
30
- };
31
- const getDistance = (nodeIdOrDataKeyRaw1, nodeIdOrDataKeyRaw2) => {
32
- return k_bucket_1.default.distance(nodeIdOrDataKeyRaw1, nodeIdOrDataKeyRaw2);
33
- };
34
- exports.getDistance = getDistance;
35
- class PeerManager extends eventemitter3_1.default {
36
- // Glossary:
37
- // * 'neighbors' are the nodes that are our neighbors according to
38
- // the protocol of the layer we are in
39
- // * 'connections' are the nodes that are connected to this node on Layer0
40
- // * 'contacts' are all non-unresponsive nodes that we know about
41
- neighbors;
42
- nearbyContacts;
43
- activeContacts;
44
- ringContacts;
45
- randomContacts;
46
- stopped = false;
47
- options;
48
- constructor(options) {
49
- super();
50
- this.options = options;
51
- this.neighbors = new k_bucket_1.default({
52
- localNodeId: (0, identifiers_1.toDhtAddressRaw)(this.options.localNodeId),
53
- numberOfNodesPerKBucket: this.options.numberOfNodesPerKBucket,
54
- numberOfNodesToPing: this.options.numberOfNodesPerKBucket
55
- });
56
- this.ringContacts = new RingContactList_1.RingContactList((0, ringIdentifiers_1.getRingIdRawFromPeerDescriptor)(this.options.localPeerDescriptor));
57
- this.ringContacts.on('contactAdded', (contact) => {
58
- this.emit('ringContactAdded', contact.getPeerDescriptor());
59
- });
60
- this.ringContacts.on('contactRemoved', (contact) => {
61
- this.emit('ringContactRemoved', contact.getPeerDescriptor());
62
- });
63
- this.neighbors.on('ping', (oldContacts, newContact) => this.onKBucketPing(oldContacts, newContact));
64
- this.neighbors.on('removed', (contact) => this.onKBucketRemoved((0, identifiers_1.toNodeId)(contact.getPeerDescriptor())));
65
- this.neighbors.on('added', (contact) => this.onKBucketAdded(contact));
66
- this.neighbors.on('updated', () => {
67
- // TODO: Update contact info to the connection manager and reconnect
68
- });
69
- this.nearbyContacts = new SortedContactList_1.SortedContactList({
70
- referenceId: this.options.localNodeId,
71
- maxSize: this.options.maxContactCount,
72
- allowToContainReferenceId: false
73
- });
74
- this.nearbyContacts.on('contactRemoved', (contact) => {
75
- if (this.stopped) {
76
- return;
77
- }
78
- this.emit('nearbyContactRemoved', contact.getPeerDescriptor());
79
- this.randomContacts.addContact(this.options.createDhtNodeRpcRemote(contact.getPeerDescriptor()));
80
- });
81
- this.nearbyContacts.on('contactAdded', (contact) => this.emit('nearbyContactAdded', contact.getPeerDescriptor()));
82
- this.activeContacts = new Set();
83
- this.randomContacts = new RandomContactList_1.RandomContactList(this.options.localNodeId, this.options.maxContactCount);
84
- this.randomContacts.on('contactRemoved', (removedContact) => this.emit('randomContactRemoved', removedContact.getPeerDescriptor()));
85
- this.randomContacts.on('contactAdded', (contactAdded) => this.emit('randomContactAdded', contactAdded.getPeerDescriptor()));
86
- }
87
- onKBucketPing(oldContacts, newContact) {
88
- if (this.stopped) {
89
- return;
90
- }
91
- const sortingList = new SortedContactList_1.SortedContactList({
92
- referenceId: this.options.localNodeId,
93
- allowToContainReferenceId: false
94
- });
95
- sortingList.addContacts(oldContacts);
96
- const removableNodeId = sortingList.getFurthestContacts(1)[0].getNodeId();
97
- this.options.connectionLocker?.weakUnlockConnection(removableNodeId, this.options.lockId);
98
- this.neighbors.remove((0, identifiers_1.toDhtAddressRaw)(removableNodeId));
99
- this.neighbors.add(newContact);
100
- }
101
- onKBucketRemoved(nodeId) {
102
- if (this.stopped) {
103
- return;
104
- }
105
- this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId);
106
- logger.trace(`Removed contact ${nodeId}`);
107
- if (this.neighbors.count() === 0) {
108
- this.emit('kBucketEmpty');
109
- }
110
- }
111
- onKBucketAdded(contact) {
112
- if (this.stopped) {
113
- return;
114
- }
115
- if (contact.getNodeId() !== this.options.localNodeId) {
116
- const peerDescriptor = contact.getPeerDescriptor();
117
- const nodeId = (0, identifiers_1.toNodeId)(peerDescriptor);
118
- // Important to lock here, before the ping result is known
119
- this.options.connectionLocker?.weakLockConnection(nodeId, this.options.lockId);
120
- if (this.options.hasConnection(contact.getNodeId())
121
- || (this.options.neighborPingLimit !== undefined && this.neighbors.count() > this.options.neighborPingLimit)) {
122
- logger.trace(`Added new contact ${nodeId}`);
123
- }
124
- else { // open connection by pinging
125
- logger.trace('starting ping ' + nodeId);
126
- contact.ping().then((result) => {
127
- if (result) {
128
- logger.trace(`Added new contact ${nodeId}`);
129
- }
130
- else {
131
- logger.trace('ping failed ' + nodeId);
132
- this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId);
133
- this.removeContact(nodeId);
134
- this.addNearbyContactToNeighbors();
135
- }
136
- }).catch((_e) => {
137
- this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId);
138
- this.removeContact(nodeId);
139
- this.addNearbyContactToNeighbors();
140
- });
141
- }
142
- }
143
- }
144
- addNearbyContactToNeighbors() {
145
- if (this.stopped) {
146
- return;
147
- }
148
- const closest = this.getNearbyActiveContactNotInNeighbors();
149
- if (closest) {
150
- this.addContact(closest.getPeerDescriptor());
151
- }
152
- }
153
- getNearbyActiveContactNotInNeighbors() {
154
- for (const contactId of this.nearbyContacts.getContactIds()) {
155
- if (!this.neighbors.get((0, identifiers_1.toDhtAddressRaw)(contactId)) && this.activeContacts.has(contactId)) {
156
- return this.nearbyContacts.getContact(contactId);
157
- }
158
- }
159
- return undefined;
160
- }
161
- removeContact(nodeId) {
162
- if (this.stopped) {
163
- return;
164
- }
165
- logger.trace(`Removing contact ${nodeId}`);
166
- this.ringContacts.removeContact(this.nearbyContacts.getContact(nodeId));
167
- this.neighbors.remove((0, identifiers_1.toDhtAddressRaw)(nodeId));
168
- this.nearbyContacts.removeContact(nodeId);
169
- this.activeContacts.delete(nodeId);
170
- this.randomContacts.removeContact(nodeId);
171
- }
172
- removeNeighbor(nodeId) {
173
- this.neighbors.remove((0, identifiers_1.toDhtAddressRaw)(nodeId));
174
- }
175
- async pruneOfflineNodes(nodes) {
176
- logger.trace('Pruning offline nodes', { nodes: nodes.length });
177
- const offlineNeighbors = await pingNodes(nodes, this.activeContacts);
178
- offlineNeighbors.forEach((offlineNeighbor) => {
179
- logger.trace('Removing offline node', { node: (0, identifiers_1.toNodeId)(offlineNeighbor) });
180
- this.removeContact((0, identifiers_1.toNodeId)(offlineNeighbor));
181
- });
182
- }
183
- stop() {
184
- this.stopped = true;
185
- this.neighbors.toArray().forEach((rpcRemote) => {
186
- rpcRemote.leaveNotice();
187
- this.neighbors.remove(rpcRemote.id);
188
- });
189
- this.neighbors.removeAllListeners();
190
- this.ringContacts.getAllContacts().forEach((rpcRemote) => {
191
- rpcRemote.leaveNotice();
192
- this.ringContacts.removeContact(rpcRemote);
193
- });
194
- this.nearbyContacts.stop();
195
- this.randomContacts.stop();
196
- }
197
- getNearbyContacts() {
198
- return this.nearbyContacts;
199
- }
200
- getClosestRingContactsTo(ringIdRaw, limit, excludedIds) {
201
- const closest = new RingContactList_1.RingContactList(ringIdRaw, excludedIds);
202
- this.ringContacts.getAllContacts().map((contact) => closest.addContact(contact));
203
- // TODO use options option or named constant?
204
- return closest.getClosestContacts(limit ?? 8);
205
- }
206
- getRandomContacts() {
207
- return this.randomContacts;
208
- }
209
- getRingContacts() {
210
- return this.ringContacts;
211
- }
212
- getNearbyContactCount(excludedNodeIds) {
213
- return this.nearbyContacts.getSize(excludedNodeIds);
214
- }
215
- getNeighborCount() {
216
- return this.neighbors.count();
217
- }
218
- getNeighbors() {
219
- return this.neighbors.toArray();
220
- }
221
- setContactActive(nodeId) {
222
- this.activeContacts.add(nodeId);
223
- }
224
- addContact(peerDescriptor) {
225
- if (this.stopped) {
226
- return;
227
- }
228
- const nodeId = (0, identifiers_1.toNodeId)(peerDescriptor);
229
- if (nodeId !== this.options.localNodeId) {
230
- logger.trace(`Adding new contact ${nodeId}`);
231
- const remote = this.options.createDhtNodeRpcRemote(peerDescriptor);
232
- const isInNeighbors = (this.neighbors.get(peerDescriptor.nodeId) !== null);
233
- const isInNearbyContacts = (this.nearbyContacts.getContact(nodeId) !== undefined);
234
- const isInRingContacts = this.ringContacts.getContact(peerDescriptor) !== undefined;
235
- if (isInNeighbors || isInNearbyContacts) {
236
- this.randomContacts.addContact(remote);
237
- }
238
- if (!isInNeighbors) {
239
- this.neighbors.add(remote);
240
- }
241
- if (!isInNearbyContacts) {
242
- this.nearbyContacts.addContact(remote);
243
- }
244
- if (!isInRingContacts) {
245
- this.ringContacts.addContact(remote);
246
- }
247
- }
248
- }
249
- }
250
- exports.PeerManager = PeerManager;
251
- //# sourceMappingURL=PeerManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PeerManager.js","sourceRoot":"","sources":["../../../src/dht/PeerManager.ts"],"names":[],"mappings":";;;;;;AAAA,0CAEuB;AACvB,kEAAwC;AACxC,wDAA8B;AAG9B,gDAAqF;AAKrF,mEAA+D;AAC/D,+DAA2D;AAC3D,mEAA0F;AAC1F,+DAAqF;AAErF,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAcjC,wEAAwE;AACxE,MAAM,SAAS,GAAG,KAAK,EAAE,KAAyB,EAAE,cAA+B,EAA6B,EAAE;IAC9G,MAAM,gBAAgB,GAAqB,EAAE,CAAA;IAC7C,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAA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,CAAC,cAAc,CAAC,CAAA;YAClE,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAA;YAC1E,MAAM,kBAAkB,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAA;YACjF,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,SAAS,CAAA;YAEnF,IAAI,aAAa,IAAI,kBAAkB,EAAE,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;YAC1C,CAAC;YACD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACjB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAC9B,CAAC;YACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACtB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;YAC1C,CAAC;YACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACpB,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;YACxC,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AApPD,kCAoPC"}
@@ -1,8 +0,0 @@
1
- import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc';
2
- import { DhtAddress } from '../../identifiers';
3
- export declare class Contact {
4
- private peerDescriptor;
5
- constructor(peerDescriptor: PeerDescriptor);
6
- getPeerDescriptor(): PeerDescriptor;
7
- getNodeId(): DhtAddress;
8
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Contact = void 0;
4
- const identifiers_1 = require("../../identifiers");
5
- class Contact {
6
- peerDescriptor;
7
- constructor(peerDescriptor) {
8
- this.peerDescriptor = peerDescriptor;
9
- }
10
- getPeerDescriptor() {
11
- return this.peerDescriptor;
12
- }
13
- getNodeId() {
14
- return (0, identifiers_1.toNodeId)(this.peerDescriptor);
15
- }
16
- }
17
- exports.Contact = Contact;
18
- //# sourceMappingURL=Contact.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Contact.js","sourceRoot":"","sources":["../../../../src/dht/contact/Contact.ts"],"names":[],"mappings":";;;AACA,mDAAwD;AAExD,MAAa,OAAO;IAER,cAAc,CAAgB;IAEtC,YAAY,cAA8B;QACtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;IACxC,CAAC;IAEM,iBAAiB;QACpB,OAAO,IAAI,CAAC,cAAc,CAAA;IAC9B,CAAC;IAEM,SAAS;QACZ,OAAO,IAAA,sBAAQ,EAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IACxC,CAAC;CACJ;AAfD,0BAeC"}
@@ -1,19 +0,0 @@
1
- import EventEmitter from 'eventemitter3';
2
- import { DhtAddress } from '../../identifiers';
3
- export interface Events<C> {
4
- contactRemoved: (removedContact: C) => void;
5
- contactAdded: (contactAdded: C) => void;
6
- }
7
- export declare class ContactList<C extends {
8
- getNodeId: () => DhtAddress;
9
- }> extends EventEmitter<Events<C>> {
10
- protected contactsById: Map<DhtAddress, C>;
11
- protected contactIds: DhtAddress[];
12
- protected localNodeId: DhtAddress;
13
- protected maxSize: number;
14
- constructor(localNodeId: DhtAddress, maxSize: number);
15
- getContact(id: DhtAddress): C | undefined;
16
- getSize(): number;
17
- clear(): void;
18
- stop(): void;
19
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ContactList = void 0;
7
- const eventemitter3_1 = __importDefault(require("eventemitter3"));
8
- class ContactList extends eventemitter3_1.default {
9
- contactsById = new Map();
10
- // TODO move this to SortedContactList
11
- contactIds = [];
12
- localNodeId;
13
- maxSize;
14
- constructor(localNodeId, maxSize) {
15
- super();
16
- this.localNodeId = localNodeId;
17
- this.maxSize = maxSize;
18
- }
19
- getContact(id) {
20
- return this.contactsById.get(id);
21
- }
22
- getSize() {
23
- return this.contactIds.length;
24
- }
25
- clear() {
26
- this.contactsById.clear();
27
- this.contactIds = [];
28
- }
29
- stop() {
30
- this.removeAllListeners();
31
- this.clear();
32
- }
33
- }
34
- exports.ContactList = ContactList;
35
- //# sourceMappingURL=ContactList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContactList.js","sourceRoot":"","sources":["../../../../src/dht/contact/ContactList.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AAQxC,MAAa,WAAuD,SAAQ,uBAAuB;IAErF,YAAY,GAAuB,IAAI,GAAG,EAAE,CAAA;IACtD,sCAAsC;IAC5B,UAAU,GAAiB,EAAE,CAAA;IAC7B,WAAW,CAAY;IACvB,OAAO,CAAQ;IAEzB,YACI,WAAuB,EACvB,OAAe;QAEf,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAEM,UAAU,CAAC,EAAc;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACpC,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAA;IACjC,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACxB,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,kBAAkB,EAAE,CAAA;QACzB,IAAI,CAAC,KAAK,EAAE,CAAA;IAChB,CAAC;CACJ;AAlCD,kCAkCC"}