@streamr/dht 100.0.0-pretestnet.6 → 100.0.0-rc.1
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/README.md +90 -8
- package/dist/package.json +70 -0
- package/dist/src/connection/Connection.d.ts +1 -0
- package/dist/src/connection/Connection.js +10 -3
- package/dist/src/connection/Connection.js.map +1 -1
- package/dist/src/connection/ConnectionLockHandler.d.ts +14 -14
- package/dist/src/connection/ConnectionLockHandler.js +22 -16
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +7 -6
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js +10 -37
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +19 -20
- package/dist/src/connection/ConnectionManager.js +132 -117
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +3 -2
- package/dist/src/connection/ConnectorFacade.js +10 -3
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +3 -1
- package/dist/src/connection/Handshaker.js +19 -10
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +2 -7
- package/dist/src/connection/IConnection.js +1 -8
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +5 -7
- package/dist/src/connection/ManagedConnection.js +42 -26
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +9 -0
- package/dist/src/connection/connectivityChecker.js +130 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -0
- package/dist/src/connection/connectivityRequestHandler.d.ts +3 -0
- package/dist/src/connection/connectivityRequestHandler.js +101 -0
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -0
- package/dist/src/connection/simulator/Simulator.d.ts +0 -3
- package/dist/src/connection/simulator/Simulator.js +34 -69
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +27 -25
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +16 -12
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -3
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +40 -27
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +1 -2
- package/dist/src/connection/webrtc/WebrtcConnector.js +36 -32
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +4 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +28 -22
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +3 -6
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +2 -5
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +6 -4
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +1 -0
- package/dist/src/connection/websocket/ClientWebsocket.js +14 -7
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +3 -9
- package/dist/src/connection/websocket/WebsocketConnector.js +142 -74
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +5 -3
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +9 -12
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +4 -7
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +7 -44
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.d.ts +1 -4
- package/dist/src/connection/websocket/WebsocketServer.js +49 -40
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{ServerWebsocket.d.ts → WebsocketServerConnection.d.ts} +8 -4
- package/dist/src/connection/websocket/WebsocketServerConnection.js +97 -0
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +45 -49
- package/dist/src/dht/DhtNode.js +229 -317
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +10 -9
- package/dist/src/dht/DhtNodeRpcLocal.js +19 -11
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +15 -10
- package/dist/src/dht/DhtNodeRpcRemote.js +38 -21
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +7 -6
- package/dist/src/dht/ExternalApiRpcLocal.js +9 -13
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +6 -5
- package/dist/src/dht/ExternalApiRpcRemote.js +10 -7
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +61 -0
- package/dist/src/dht/PeerManager.js +288 -0
- package/dist/src/dht/PeerManager.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +2 -2
- package/dist/src/dht/contact/Contact.js +4 -3
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +8 -8
- package/dist/src/dht/contact/ContactList.js +12 -7
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +4 -4
- package/dist/src/dht/contact/RandomContactList.js +13 -12
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +31 -0
- package/dist/src/dht/contact/RingContactList.js +133 -0
- package/dist/src/dht/contact/RingContactList.js.map +1 -0
- package/dist/src/dht/contact/{Remote.d.ts → RpcRemote.d.ts} +8 -7
- package/dist/src/dht/contact/{Remote.js → RpcRemote.js} +16 -13
- package/dist/src/dht/contact/RpcRemote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +29 -15
- package/dist/src/dht/contact/SortedContactList.js +79 -42
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +16 -0
- package/dist/src/dht/contact/ringIdentifiers.js +54 -0
- package/dist/src/dht/contact/ringIdentifiers.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.d.ts +8 -18
- package/dist/src/dht/discovery/DiscoverySession.js +32 -48
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +16 -12
- package/dist/src/dht/discovery/PeerDiscovery.js +82 -39
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +29 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js +123 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +166 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +14 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +26 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +6 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +187 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +14 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +20 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +6 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +21 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/DuplicateDetector.d.ts +2 -4
- package/dist/src/dht/routing/DuplicateDetector.js +10 -15
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +11 -27
- package/dist/src/dht/routing/Router.js +92 -58
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -4
- package/dist/src/dht/routing/RouterRpcLocal.js +17 -16
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +3 -3
- package/dist/src/dht/routing/RouterRpcRemote.js +29 -20
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +29 -21
- package/dist/src/dht/routing/RoutingSession.js +93 -68
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +24 -0
- package/dist/src/dht/routing/RoutingTablesCache.js +46 -0
- package/dist/src/dht/routing/RoutingTablesCache.js.map +1 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +9 -14
- package/dist/src/dht/store/LocalDataStore.js +46 -72
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +33 -0
- package/dist/src/dht/store/StoreManager.js +182 -0
- package/dist/src/dht/store/StoreManager.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -41
- package/dist/src/dht/store/StoreRpcLocal.js +27 -234
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +6 -7
- package/dist/src/dht/store/StoreRpcRemote.js +10 -20
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +5 -3
- package/dist/src/exports.js +10 -8
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/AddressTools.js +2 -0
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.d.ts +14 -0
- package/dist/src/helpers/MapWithTtl.js +60 -0
- package/dist/src/helpers/MapWithTtl.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptor.d.ts +3 -0
- package/dist/src/helpers/createPeerDescriptor.js +57 -0
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +2 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +30 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/errors.js +2 -0
- package/dist/src/helpers/errors.js.map +1 -1
- package/dist/src/helpers/offering.d.ts +4 -0
- package/dist/src/helpers/offering.js +18 -0
- package/dist/src/helpers/offering.js.map +1 -0
- package/dist/src/helpers/protoClasses.js +2 -3
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +6 -0
- package/dist/src/helpers/version.js +38 -0
- package/dist/src/helpers/version.js.map +1 -0
- package/dist/src/identifiers.d.ts +10 -0
- package/dist/src/identifiers.js +31 -0
- package/dist/src/identifiers.js.map +1 -0
- package/dist/src/proto/google/protobuf/any.js +8 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.js +2 -4
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.js +10 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +46 -49
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +63 -54
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +226 -232
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +146 -168
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -29
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -2
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +2 -1
- package/dist/src/transport/ITransport.d.ts +10 -2
- package/dist/src/transport/ITransport.js +5 -0
- package/dist/src/transport/ITransport.js.map +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +3 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +4 -2
- package/dist/src/transport/RoutingRpcCommunicator.js +19 -12
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/jest.config.js +4 -1
- package/karma-setup.js +2 -0
- package/karma.config.js +13 -9
- package/package.json +17 -14
- package/protos/DhtRpc.proto +76 -76
- package/src/connection/Connection.ts +6 -1
- package/src/connection/ConnectionLockHandler.ts +30 -22
- package/src/connection/ConnectionLockRpcLocal.ts +7 -12
- package/src/connection/ConnectionLockRpcRemote.ts +9 -19
- package/src/connection/ConnectionManager.ts +132 -138
- package/src/connection/ConnectorFacade.ts +10 -9
- package/src/connection/Handshaker.ts +24 -12
- package/src/connection/IConnection.ts +2 -8
- package/src/connection/ManagedConnection.ts +34 -35
- package/src/connection/connectivityChecker.ts +109 -0
- package/src/connection/connectivityRequestHandler.ts +103 -0
- package/src/connection/simulator/Simulator.ts +6 -37
- package/src/connection/simulator/SimulatorConnection.ts +23 -25
- package/src/connection/simulator/SimulatorConnector.ts +11 -11
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +17 -25
- package/src/connection/webrtc/NodeWebrtcConnection.ts +25 -27
- package/src/connection/webrtc/WebrtcConnector.ts +31 -36
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +31 -25
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +4 -14
- package/src/connection/webrtc/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
- package/src/connection/websocket/ClientWebsocket.ts +10 -4
- package/src/connection/websocket/WebsocketConnector.ts +120 -97
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +13 -15
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +7 -27
- package/src/connection/websocket/WebsocketServer.ts +50 -53
- package/src/connection/websocket/WebsocketServerConnection.ts +104 -0
- package/src/dht/DhtNode.ts +289 -410
- package/src/dht/DhtNodeRpcLocal.ts +25 -17
- package/src/dht/DhtNodeRpcRemote.ts +43 -27
- package/src/dht/ExternalApiRpcLocal.ts +30 -17
- package/src/dht/ExternalApiRpcRemote.ts +14 -11
- package/src/dht/PeerManager.ts +339 -0
- package/src/dht/contact/Contact.ts +4 -4
- package/src/dht/contact/ContactList.ts +11 -10
- package/src/dht/contact/RandomContactList.ts +15 -15
- package/src/dht/contact/RingContactList.ts +151 -0
- package/src/dht/contact/{Remote.ts → RpcRemote.ts} +16 -19
- package/src/dht/contact/SortedContactList.ts +120 -72
- package/src/dht/contact/ringIdentifiers.ts +62 -0
- package/src/dht/discovery/DiscoverySession.ts +36 -61
- package/src/dht/discovery/PeerDiscovery.ts +98 -43
- package/src/dht/discovery/RingDiscoverySession.ts +160 -0
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +246 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +34 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +43 -0
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +232 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +35 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +30 -0
- package/src/dht/routing/DuplicateDetector.ts +9 -21
- package/src/dht/routing/Router.ts +95 -92
- package/src/dht/routing/RouterRpcLocal.ts +16 -18
- package/src/dht/routing/RouterRpcRemote.ts +26 -24
- package/src/dht/routing/RoutingSession.ts +119 -98
- package/src/dht/routing/RoutingTablesCache.ts +58 -0
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +47 -77
- package/src/dht/store/StoreManager.ts +209 -0
- package/src/dht/store/StoreRpcLocal.ts +39 -308
- package/src/dht/store/StoreRpcRemote.ts +13 -31
- package/src/exports.ts +13 -3
- package/src/helpers/AddressTools.ts +2 -0
- package/src/helpers/MapWithTtl.ts +71 -0
- package/src/helpers/createPeerDescriptor.ts +57 -0
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +28 -0
- package/src/helpers/offering.ts +15 -0
- package/src/helpers/protoClasses.ts +4 -6
- package/src/helpers/version.ts +32 -0
- package/src/identifiers.ts +29 -0
- package/src/proto/google/protobuf/any.ts +4 -4
- package/src/proto/google/protobuf/empty.ts +2 -4
- package/src/proto/google/protobuf/timestamp.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +65 -68
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +27 -30
- package/src/proto/packages/dht/protos/DhtRpc.ts +297 -313
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/rpc-protocol/DhtCallContext.ts +2 -2
- package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
- package/src/transport/ITransport.ts +11 -2
- package/src/transport/ListeningRpcCommunicator.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +21 -14
- package/test/RandomGraphSimulation.ts +3 -2
- package/test/benchmark/Find.test.ts +13 -28
- package/test/benchmark/KademliaCorrectness.test.ts +24 -28
- package/test/benchmark/RingCorrectness.test.ts +157 -0
- package/test/benchmark/SortedContactListBenchmark.test.ts +151 -0
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +41 -0
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +72 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +9 -9
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +11 -11
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +29 -25
- package/test/data/generateGroundTruthData.ts +7 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +11 -15
- package/test/end-to-end/Layer0.test.ts +19 -22
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +19 -21
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +26 -28
- package/test/end-to-end/Layer0Webrtc.test.ts +19 -19
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +10 -18
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +8 -15
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +2 -2
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +8 -9
- package/test/end-to-end/memory-leak.test.ts +19 -24
- package/test/integration/ConnectionLocking.test.ts +66 -60
- package/test/integration/ConnectionManager.test.ts +43 -63
- package/test/integration/ConnectivityChecking.test.ts +52 -0
- package/test/integration/DhtJoinPeerDiscovery.test.ts +8 -12
- package/test/integration/DhtNodeExternalAPI.test.ts +17 -21
- package/test/integration/DhtNodeRpcRemote.test.ts +19 -26
- package/test/integration/DhtRpc.test.ts +20 -24
- package/test/integration/Find.test.ts +10 -12
- package/test/integration/Layer1-scale.test.ts +25 -37
- package/test/integration/Mock-Layer1-Layer0.test.ts +39 -59
- package/test/integration/MultipleEntryPointJoining.test.ts +14 -14
- package/test/integration/ReplicateData.test.ts +106 -0
- package/test/integration/RouteMessage.test.ts +42 -68
- package/test/integration/RouterRpcRemote.test.ts +19 -24
- package/test/integration/ScaleDownDht.test.ts +14 -12
- package/test/integration/SimultaneousConnections.test.ts +112 -111
- package/test/integration/Store.test.ts +43 -27
- package/test/integration/StoreAndDelete.test.ts +36 -48
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +59 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +17 -37
- package/test/integration/StoreRpcRemote.test.ts +20 -32
- package/test/integration/WebrtcConnectionManagement.test.ts +39 -25
- package/test/integration/WebrtcConnectorRpc.test.ts +6 -11
- package/test/integration/WebsocketConnectionManagement.test.ts +87 -22
- package/test/integration/WebsocketConnectorRpc.test.ts +14 -24
- package/test/integration/{RpcErrors.test.ts → rpc-connections-over-webrpc.test.ts} +15 -26
- package/test/unit/AddressTools.test.ts +4 -0
- package/test/unit/ConnectivityHelpers.test.ts +9 -17
- package/test/unit/DuplicateDetector.test.ts +8 -5
- package/test/unit/LocalDataStore.test.ts +78 -75
- package/test/unit/PeerManager.test.ts +33 -0
- package/test/unit/RandomContactList.test.ts +12 -9
- package/test/unit/RecursiveOperationManager.test.ts +157 -0
- package/test/unit/RecursiveOperationSession.test.ts +68 -0
- package/test/unit/Router.test.ts +52 -35
- package/test/unit/RoutingSession.test.ts +79 -0
- package/test/unit/SortedContactList.test.ts +61 -30
- package/test/unit/StoreManager.test.ts +138 -0
- package/test/unit/WebsocketConnector.test.ts +27 -35
- package/test/unit/connectivityRequestHandler.test.ts +104 -0
- package/test/unit/createPeerDescriptor.test.ts +69 -0
- package/test/unit/customMatchers.test.ts +16 -0
- package/test/unit/version.test.ts +18 -0
- package/test/utils/FakeTransport.ts +47 -0
- package/test/utils/customMatchers.ts +71 -0
- package/test/utils/mock/MockRpcCommunicator.ts +7 -0
- package/test/utils/mock/Router.ts +13 -3
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/mock/mockDataEntry.ts +38 -0
- package/test/utils/utils.ts +104 -107
- package/tsconfig.browser.json +2 -1
- package/tsconfig.jest.json +4 -2
- package/tsconfig.node.json +4 -2
- package/dist/src/connection/ConnectivityChecker.d.ts +0 -17
- package/dist/src/connection/ConnectivityChecker.js +0 -208
- package/dist/src/connection/ConnectivityChecker.js.map +0 -1
- package/dist/src/connection/websocket/ServerWebsocket.js +0 -100
- package/dist/src/connection/websocket/ServerWebsocket.js.map +0 -1
- package/dist/src/dht/contact/Remote.js.map +0 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
- package/dist/src/dht/find/FindRpcLocal.js +0 -25
- package/dist/src/dht/find/FindRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSession.d.ts +0 -44
- package/dist/src/dht/find/FindSession.js +0 -145
- package/dist/src/dht/find/FindSession.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +0 -12
- package/dist/src/dht/find/FindSessionRpcLocal.js +0 -17
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcRemote.d.ts +0 -6
- package/dist/src/dht/find/FindSessionRpcRemote.js +0 -21
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +0 -1
- package/dist/src/dht/find/Finder.d.ts +0 -49
- package/dist/src/dht/find/Finder.js +0 -184
- package/dist/src/dht/find/Finder.js.map +0 -1
- package/dist/src/dht/routing/FindRpcRemote.d.ts +0 -6
- package/dist/src/dht/routing/FindRpcRemote.js +0 -41
- package/dist/src/dht/routing/FindRpcRemote.js.map +0 -1
- package/dist/src/helpers/PeerID.d.ts +0 -24
- package/dist/src/helpers/PeerID.js +0 -78
- package/dist/src/helpers/PeerID.js.map +0 -1
- package/dist/src/helpers/UUID.d.ts +0 -8
- package/dist/src/helpers/UUID.js +0 -36
- package/dist/src/helpers/UUID.js.map +0 -1
- package/dist/src/helpers/kademliaId.d.ts +0 -1
- package/dist/src/helpers/kademliaId.js +0 -14
- package/dist/src/helpers/kademliaId.js.map +0 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +0 -6
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +0 -23
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +0 -1
- package/src/connection/ConnectivityChecker.ts +0 -199
- package/src/connection/websocket/ServerWebsocket.ts +0 -114
- package/src/dht/find/FindRpcLocal.ts +0 -35
- package/src/dht/find/FindSession.ts +0 -178
- package/src/dht/find/FindSessionRpcLocal.ts +0 -25
- package/src/dht/find/FindSessionRpcRemote.ts +0 -30
- package/src/dht/find/Finder.ts +0 -275
- package/src/dht/routing/FindRpcRemote.ts +0 -40
- package/src/helpers/PeerID.ts +0 -88
- package/src/helpers/UUID.ts +0 -35
- package/src/helpers/kademliaId.ts +0 -8
- package/src/helpers/peerIdFromPeerDescriptor.ts +0 -20
- package/test/integration/MigrateData.test.ts +0 -204
- package/test/unit/Finder.test.ts +0 -110
- package/test/unit/PeerID.test.ts +0 -22
- package/test/unit/UUID.test.ts +0 -55
|
@@ -0,0 +1,123 @@
|
|
|
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.RingDiscoverySession = void 0;
|
|
7
|
+
const utils_1 = require("@streamr/utils");
|
|
8
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const identifiers_1 = require("../../identifiers");
|
|
11
|
+
const ringIdentifiers_1 = require("../contact/ringIdentifiers");
|
|
12
|
+
const logger = new utils_1.Logger(module);
|
|
13
|
+
class RingDiscoverySession {
|
|
14
|
+
id = (0, uuid_1.v4)();
|
|
15
|
+
stopped = false;
|
|
16
|
+
emitter = new eventemitter3_1.default();
|
|
17
|
+
noProgressCounter = 0;
|
|
18
|
+
ongoingClosestPeersRequests = new Set();
|
|
19
|
+
config;
|
|
20
|
+
numContactedPeers = 0;
|
|
21
|
+
targetIdAsRingId;
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.targetIdAsRingId = (0, ringIdentifiers_1.getRingIdFromRaw)(this.config.targetId);
|
|
25
|
+
}
|
|
26
|
+
addContacts(contacts) {
|
|
27
|
+
if (this.stopped) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.config.peerManager.addContact(contacts);
|
|
31
|
+
}
|
|
32
|
+
async getClosestPeersFromContact(contact) {
|
|
33
|
+
if (this.stopped) {
|
|
34
|
+
return { left: [], right: [] };
|
|
35
|
+
}
|
|
36
|
+
logger.trace(`Getting closest ring peers from contact: ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(contact.getPeerDescriptor())}`);
|
|
37
|
+
this.numContactedPeers++;
|
|
38
|
+
this.config.contactedPeers.add(contact.getNodeId());
|
|
39
|
+
const returnedContacts = await contact.getClosestRingPeers(this.config.targetId);
|
|
40
|
+
this.config.peerManager.setContactActive(contact.getNodeId());
|
|
41
|
+
return returnedContacts;
|
|
42
|
+
}
|
|
43
|
+
onClosestPeersRequestSucceeded(nodeId, contacts) {
|
|
44
|
+
if (!this.ongoingClosestPeersRequests.has(nodeId)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.ongoingClosestPeersRequests.delete(nodeId);
|
|
48
|
+
const oldClosestContacts = this.config.peerManager.getClosestRingContactsTo(this.config.targetId, 1);
|
|
49
|
+
const oldClosestLeftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(oldClosestContacts.left[0].getPeerDescriptor()));
|
|
50
|
+
const oldClosestRightDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(oldClosestContacts.right[0].getPeerDescriptor()));
|
|
51
|
+
this.addContacts(contacts.left.concat(contacts.right));
|
|
52
|
+
const newClosestContacts = this.config.peerManager.getClosestRingContactsTo(this.config.targetId, 1);
|
|
53
|
+
const newClosestLeftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(newClosestContacts.left[0].getPeerDescriptor()));
|
|
54
|
+
const newClosestRightDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(newClosestContacts.right[0].getPeerDescriptor()));
|
|
55
|
+
if (newClosestLeftDistance >= oldClosestLeftDistance && newClosestRightDistance >= oldClosestRightDistance) {
|
|
56
|
+
this.noProgressCounter++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onClosestPeersRequestFailed(peer) {
|
|
60
|
+
if (!this.ongoingClosestPeersRequests.has(peer.getNodeId())) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.ongoingClosestPeersRequests.delete(peer.getNodeId());
|
|
64
|
+
this.config.peerManager.removeContact(peer.getNodeId());
|
|
65
|
+
}
|
|
66
|
+
findMoreContacts() {
|
|
67
|
+
if (this.stopped) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const uncontacted = this.config.peerManager.getClosestRingContactsTo(this.config.targetId, this.config.parallelism, this.config.contactedPeers);
|
|
71
|
+
if ((uncontacted.left.length === 0 && uncontacted.right.length === 0)
|
|
72
|
+
|| this.noProgressCounter >= this.config.noProgressLimit) {
|
|
73
|
+
this.emitter.emit('discoveryCompleted');
|
|
74
|
+
this.stopped = true;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// ask from both sides equally
|
|
78
|
+
const merged = [];
|
|
79
|
+
const alreadyInMerged = new Set();
|
|
80
|
+
const length = Math.max(uncontacted.left.length, uncontacted.right.length);
|
|
81
|
+
for (let i = 0; i < length; i++) {
|
|
82
|
+
if (i < uncontacted.left.length) {
|
|
83
|
+
if (!alreadyInMerged.has(uncontacted.left[i].getNodeId())) {
|
|
84
|
+
merged.push(uncontacted.left[i]);
|
|
85
|
+
alreadyInMerged.add(uncontacted.left[i].getNodeId());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (i < uncontacted.right.length) {
|
|
89
|
+
if (!alreadyInMerged.has(uncontacted.right[i].getNodeId())) {
|
|
90
|
+
merged.push(uncontacted.right[i]);
|
|
91
|
+
alreadyInMerged.add(uncontacted.right[i].getNodeId());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const nextPeer of merged) {
|
|
96
|
+
if (this.ongoingClosestPeersRequests.size >= this.config.parallelism) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
this.ongoingClosestPeersRequests.add(nextPeer.getNodeId());
|
|
100
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
101
|
+
this.getClosestPeersFromContact(nextPeer)
|
|
102
|
+
.then((contacts) => this.onClosestPeersRequestSucceeded(nextPeer.getNodeId(), contacts))
|
|
103
|
+
.catch(() => this.onClosestPeersRequestFailed(nextPeer))
|
|
104
|
+
.finally(() => {
|
|
105
|
+
this.findMoreContacts();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async findClosestNodes(timeout) {
|
|
110
|
+
if (this.config.peerManager.getContactCount(this.config.contactedPeers) === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// TODO add abortController and signal it in stop()
|
|
114
|
+
await (0, utils_1.runAndWaitForEvents3)([this.findMoreContacts.bind(this)], [[this.emitter, 'discoveryCompleted']], timeout);
|
|
115
|
+
}
|
|
116
|
+
stop() {
|
|
117
|
+
this.stopped = true;
|
|
118
|
+
this.emitter.emit('discoveryCompleted');
|
|
119
|
+
this.emitter.removeAllListeners();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.RingDiscoverySession = RingDiscoverySession;
|
|
123
|
+
//# sourceMappingURL=RingDiscoverySession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RingDiscoverySession.js","sourceRoot":"","sources":["../../../../src/dht/discovery/RingDiscoverySession.ts"],"names":[],"mappings":";;;;;;AAAA,0CAA6D;AAC7D,kEAAwC;AACxC,+BAAyB;AAIzB,mDAA2E;AAC3E,gEAA8H;AAG9H,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAejC,MAAa,oBAAoB;IAEb,EAAE,GAAG,IAAA,SAAE,GAAE,CAAA;IACjB,OAAO,GAAG,KAAK,CAAA;IACf,OAAO,GAAG,IAAI,uBAAY,EAA8B,CAAA;IACxD,iBAAiB,GAAG,CAAC,CAAA;IACrB,2BAA2B,GAAoB,IAAI,GAAG,EAAE,CAAA;IAC/C,MAAM,CAA4B;IAC3C,iBAAiB,GAAG,CAAC,CAAA;IACrB,gBAAgB,CAAQ;IA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AAC,GAAG,EAAE;gBACV,IAAI,CAAC,gBAAgB,EAAE,CAAA;YAC3B,CAAC,CAAC,CAAA;QACV,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,OAAe;QACzC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5E,OAAM;QACV,CAAC;QACD,mDAAmD;QACnD,MAAM,IAAA,4BAAoB,EACtB,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAClC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,EACtC,OAAO,CACV,CAAA;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QACvC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAA;IACrC,CAAC;CACJ;AAtID,oDAsIC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DataEntry, PeerDescriptor, RecursiveOperation } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { Router } from '../routing/Router';
|
|
3
|
+
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator';
|
|
4
|
+
import { DhtNodeRpcRemote } from '../DhtNodeRpcRemote';
|
|
5
|
+
import { ITransport } from '../../transport/ITransport';
|
|
6
|
+
import { LocalDataStore } from '../store/LocalDataStore';
|
|
7
|
+
import { ServiceID } from '../../types/ServiceID';
|
|
8
|
+
import { DhtAddress } from '../../identifiers';
|
|
9
|
+
interface RecursiveOperationManagerConfig {
|
|
10
|
+
rpcCommunicator: RoutingRpcCommunicator;
|
|
11
|
+
sessionTransport: ITransport;
|
|
12
|
+
connections: Map<DhtAddress, DhtNodeRpcRemote>;
|
|
13
|
+
router: Router;
|
|
14
|
+
localPeerDescriptor: PeerDescriptor;
|
|
15
|
+
serviceId: ServiceID;
|
|
16
|
+
localDataStore: LocalDataStore;
|
|
17
|
+
addContact: (contact: PeerDescriptor) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface RecursiveOperationResult {
|
|
20
|
+
closestNodes: Array<PeerDescriptor>;
|
|
21
|
+
dataEntries?: Array<DataEntry>;
|
|
22
|
+
}
|
|
23
|
+
export declare class RecursiveOperationManager {
|
|
24
|
+
private ongoingSessions;
|
|
25
|
+
private stopped;
|
|
26
|
+
private readonly config;
|
|
27
|
+
constructor(config: RecursiveOperationManagerConfig);
|
|
28
|
+
private registerLocalRpcMethods;
|
|
29
|
+
execute(targetId: DhtAddress, operation: RecursiveOperation, excludedPeer?: DhtAddress, waitForCompletion?: boolean): Promise<RecursiveOperationResult>;
|
|
30
|
+
private sendResponse;
|
|
31
|
+
private doRouteRequest;
|
|
32
|
+
private getClosestConnections;
|
|
33
|
+
private isPeerCloserToIdThanSelf;
|
|
34
|
+
stop(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecursiveOperationManager = void 0;
|
|
4
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
5
|
+
const RoutingSession_1 = require("../routing/RoutingSession");
|
|
6
|
+
const utils_1 = require("@streamr/utils");
|
|
7
|
+
const RecursiveOperationSessionRpcRemote_1 = require("./RecursiveOperationSessionRpcRemote");
|
|
8
|
+
const RecursiveOperationSession_1 = require("./RecursiveOperationSession");
|
|
9
|
+
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
10
|
+
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
11
|
+
const SortedContactList_1 = require("../contact/SortedContactList");
|
|
12
|
+
const getPreviousPeer_1 = require("../routing/getPreviousPeer");
|
|
13
|
+
const RouterRpcLocal_1 = require("../routing/RouterRpcLocal");
|
|
14
|
+
const RecursiveOperationRpcLocal_1 = require("./RecursiveOperationRpcLocal");
|
|
15
|
+
const identifiers_1 = require("../../identifiers");
|
|
16
|
+
const PeerManager_1 = require("../PeerManager");
|
|
17
|
+
const logger = new utils_1.Logger(module);
|
|
18
|
+
class RecursiveOperationManager {
|
|
19
|
+
ongoingSessions = new Map();
|
|
20
|
+
stopped = false;
|
|
21
|
+
config;
|
|
22
|
+
constructor(config) {
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.registerLocalRpcMethods();
|
|
25
|
+
}
|
|
26
|
+
registerLocalRpcMethods() {
|
|
27
|
+
const rpcLocal = new RecursiveOperationRpcLocal_1.RecursiveOperationRpcLocal({
|
|
28
|
+
doRouteRequest: (routedMessage) => this.doRouteRequest(routedMessage),
|
|
29
|
+
addContact: (contact) => this.config.addContact(contact),
|
|
30
|
+
isMostLikelyDuplicate: (requestId) => this.config.router.isMostLikelyDuplicate(requestId),
|
|
31
|
+
addToDuplicateDetector: (requestId) => this.config.router.addToDuplicateDetector(requestId)
|
|
32
|
+
});
|
|
33
|
+
this.config.rpcCommunicator.registerRpcMethod(DhtRpc_1.RouteMessageWrapper, DhtRpc_1.RouteMessageAck, 'routeRequest', async (routedMessage) => {
|
|
34
|
+
if (this.stopped) {
|
|
35
|
+
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage, DhtRpc_1.RouteMessageError.STOPPED);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return rpcLocal.routeRequest(routedMessage);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async execute(targetId, operation, excludedPeer, waitForCompletion = true) {
|
|
43
|
+
if (this.stopped) {
|
|
44
|
+
return { closestNodes: [] };
|
|
45
|
+
}
|
|
46
|
+
const session = new RecursiveOperationSession_1.RecursiveOperationSession({
|
|
47
|
+
transport: this.config.sessionTransport,
|
|
48
|
+
targetId,
|
|
49
|
+
localPeerDescriptor: this.config.localPeerDescriptor,
|
|
50
|
+
// TODO use config option or named constant?
|
|
51
|
+
waitedRoutingPathCompletions: this.config.connections.size > 1 ? 2 : 1,
|
|
52
|
+
operation,
|
|
53
|
+
// TODO would it make sense to give excludedPeer as one of the fields RecursiveOperationSession?
|
|
54
|
+
doRouteRequest: (routedMessage) => {
|
|
55
|
+
return this.doRouteRequest(routedMessage, excludedPeer);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (this.config.connections.size === 0) {
|
|
59
|
+
const dataEntries = Array.from(this.config.localDataStore.values(targetId));
|
|
60
|
+
session.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.config.localPeerDescriptor), [this.config.localPeerDescriptor], [this.config.localPeerDescriptor], dataEntries, true);
|
|
61
|
+
return session.getResults();
|
|
62
|
+
}
|
|
63
|
+
this.ongoingSessions.set(session.getId(), session);
|
|
64
|
+
if (waitForCompletion === true) {
|
|
65
|
+
try {
|
|
66
|
+
await (0, utils_1.runAndWaitForEvents3)([() => session.start(this.config.serviceId)], [[session, 'completed']],
|
|
67
|
+
// TODO use config option or named constant?
|
|
68
|
+
15000);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
logger.debug(`start failed with error ${err}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
session.start(this.config.serviceId);
|
|
76
|
+
// Wait for delete operation to be sent out by the router
|
|
77
|
+
// TODO: Add a feature to wait for the router to pass the message?
|
|
78
|
+
await (0, utils_1.wait)(50);
|
|
79
|
+
}
|
|
80
|
+
if (operation === DhtRpc_1.RecursiveOperation.FETCH_DATA) {
|
|
81
|
+
const dataEntries = Array.from(this.config.localDataStore.values(targetId));
|
|
82
|
+
if (dataEntries.length > 0) {
|
|
83
|
+
this.sendResponse([this.config.localPeerDescriptor], this.config.localPeerDescriptor, session.getId(), [], dataEntries, true);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (operation === DhtRpc_1.RecursiveOperation.DELETE_DATA) {
|
|
87
|
+
this.config.localDataStore.markAsDeleted(targetId, (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.config.localPeerDescriptor));
|
|
88
|
+
}
|
|
89
|
+
this.ongoingSessions.delete(session.getId());
|
|
90
|
+
session.stop();
|
|
91
|
+
return session.getResults();
|
|
92
|
+
}
|
|
93
|
+
sendResponse(routingPath, targetPeerDescriptor, serviceId, closestNodes, dataEntries, noCloserNodesFound = false) {
|
|
94
|
+
const isOwnNode = (0, identifiers_1.areEqualPeerDescriptors)(this.config.localPeerDescriptor, targetPeerDescriptor);
|
|
95
|
+
if (isOwnNode && this.ongoingSessions.has(serviceId)) {
|
|
96
|
+
this.ongoingSessions.get(serviceId)
|
|
97
|
+
.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.config.localPeerDescriptor), routingPath, closestNodes, dataEntries, noCloserNodesFound);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// TODO use config option or named constant?
|
|
101
|
+
const remoteCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(serviceId, this.config.sessionTransport, { rpcRequestTimeout: 15000 });
|
|
102
|
+
const rpcRemote = new RecursiveOperationSessionRpcRemote_1.RecursiveOperationSessionRpcRemote(this.config.localPeerDescriptor, targetPeerDescriptor, remoteCommunicator, DhtRpc_client_1.RecursiveOperationSessionRpcClient,
|
|
103
|
+
// TODO use config option or named constant?
|
|
104
|
+
10000);
|
|
105
|
+
rpcRemote.sendResponse(routingPath, closestNodes, dataEntries, noCloserNodesFound);
|
|
106
|
+
remoteCommunicator.destroy();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
doRouteRequest(routedMessage, excludedPeer) {
|
|
110
|
+
if (this.stopped) {
|
|
111
|
+
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage, DhtRpc_1.RouteMessageError.STOPPED);
|
|
112
|
+
}
|
|
113
|
+
const targetId = (0, identifiers_1.getDhtAddressFromRaw)(routedMessage.target);
|
|
114
|
+
const request = routedMessage.message.body.recursiveOperationRequest;
|
|
115
|
+
// TODO use config option or named constant?
|
|
116
|
+
const closestPeersToDestination = this.getClosestConnections(targetId, 5);
|
|
117
|
+
const dataEntries = (request.operation === DhtRpc_1.RecursiveOperation.FETCH_DATA)
|
|
118
|
+
? Array.from(this.config.localDataStore.values(targetId))
|
|
119
|
+
: [];
|
|
120
|
+
if (request.operation === DhtRpc_1.RecursiveOperation.DELETE_DATA) {
|
|
121
|
+
this.config.localDataStore.markAsDeleted(targetId, (0, identifiers_1.getNodeIdFromPeerDescriptor)(routedMessage.sourcePeer));
|
|
122
|
+
}
|
|
123
|
+
if ((0, utils_1.areEqualBinaries)(this.config.localPeerDescriptor.nodeId, routedMessage.target)) {
|
|
124
|
+
// TODO this is also very similar case to what we do at line 255, could simplify the code paths?
|
|
125
|
+
this.sendResponse(routedMessage.routingPath, routedMessage.sourcePeer, request.sessionId, closestPeersToDestination, dataEntries, true);
|
|
126
|
+
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const ack = this.config.router.doRouteMessage(routedMessage, RoutingSession_1.RoutingMode.RECURSIVE, excludedPeer);
|
|
130
|
+
if ((ack.error === undefined) || (ack.error === DhtRpc_1.RouteMessageError.NO_TARGETS)) {
|
|
131
|
+
const noCloserContactsFound = (ack.error === DhtRpc_1.RouteMessageError.NO_TARGETS) ||
|
|
132
|
+
(closestPeersToDestination.length > 0
|
|
133
|
+
&& (0, getPreviousPeer_1.getPreviousPeer)(routedMessage)
|
|
134
|
+
&& !this.isPeerCloserToIdThanSelf(closestPeersToDestination[0], targetId));
|
|
135
|
+
this.sendResponse(routedMessage.routingPath, routedMessage.sourcePeer, request.sessionId, closestPeersToDestination, dataEntries, noCloserContactsFound);
|
|
136
|
+
}
|
|
137
|
+
return ack;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
getClosestConnections(referenceId, limit) {
|
|
141
|
+
const connectedPeers = Array.from(this.config.connections.values());
|
|
142
|
+
const closestPeers = new SortedContactList_1.SortedContactList({
|
|
143
|
+
referenceId,
|
|
144
|
+
maxSize: limit,
|
|
145
|
+
allowToContainReferenceId: true,
|
|
146
|
+
emitEvents: false
|
|
147
|
+
});
|
|
148
|
+
closestPeers.addContacts(connectedPeers);
|
|
149
|
+
return closestPeers.getClosestContacts(limit).map((peer) => peer.getPeerDescriptor());
|
|
150
|
+
}
|
|
151
|
+
isPeerCloserToIdThanSelf(peer, nodeIdOrDataKey) {
|
|
152
|
+
const nodeIdOrDataKeyRaw = (0, identifiers_1.getRawFromDhtAddress)(nodeIdOrDataKey);
|
|
153
|
+
const distance1 = (0, PeerManager_1.getDistance)(peer.nodeId, nodeIdOrDataKeyRaw);
|
|
154
|
+
const distance2 = (0, PeerManager_1.getDistance)(this.config.localPeerDescriptor.nodeId, nodeIdOrDataKeyRaw);
|
|
155
|
+
return distance1 < distance2;
|
|
156
|
+
}
|
|
157
|
+
stop() {
|
|
158
|
+
this.stopped = true;
|
|
159
|
+
this.ongoingSessions.forEach((session, _id) => {
|
|
160
|
+
session.stop();
|
|
161
|
+
});
|
|
162
|
+
this.ongoingSessions.clear();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.RecursiveOperationManager = RecursiveOperationManager;
|
|
166
|
+
//# sourceMappingURL=RecursiveOperationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecursiveOperationManager.js","sourceRoot":"","sources":["../../../../src/dht/recursive-operation/RecursiveOperationManager.ts"],"names":[],"mappings":";;;AAAA,mEAQ+C;AAE/C,8DAAuD;AACvD,0CAAqF;AAErF,6FAAyF;AACzF,2EAAwG;AAIxG,uFAAmF;AACnF,iFAAkG;AAClG,oEAAgE;AAChE,gEAA4D;AAC5D,8DAAiE;AAEjE,6EAAyE;AACzE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,CAAA;QAC9D,MAAM,SAAS,GAAG,IAAA,yBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;QACzF,OAAO,SAAS,GAAG,SAAS,CAAA;IAChC,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;YAC1C,OAAO,CAAC,IAAI,EAAE,CAAA;QAClB,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAChC,CAAC;CACJ;AA1MD,8DA0MC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PeerDescriptor, RouteMessageAck, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { IRecursiveOperationRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
3
|
+
interface RecursiveOperationRpcLocalConfig {
|
|
4
|
+
doRouteRequest: (routedMessage: RouteMessageWrapper) => RouteMessageAck;
|
|
5
|
+
addContact: (contact: PeerDescriptor, setActive?: boolean) => void;
|
|
6
|
+
isMostLikelyDuplicate: (requestId: string) => boolean;
|
|
7
|
+
addToDuplicateDetector: (requestId: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class RecursiveOperationRpcLocal implements IRecursiveOperationRpc {
|
|
10
|
+
private readonly config;
|
|
11
|
+
constructor(config: RecursiveOperationRpcLocalConfig);
|
|
12
|
+
routeRequest(routedMessage: RouteMessageWrapper): Promise<RouteMessageAck>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecursiveOperationRpcLocal = void 0;
|
|
4
|
+
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
6
|
+
const RouterRpcLocal_1 = require("../routing/RouterRpcLocal");
|
|
7
|
+
const getPreviousPeer_1 = require("../routing/getPreviousPeer");
|
|
8
|
+
const identifiers_1 = require("../../identifiers");
|
|
9
|
+
const logger = new utils_1.Logger(module);
|
|
10
|
+
class RecursiveOperationRpcLocal {
|
|
11
|
+
config;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
async routeRequest(routedMessage) {
|
|
16
|
+
if (this.config.isMostLikelyDuplicate(routedMessage.requestId)) {
|
|
17
|
+
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage, DhtRpc_1.RouteMessageError.DUPLICATE);
|
|
18
|
+
}
|
|
19
|
+
const senderId = (0, identifiers_1.getNodeIdFromPeerDescriptor)((0, getPreviousPeer_1.getPreviousPeer)(routedMessage) ?? routedMessage.sourcePeer);
|
|
20
|
+
logger.trace(`Received routeRequest call from ${senderId}`);
|
|
21
|
+
this.config.addToDuplicateDetector(routedMessage.requestId);
|
|
22
|
+
return this.config.doRouteRequest(routedMessage);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.RecursiveOperationRpcLocal = RecursiveOperationRpcLocal;
|
|
26
|
+
//# sourceMappingURL=RecursiveOperationRpcLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecursiveOperationRpcLocal.js","sourceRoot":"","sources":["../../../../src/dht/recursive-operation/RecursiveOperationRpcLocal.ts"],"names":[],"mappings":";;;AAAA,0CAAuC;AACvC,mEAAgI;AAEhI,8DAAiE;AACjE,gEAA4D;AAC5D,mDAA+D;AAE/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AASjC,MAAa,0BAA0B;IAElB,MAAM,CAAkC;IAEzD,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,aAAkC;QACjD,IAAI,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,OAAO,IAAA,sCAAqB,EAAC,aAAa,EAAE,0BAAiB,CAAC,SAAS,CAAC,CAAA;QAC5E,CAAC;QACD,MAAM,QAAQ,GAAG,IAAA,yCAA2B,EAAC,IAAA,iCAAe,EAAC,aAAa,CAAC,IAAI,aAAa,CAAC,UAAW,CAAC,CAAA;QACzG,MAAM,CAAC,KAAK,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAA;QAC3D,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAC3D,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;IACpD,CAAC;CACJ;AAjBD,gEAiBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { RecursiveOperationRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
+
import { RpcRemote } from '../contact/RpcRemote';
|
|
4
|
+
export declare class RecursiveOperationRpcRemote extends RpcRemote<RecursiveOperationRpcClient> {
|
|
5
|
+
routeRequest(params: RouteMessageWrapper): Promise<boolean>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RecursiveOperationRpcRemote = void 0;
|
|
4
|
+
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const RpcRemote_1 = require("../contact/RpcRemote");
|
|
7
|
+
const getPreviousPeer_1 = require("../routing/getPreviousPeer");
|
|
8
|
+
const identifiers_1 = require("../../identifiers");
|
|
9
|
+
const logger = new utils_1.Logger(module);
|
|
10
|
+
class RecursiveOperationRpcRemote extends RpcRemote_1.RpcRemote {
|
|
11
|
+
async routeRequest(params) {
|
|
12
|
+
const message = {
|
|
13
|
+
target: params.target,
|
|
14
|
+
sourcePeer: params.sourcePeer,
|
|
15
|
+
message: params.message,
|
|
16
|
+
requestId: params.requestId ?? (0, uuid_1.v4)(),
|
|
17
|
+
reachableThrough: params.reachableThrough ?? [],
|
|
18
|
+
routingPath: params.routingPath,
|
|
19
|
+
parallelRootNodeIds: params.parallelRootNodeIds
|
|
20
|
+
};
|
|
21
|
+
const options = this.formDhtRpcOptions({
|
|
22
|
+
connect: false
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
const ack = await this.getClient().routeRequest(message, options);
|
|
26
|
+
if (ack.error !== undefined) {
|
|
27
|
+
logger.trace('Next hop responded with error ' + ack.error);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
const previousPeer = (0, getPreviousPeer_1.getPreviousPeer)(params);
|
|
33
|
+
const fromNode = previousPeer
|
|
34
|
+
? (0, identifiers_1.getNodeIdFromPeerDescriptor)(previousPeer)
|
|
35
|
+
: (0, identifiers_1.getNodeIdFromPeerDescriptor)(params.sourcePeer);
|
|
36
|
+
const toNode = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor());
|
|
37
|
+
logger.debug(`Failed to send routeRequest message from ${fromNode} to ${toNode} with: ${err}`);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.RecursiveOperationRpcRemote = RecursiveOperationRpcRemote;
|
|
44
|
+
//# sourceMappingURL=RecursiveOperationRpcRemote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecursiveOperationRpcRemote.js","sourceRoot":"","sources":["../../../../src/dht/recursive-operation/RecursiveOperationRpcRemote.ts"],"names":[],"mappings":";;;AAA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I,CAAC,iBAAiB,EAAE,CAAC,CAAA;YACpE,MAAM,CAAC,KAAK,CAAC,4CAA4C,QAAQ,OAAO,MAAM,UAAU,GAAG,EAAE,CAAC,CAAA;YAC9F,OAAO,KAAK,CAAA;QAChB,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAhCD,kEAgCC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { DataEntry, PeerDescriptor, RecursiveOperation, RouteMessageWrapper, RouteMessageAck } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
+
import { ITransport } from '../../transport/ITransport';
|
|
4
|
+
import { RecursiveOperationResult } from './RecursiveOperationManager';
|
|
5
|
+
import { ServiceID } from '../../types/ServiceID';
|
|
6
|
+
import { DhtAddress } from '../../identifiers';
|
|
7
|
+
export interface RecursiveOperationSessionEvents {
|
|
8
|
+
completed: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface RecursiveOperationSessionConfig {
|
|
11
|
+
transport: ITransport;
|
|
12
|
+
targetId: DhtAddress;
|
|
13
|
+
localPeerDescriptor: PeerDescriptor;
|
|
14
|
+
waitedRoutingPathCompletions: number;
|
|
15
|
+
operation: RecursiveOperation;
|
|
16
|
+
doRouteRequest: (routedMessage: RouteMessageWrapper) => RouteMessageAck;
|
|
17
|
+
}
|
|
18
|
+
export declare class RecursiveOperationSession extends EventEmitter<RecursiveOperationSessionEvents> {
|
|
19
|
+
private readonly id;
|
|
20
|
+
private readonly rpcCommunicator;
|
|
21
|
+
private results;
|
|
22
|
+
private foundData;
|
|
23
|
+
private allKnownHops;
|
|
24
|
+
private reportedHops;
|
|
25
|
+
private timeoutTask?;
|
|
26
|
+
private completionEventEmitted;
|
|
27
|
+
private noCloserNodesReceivedCounter;
|
|
28
|
+
private readonly noCloserNodesReceivedFrom;
|
|
29
|
+
private readonly config;
|
|
30
|
+
constructor(config: RecursiveOperationSessionConfig);
|
|
31
|
+
private registerLocalRpcMethods;
|
|
32
|
+
start(serviceId: ServiceID): void;
|
|
33
|
+
private wrapRequest;
|
|
34
|
+
private isCompleted;
|
|
35
|
+
private hasNonStaleData;
|
|
36
|
+
onResponseReceived(sourceId: DhtAddress, routingPath: PeerDescriptor[], nodes: PeerDescriptor[], dataEntries: DataEntry[], noCloserNodesFound: boolean): void;
|
|
37
|
+
private addKnownHops;
|
|
38
|
+
private setHopAsReported;
|
|
39
|
+
private processFoundData;
|
|
40
|
+
private onNoCloserPeersFound;
|
|
41
|
+
getResults(): RecursiveOperationResult;
|
|
42
|
+
getId(): string;
|
|
43
|
+
stop(): void;
|
|
44
|
+
}
|