@streamr/dht 100.0.0-pretestnet.0 → 100.0.0-pretestnet.3
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.
- package/dist/src/connection/ConnectionLockHandler.d.ts +7 -8
- package/dist/src/connection/ConnectionLockHandler.js +16 -14
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js +6 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +5 -8
- package/dist/src/connection/ConnectionManager.js +77 -107
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -6
- package/dist/src/connection/ConnectivityChecker.js +23 -20
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +15 -12
- package/dist/src/connection/ConnectorFacade.js +61 -26
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +2 -2
- package/dist/src/connection/Handshaker.js +28 -28
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +5 -6
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +3 -4
- package/dist/src/connection/ManagedConnection.js +30 -30
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
- package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +22 -22
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +2 -2
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +11 -11
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
- package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
- package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
- package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +36 -36
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
- package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
- package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +20 -16
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
- package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +23 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.d.ts → websocket/WebsocketConnector.d.ts} +23 -15
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.js → websocket/WebsocketConnector.js} +108 -102
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +5 -10
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js.map → websocket/WebsocketConnectorRpcRemote.js.map} +1 -1
- package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
- package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +11 -19
- package/dist/src/dht/DhtNode.js +119 -150
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
- package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
- package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
- package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +17 -21
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
- package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/contact/Remote.d.ts +4 -1
- package/dist/src/dht/contact/Remote.js +28 -2
- package/dist/src/dht/contact/Remote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
- package/dist/src/dht/contact/SortedContactList.js +3 -3
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
- package/dist/src/dht/discovery/DiscoverySession.js +8 -8
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
- package/dist/src/dht/discovery/PeerDiscovery.js +5 -5
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
- package/dist/src/dht/find/FindRpcLocal.js +25 -0
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
- package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +18 -15
- package/dist/src/dht/find/FindSession.js.map +1 -0
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
- package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
- package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +51 -46
- package/dist/src/dht/find/Finder.js.map +1 -0
- package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
- package/dist/src/dht/routing/FindRpcRemote.js +41 -0
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +10 -17
- package/dist/src/dht/routing/Router.js +48 -90
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
- package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +15 -43
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
- package/dist/src/dht/routing/RoutingSession.js +124 -131
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
- package/dist/src/dht/routing/getPreviousPeer.js +9 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
- package/dist/src/dht/store/StoreRpcLocal.js +25 -24
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +3 -7
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +11 -5
- package/dist/src/exports.js +17 -4
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +4 -0
- package/dist/src/helpers/Connectivity.js +24 -0
- package/dist/src/helpers/Connectivity.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +3 -3
- package/dist/src/helpers/errors.js +7 -7
- package/dist/src/helpers/protoClasses.js +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +64 -84
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +64 -66
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/transport/ITransport.d.ts +5 -6
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +5 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +8 -2
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/dist/src/types/ServiceID.d.ts +1 -0
- package/dist/src/types/ServiceID.js +3 -0
- package/dist/src/types/ServiceID.js.map +1 -0
- package/karma.config.js +4 -4
- package/package.json +10 -8
- package/protos/DhtRpc.proto +32 -35
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +7 -6
- package/src/connection/ConnectionManager.ts +59 -95
- package/src/connection/ConnectivityChecker.ts +30 -26
- package/src/connection/ConnectorFacade.ts +74 -34
- package/src/connection/Handshaker.ts +9 -9
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +21 -22
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +9 -9
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +23 -24
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +13 -13
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +12 -13
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +32 -33
- package/src/connection/webrtc/WebrtcConnector.ts +225 -0
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
- package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
- package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
- package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +19 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +21 -27
- package/src/connection/{WebSocket/WebSocketConnectorRpcLocal.ts → websocket/WebsocketConnector.ts} +110 -101
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +6 -12
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +144 -179
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +12 -13
- package/src/dht/ExternalApiRpcLocal.ts +46 -0
- package/src/dht/ExternalApiRpcRemote.ts +4 -4
- package/src/dht/contact/Remote.ts +32 -4
- package/src/dht/contact/SortedContactList.ts +4 -4
- package/src/dht/discovery/DiscoverySession.ts +23 -20
- package/src/dht/discovery/PeerDiscovery.ts +14 -17
- package/src/dht/find/FindRpcLocal.ts +35 -0
- package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +26 -25
- package/src/dht/find/FindSessionRpcLocal.ts +25 -0
- package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
- package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +78 -71
- package/src/dht/routing/FindRpcRemote.ts +40 -0
- package/src/dht/routing/Router.ts +70 -105
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +15 -45
- package/src/dht/routing/RoutingSession.ts +56 -61
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +44 -37
- package/src/dht/store/StoreRpcRemote.ts +4 -8
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- package/src/helpers/protoClasses.ts +6 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
- package/src/proto/packages/dht/protos/DhtRpc.ts +87 -114
- package/src/rpc-protocol/DhtCallContext.ts +0 -1
- package/src/transport/ITransport.ts +5 -8
- package/src/transport/ListeningRpcCommunicator.ts +14 -4
- package/src/transport/RoutingRpcCommunicator.ts +3 -4
- package/src/types/ServiceID.ts +1 -0
- package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +2 -2
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
- package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
- package/test/end-to-end/Layer0.test.ts +35 -17
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +24 -6
- package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
- package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
- package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
- package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
- package/test/end-to-end/memory-leak.test.ts +85 -0
- package/test/integration/ConnectionLocking.test.ts +4 -4
- package/test/integration/ConnectionManager.test.ts +37 -28
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
- package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
- package/test/integration/DhtRpc.test.ts +5 -5
- package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +3 -3
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +6 -5
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +6 -6
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +3 -3
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +1 -1
- package/test/integration/StoreAndDelete.test.ts +1 -1
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +4 -4
- package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
- package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
- package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
- package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
- package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
- package/test/unit/ConnectivityHelpers.test.ts +69 -0
- package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
- package/test/unit/Router.test.ts +26 -26
- package/test/unit/UUID.test.ts +1 -1
- package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
- package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
- package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
- package/test/utils/FakeRpcCommunicator.ts +23 -0
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/utils.ts +14 -24
- package/tsconfig.browser.json +1 -1
- package/tsconfig.jest.json +3 -2
- package/tsconfig.node.json +3 -2
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
- package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
- package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
- package/dist/src/dht/RemoteDhtNode.js.map +0 -1
- package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
- package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
- package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
- package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
- package/src/dht/registerExternalApiRpcMethods.ts +0 -44
- package/test/utils/mock/RecursiveFinder.ts +0 -19
- /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
- /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
- /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IceCandidate,
|
|
3
|
-
PeerDescriptor,
|
|
4
|
-
RtcAnswer,
|
|
5
|
-
RtcOffer, WebRtcConnectionRequest
|
|
6
|
-
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
7
|
-
import { Empty } from '../../proto/google/protobuf/empty'
|
|
8
|
-
import { ITransport } from '../../transport/ITransport'
|
|
9
|
-
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator'
|
|
10
|
-
import { NodeWebRtcConnection } from './NodeWebRtcConnection'
|
|
11
|
-
import { WebRtcConnectorRpcRemote } from './WebRtcConnectorRpcRemote'
|
|
12
|
-
import { WebRtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
|
|
13
|
-
import { PeerIDKey } from '../../helpers/PeerID'
|
|
14
|
-
import { ManagedWebRtcConnection } from '../ManagedWebRtcConnection'
|
|
15
|
-
import { Logger } from '@streamr/utils'
|
|
16
|
-
import * as Err from '../../helpers/errors'
|
|
17
|
-
import { IWebRtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
|
|
18
|
-
import { ManagedConnection } from '../ManagedConnection'
|
|
19
|
-
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
20
|
-
import {
|
|
21
|
-
areEqualPeerDescriptors,
|
|
22
|
-
keyFromPeerDescriptor,
|
|
23
|
-
peerIdFromPeerDescriptor
|
|
24
|
-
} from '../../helpers/peerIdFromPeerDescriptor'
|
|
25
|
-
import { getAddressFromIceCandidate, isPrivateIPv4 } from '../../helpers/AddressTools'
|
|
26
|
-
import { PortRange } from '../ConnectionManager'
|
|
27
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
28
|
-
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
29
|
-
|
|
30
|
-
const logger = new Logger(module)
|
|
31
|
-
|
|
32
|
-
export const replaceInternalIpWithExternalIp = (candidate: string, ip: string): string => {
|
|
33
|
-
const parsed = candidate.split(' ')
|
|
34
|
-
const type = parsed[7]
|
|
35
|
-
if (type === 'host') {
|
|
36
|
-
parsed[4] = ip
|
|
37
|
-
}
|
|
38
|
-
return parsed.join(' ')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface WebRtcConnectorRpcLocalConfig {
|
|
42
|
-
transport: ITransport
|
|
43
|
-
iceServers?: IceServer[]
|
|
44
|
-
allowPrivateAddresses?: boolean
|
|
45
|
-
bufferThresholdLow?: number
|
|
46
|
-
bufferThresholdHigh?: number
|
|
47
|
-
maxMessageSize?: number
|
|
48
|
-
connectionTimeout?: number
|
|
49
|
-
externalIp?: string
|
|
50
|
-
portRange?: PortRange
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface IceServer {
|
|
54
|
-
url: string
|
|
55
|
-
port: number
|
|
56
|
-
username?: string
|
|
57
|
-
password?: string
|
|
58
|
-
tcp?: boolean
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export class WebRtcConnectorRpcLocal implements IWebRtcConnectorRpc {
|
|
62
|
-
|
|
63
|
-
private static readonly WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector'
|
|
64
|
-
private readonly rpcCommunicator: ListeningRpcCommunicator
|
|
65
|
-
private readonly ongoingConnectAttempts: Map<PeerIDKey, ManagedWebRtcConnection> = new Map()
|
|
66
|
-
private ownPeerDescriptor?: PeerDescriptor
|
|
67
|
-
private stopped = false
|
|
68
|
-
private iceServers: IceServer[]
|
|
69
|
-
private allowPrivateAddresses: boolean
|
|
70
|
-
private config: WebRtcConnectorRpcLocalConfig
|
|
71
|
-
private onIncomingConnection: (connection: ManagedConnection) => boolean
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
74
|
-
config: WebRtcConnectorRpcLocalConfig,
|
|
75
|
-
onIncomingConnection: (connection: ManagedConnection) => boolean
|
|
76
|
-
) {
|
|
77
|
-
this.config = config
|
|
78
|
-
this.iceServers = config.iceServers || []
|
|
79
|
-
this.allowPrivateAddresses = config.allowPrivateAddresses || true
|
|
80
|
-
this.onIncomingConnection = onIncomingConnection
|
|
81
|
-
|
|
82
|
-
this.rpcCommunicator = new ListeningRpcCommunicator(WebRtcConnectorRpcLocal.WEBRTC_CONNECTOR_SERVICE_ID, config.transport, {
|
|
83
|
-
rpcRequestTimeout: 15000
|
|
84
|
-
})
|
|
85
|
-
this.rpcCommunicator.registerRpcNotification(RtcOffer, 'rtcOffer',
|
|
86
|
-
(req: RtcOffer, context: ServerCallContext) => this.rtcOffer(req, context))
|
|
87
|
-
this.rpcCommunicator.registerRpcNotification(RtcAnswer, 'rtcAnswer',
|
|
88
|
-
(req: RtcAnswer, context: ServerCallContext) => this.rtcAnswer(req, context))
|
|
89
|
-
this.rpcCommunicator.registerRpcNotification(IceCandidate, 'iceCandidate',
|
|
90
|
-
(req: IceCandidate, context: ServerCallContext) => this.iceCandidate(req, context))
|
|
91
|
-
this.rpcCommunicator.registerRpcNotification(WebRtcConnectionRequest, 'requestConnection',
|
|
92
|
-
(req: WebRtcConnectionRequest, context: ServerCallContext) => this.requestConnection(req, context))
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection {
|
|
96
|
-
if (areEqualPeerDescriptors(targetPeerDescriptor, this.ownPeerDescriptor!)) {
|
|
97
|
-
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self')
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
logger.trace(`Opening WebRTC connection to ${keyFromPeerDescriptor(targetPeerDescriptor)}`)
|
|
101
|
-
|
|
102
|
-
const peerKey = keyFromPeerDescriptor(targetPeerDescriptor)
|
|
103
|
-
const existingConnection = this.ongoingConnectAttempts.get(peerKey)
|
|
104
|
-
if (existingConnection) {
|
|
105
|
-
return existingConnection
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const connection = new NodeWebRtcConnection({
|
|
109
|
-
remotePeerDescriptor: targetPeerDescriptor,
|
|
110
|
-
iceServers: this.iceServers,
|
|
111
|
-
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
112
|
-
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
113
|
-
connectingTimeout: this.config.connectionTimeout,
|
|
114
|
-
portRange: this.config.portRange
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const offering = this.isOffering(targetPeerDescriptor)
|
|
118
|
-
let managedConnection: ManagedWebRtcConnection
|
|
119
|
-
|
|
120
|
-
if (offering) {
|
|
121
|
-
managedConnection = new ManagedWebRtcConnection(this.ownPeerDescriptor!, connection)
|
|
122
|
-
} else {
|
|
123
|
-
managedConnection = new ManagedWebRtcConnection(this.ownPeerDescriptor!, undefined, connection)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
managedConnection.setPeerDescriptor(targetPeerDescriptor)
|
|
127
|
-
|
|
128
|
-
this.ongoingConnectAttempts.set(keyFromPeerDescriptor(targetPeerDescriptor), managedConnection)
|
|
129
|
-
|
|
130
|
-
const delFunc = () => {
|
|
131
|
-
if (this.ongoingConnectAttempts.has(peerKey)) {
|
|
132
|
-
this.ongoingConnectAttempts.delete(peerKey)
|
|
133
|
-
}
|
|
134
|
-
connection.off('disconnected', delFunc)
|
|
135
|
-
managedConnection.off('handshakeCompleted', delFunc)
|
|
136
|
-
}
|
|
137
|
-
connection.on('disconnected', delFunc)
|
|
138
|
-
managedConnection.on('handshakeCompleted', delFunc)
|
|
139
|
-
|
|
140
|
-
const remoteConnector = new WebRtcConnectorRpcRemote(
|
|
141
|
-
this.ownPeerDescriptor!,
|
|
142
|
-
targetPeerDescriptor,
|
|
143
|
-
toProtoRpcClient(new WebRtcConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport()))
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
connection.on('localCandidate', (candidate: string, mid: string) => {
|
|
147
|
-
if (this.config.externalIp) {
|
|
148
|
-
candidate = replaceInternalIpWithExternalIp(candidate, this.config.externalIp)
|
|
149
|
-
logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`)
|
|
150
|
-
}
|
|
151
|
-
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString())
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
if (offering) {
|
|
155
|
-
connection.once('localDescription', (description: string) => {
|
|
156
|
-
remoteConnector.sendRtcOffer(description, connection.connectionId.toString())
|
|
157
|
-
})
|
|
158
|
-
} else {
|
|
159
|
-
connection.once('localDescription', (description: string) => {
|
|
160
|
-
remoteConnector.sendRtcAnswer(description, connection.connectionId.toString())
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
connection.start(offering)
|
|
165
|
-
|
|
166
|
-
if (!offering) {
|
|
167
|
-
remoteConnector.requestConnection(connection.connectionId.toString())
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return managedConnection
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
setOwnPeerDescriptor(peerDescriptor: PeerDescriptor): void {
|
|
174
|
-
this.ownPeerDescriptor = peerDescriptor
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private isIceCandidateAllowed(candidate: string): boolean {
|
|
178
|
-
if (!this.allowPrivateAddresses) {
|
|
179
|
-
const address = getAddressFromIceCandidate(candidate)
|
|
180
|
-
if (address && isPrivateIPv4(address)) {
|
|
181
|
-
return false
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return true
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private onRtcOffer(
|
|
188
|
-
remotePeer: PeerDescriptor,
|
|
189
|
-
targetPeer: PeerDescriptor,
|
|
190
|
-
description: string,
|
|
191
|
-
connectionId: string
|
|
192
|
-
): void {
|
|
193
|
-
if (this.stopped || !areEqualPeerDescriptors(targetPeer, this.ownPeerDescriptor!)) {
|
|
194
|
-
return
|
|
195
|
-
}
|
|
196
|
-
const peerKey = keyFromPeerDescriptor(remotePeer)
|
|
197
|
-
let managedConnection = this.ongoingConnectAttempts.get(peerKey)
|
|
198
|
-
let connection = managedConnection?.getWebRtcConnection()
|
|
199
|
-
|
|
200
|
-
if (!managedConnection) {
|
|
201
|
-
connection = new NodeWebRtcConnection({ remotePeerDescriptor: remotePeer })
|
|
202
|
-
managedConnection = new ManagedWebRtcConnection(this.ownPeerDescriptor!, undefined, connection)
|
|
203
|
-
|
|
204
|
-
managedConnection.setPeerDescriptor(remotePeer)
|
|
205
|
-
|
|
206
|
-
this.ongoingConnectAttempts.set(peerKey, managedConnection)
|
|
207
|
-
this.onIncomingConnection(managedConnection)
|
|
208
|
-
|
|
209
|
-
const remoteConnector = new WebRtcConnectorRpcRemote(
|
|
210
|
-
this.ownPeerDescriptor!,
|
|
211
|
-
remotePeer,
|
|
212
|
-
toProtoRpcClient(new WebRtcConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport()))
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
connection.on('localCandidate', (candidate: string, mid: string) => {
|
|
216
|
-
remoteConnector.sendIceCandidate(candidate, mid, connection!.connectionId.toString())
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
connection.once('localDescription', (description: string) => {
|
|
220
|
-
remoteConnector.sendRtcAnswer(description, connection!.connectionId.toString())
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
connection.start(false)
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Always use offerers connectionId
|
|
228
|
-
connection!.setConnectionId(connectionId)
|
|
229
|
-
connection!.setRemoteDescription(description, 'offer')
|
|
230
|
-
|
|
231
|
-
managedConnection.on('handshakeRequest', () => {
|
|
232
|
-
if (this.ongoingConnectAttempts.has(peerKey)) {
|
|
233
|
-
this.ongoingConnectAttempts.delete(peerKey)
|
|
234
|
-
}
|
|
235
|
-
managedConnection!.acceptHandshake()
|
|
236
|
-
})
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
private onRtcAnswer(
|
|
240
|
-
remotePeerDescriptor: PeerDescriptor,
|
|
241
|
-
targetPeerDescriptor: PeerDescriptor,
|
|
242
|
-
description: string,
|
|
243
|
-
connectionId: string
|
|
244
|
-
): void {
|
|
245
|
-
if (this.stopped || !areEqualPeerDescriptors(targetPeerDescriptor, this.ownPeerDescriptor!)) {
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
const peerKey = keyFromPeerDescriptor(remotePeerDescriptor)
|
|
249
|
-
const connection = this.ongoingConnectAttempts.get(peerKey)?.getWebRtcConnection()
|
|
250
|
-
if (!connection) {
|
|
251
|
-
return
|
|
252
|
-
} else if (connection.connectionId.toString() !== connectionId) {
|
|
253
|
-
logger.trace(`Ignoring RTC answer due to connectionId mismatch`)
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
connection.setRemoteDescription(description, 'answer')
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
private onConnectionRequest(targetPeerDescriptor: PeerDescriptor): void {
|
|
260
|
-
if (this.stopped || this.ongoingConnectAttempts.has(keyFromPeerDescriptor(targetPeerDescriptor))) {
|
|
261
|
-
return
|
|
262
|
-
}
|
|
263
|
-
const managedConnection = this.connect(targetPeerDescriptor)
|
|
264
|
-
managedConnection.setPeerDescriptor(targetPeerDescriptor)
|
|
265
|
-
|
|
266
|
-
this.onIncomingConnection(managedConnection)
|
|
267
|
-
}
|
|
268
|
-
private onRemoteCandidate(
|
|
269
|
-
remotePeerDescriptor: PeerDescriptor,
|
|
270
|
-
targetPeerDescriptor: PeerDescriptor,
|
|
271
|
-
candidate: string,
|
|
272
|
-
mid: string,
|
|
273
|
-
connectionId: string
|
|
274
|
-
): void {
|
|
275
|
-
if (this.stopped || !areEqualPeerDescriptors(targetPeerDescriptor, this.ownPeerDescriptor!)) {
|
|
276
|
-
return
|
|
277
|
-
}
|
|
278
|
-
const peerKey = keyFromPeerDescriptor(remotePeerDescriptor)
|
|
279
|
-
const connection = this.ongoingConnectAttempts.get(peerKey)?.getWebRtcConnection()
|
|
280
|
-
|
|
281
|
-
if (!connection) {
|
|
282
|
-
return
|
|
283
|
-
} else if (connection.connectionId.toString() !== connectionId) {
|
|
284
|
-
logger.trace(`Ignoring remote candidate due to connectionId mismatch`)
|
|
285
|
-
return
|
|
286
|
-
} else if (this.isIceCandidateAllowed(candidate)) {
|
|
287
|
-
connection.addRemoteCandidate(candidate, mid)
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public async stop(): Promise<void> {
|
|
292
|
-
logger.trace('stop()')
|
|
293
|
-
this.stopped = true
|
|
294
|
-
|
|
295
|
-
const attempts = Array.from(this.ongoingConnectAttempts.values())
|
|
296
|
-
await Promise.allSettled(attempts.map((conn) => conn.close('OTHER')))
|
|
297
|
-
|
|
298
|
-
this.rpcCommunicator.stop()
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
public isOffering(targetPeerDescriptor: PeerDescriptor): boolean {
|
|
302
|
-
const myId = peerIdFromPeerDescriptor(this.ownPeerDescriptor!)
|
|
303
|
-
const theirId = peerIdFromPeerDescriptor(targetPeerDescriptor)
|
|
304
|
-
return myId.hasSmallerHashThan(theirId)
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// IWebRTCConnector implementation
|
|
308
|
-
// TODO should we read connectionId from WebRtcConnectionRequest (or remove the field)?
|
|
309
|
-
async requestConnection(_request: WebRtcConnectionRequest, context: ServerCallContext): Promise<Empty> {
|
|
310
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
311
|
-
this.onConnectionRequest(senderPeerDescriptor)
|
|
312
|
-
return {}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty> {
|
|
316
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
317
|
-
const receiverPeerDescriptor = (context as DhtCallContext).incomingTargetDescriptor!
|
|
318
|
-
this.onRtcOffer(senderPeerDescriptor, receiverPeerDescriptor, request.description, request.connectionId)
|
|
319
|
-
return {}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
async rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty> {
|
|
323
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
324
|
-
const receiverPeerDescriptor = (context as DhtCallContext).incomingTargetDescriptor!
|
|
325
|
-
this.onRtcAnswer(senderPeerDescriptor, receiverPeerDescriptor, request.description, request.connectionId)
|
|
326
|
-
return {}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
async iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty> {
|
|
330
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
331
|
-
const receiverPeerDescriptor = (context as DhtCallContext).incomingTargetDescriptor!
|
|
332
|
-
this.onRemoteCandidate(senderPeerDescriptor, receiverPeerDescriptor, request.candidate, request.mid, request.connectionId)
|
|
333
|
-
return {}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { DhtNode } from '../dht/DhtNode'
|
|
2
|
-
import { ExternalStoreDataRequest, ExternalStoreDataResponse, FindDataRequest, FindDataResponse } from '../proto/packages/dht/protos/DhtRpc'
|
|
3
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
4
|
-
import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
|
|
5
|
-
|
|
6
|
-
export const registerExternalApiRpcMethods = (thisNode: DhtNode): void => {
|
|
7
|
-
const rpcCommunicator = thisNode.getRpcCommunicator()
|
|
8
|
-
rpcCommunicator.registerRpcMethod(
|
|
9
|
-
FindDataRequest,
|
|
10
|
-
FindDataResponse,
|
|
11
|
-
'findData',
|
|
12
|
-
(req: FindDataRequest, context: ServerCallContext) => findData(thisNode, req, context),
|
|
13
|
-
{ timeout: 10000 }
|
|
14
|
-
)
|
|
15
|
-
rpcCommunicator.registerRpcMethod(
|
|
16
|
-
ExternalStoreDataRequest,
|
|
17
|
-
ExternalStoreDataResponse,
|
|
18
|
-
'externalStoreData',
|
|
19
|
-
(req: ExternalStoreDataRequest) => externalStoreData(thisNode, req),
|
|
20
|
-
{ timeout: 10000 }
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// IDHTRpcService method for external findRecursive calls
|
|
25
|
-
const findData = async (thisNode: DhtNode, findDataRequest: FindDataRequest, context: ServerCallContext): Promise<FindDataResponse> => {
|
|
26
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
27
|
-
const result = await thisNode.startRecursiveFind(findDataRequest.kademliaId, true, senderPeerDescriptor)
|
|
28
|
-
if (result.dataEntries) {
|
|
29
|
-
return FindDataResponse.create({ dataEntries: result.dataEntries })
|
|
30
|
-
} else {
|
|
31
|
-
return FindDataResponse.create({
|
|
32
|
-
dataEntries: [],
|
|
33
|
-
error: 'Could not find data with the given key'
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// IDHTRpcService method for external storeData calls
|
|
39
|
-
const externalStoreData = async (thisNode: DhtNode, request: ExternalStoreDataRequest): Promise<ExternalStoreDataResponse> => {
|
|
40
|
-
const result = await thisNode.storeDataToDht(request.key, request.data!)
|
|
41
|
-
return ExternalStoreDataResponse.create({
|
|
42
|
-
storers: result
|
|
43
|
-
})
|
|
44
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { RecursiveFindResult, IRecursiveFinder } from '../../../src/dht/find/RecursiveFinder'
|
|
2
|
-
import { RouteMessageAck } from '../../../src/proto/packages/dht/protos/DhtRpc'
|
|
3
|
-
|
|
4
|
-
export class MockRecursiveFinder implements IRecursiveFinder {
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line class-methods-use-this
|
|
7
|
-
async startRecursiveFind(): Promise<RecursiveFindResult> {
|
|
8
|
-
return {
|
|
9
|
-
closestNodes: [],
|
|
10
|
-
dataEntries: []
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line class-methods-use-this
|
|
15
|
-
async findRecursively(): Promise<RouteMessageAck> {
|
|
16
|
-
return RouteMessageAck.create()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|