@streamr/dht 100.0.0-pretestnet.6 → 100.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +18 -9
- 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 +0 -2
- package/dist/src/connection/webrtc/WebrtcConnector.js +24 -25
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +27 -20
- 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 +16 -13
- 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 +23 -11
- 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 +24 -26
- package/src/connection/webrtc/WebrtcConnector.ts +18 -29
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +29 -24
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../../src/dht/routing/Router.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../../src/dht/routing/Router.ts"],"names":[],"mappings":";;;AAAA,mEAAyI;AACzI,qDAA0G;AAC1G,0CAAqF;AAErF,2DAAuD;AAEvD,+BAAyB;AACzB,qDAAwE;AACxE,mDAA0H;AAC1H,6DAAyD;AAezD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,MAAM;IAEE,eAAe,GAA0C,IAAI,GAAG,EAAE,CAAA;IAClE,kBAAkB,GAAG,IAAI,uCAAkB,EAAE,CAAA;IACtD,sBAAsB,GAAgC,IAAI,GAAG,EAAE,CAAA;IACvE,4CAA4C;IAC3B,wBAAwB,GAAsB,IAAI,qCAAiB,CAAC,KAAK,CAAC,CAAA;IACnF,OAAO,GAAG,KAAK,CAAA;IACN,MAAM,CAAc;IAErC,YAAY,MAAoB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,uBAAuB,EAAE,CAAA;IAClC,CAAC;IAEO,uBAAuB;QAC3B,MAAM,QAAQ,GAAG,IAAI,+BAAc,CAAC;YAChC,cAAc,EAAE,CAAC,aAAkC,EAAE,IAAkB,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,IAAI,CAAC;YACpH,UAAU,EAAE,CAAC,OAAuB,EAAE,SAAkB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC;YACvG,oBAAoB,EAAE,CAAC,aAAkC,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC;YACtG,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;YAC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CAAA;gBAC7C,CAAC,EAAE,KAAK,CAAC,CAAE,4CAA4C;aAC1D,CAAA;YACD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,EAAE,eAAe,CAAC,CAAA;QAC3D,CAAC;IACL,CAAC;CACJ;AAtND,wBAsNC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PeerDescriptor, RouteMessageAck, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
1
|
+
import { Message, PeerDescriptor, RouteMessageAck, RouteMessageError, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
2
|
import { IRouterRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
4
3
|
import { DuplicateDetector } from './DuplicateDetector';
|
|
5
4
|
import { RoutingMode } from './RoutingSession';
|
|
@@ -7,11 +6,11 @@ interface RouterRpcLocalConfig {
|
|
|
7
6
|
doRouteMessage: (routedMessage: RouteMessageWrapper, mode?: RoutingMode) => RouteMessageAck;
|
|
8
7
|
addContact: (contact: PeerDescriptor, setActive: boolean) => void;
|
|
9
8
|
setForwardingEntries: (routedMessage: RouteMessageWrapper) => void;
|
|
9
|
+
handleMessage: (message: Message) => void;
|
|
10
10
|
duplicateRequestDetector: DuplicateDetector;
|
|
11
11
|
localPeerDescriptor: PeerDescriptor;
|
|
12
|
-
connectionManager?: ConnectionManager;
|
|
13
12
|
}
|
|
14
|
-
export declare const createRouteMessageAck: (routedMessage: RouteMessageWrapper, error?:
|
|
13
|
+
export declare const createRouteMessageAck: (routedMessage: RouteMessageWrapper, error?: RouteMessageError) => RouteMessageAck;
|
|
15
14
|
export declare class RouterRpcLocal implements IRouterRpc {
|
|
16
15
|
private readonly config;
|
|
17
16
|
constructor(config: RouterRpcLocalConfig);
|
|
@@ -2,34 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RouterRpcLocal = exports.createRouteMessageAck = void 0;
|
|
4
4
|
const utils_1 = require("@streamr/utils");
|
|
5
|
-
const
|
|
5
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
6
6
|
const RoutingSession_1 = require("./RoutingSession");
|
|
7
|
+
const identifiers_1 = require("../../identifiers");
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
7
9
|
const logger = new utils_1.Logger(module);
|
|
8
10
|
const createRouteMessageAck = (routedMessage, error) => {
|
|
9
11
|
const ack = {
|
|
10
12
|
requestId: routedMessage.requestId,
|
|
11
|
-
error
|
|
13
|
+
error
|
|
12
14
|
};
|
|
13
15
|
return ack;
|
|
14
16
|
};
|
|
15
17
|
exports.createRouteMessageAck = createRouteMessageAck;
|
|
16
18
|
class RouterRpcLocal {
|
|
19
|
+
config;
|
|
17
20
|
constructor(config) {
|
|
18
21
|
this.config = config;
|
|
19
22
|
}
|
|
20
23
|
async routeMessage(routedMessage) {
|
|
21
24
|
if (this.config.duplicateRequestDetector.isMostLikelyDuplicate(routedMessage.requestId)) {
|
|
22
|
-
logger.trace(`Routing message ${routedMessage.requestId} from ${(0,
|
|
23
|
-
+ `to ${(0,
|
|
24
|
-
return (0, exports.createRouteMessageAck)(routedMessage,
|
|
25
|
+
logger.trace(`Routing message ${routedMessage.requestId} from ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(routedMessage.sourcePeer)} `
|
|
26
|
+
+ `to ${(0, identifiers_1.getDhtAddressFromRaw)(routedMessage.target)} is likely a duplicate`);
|
|
27
|
+
return (0, exports.createRouteMessageAck)(routedMessage, DhtRpc_1.RouteMessageError.DUPLICATE);
|
|
25
28
|
}
|
|
26
29
|
logger.trace(`Processing received routeMessage ${routedMessage.requestId}`);
|
|
27
|
-
this.config.addContact(routedMessage.sourcePeer, true);
|
|
28
30
|
this.config.duplicateRequestDetector.add(routedMessage.requestId);
|
|
29
|
-
if ((0,
|
|
31
|
+
if ((0, utils_1.areEqualBinaries)(this.config.localPeerDescriptor.nodeId, routedMessage.target)) {
|
|
30
32
|
logger.trace(`routing message targeted to self ${routedMessage.requestId}`);
|
|
31
33
|
this.config.setForwardingEntries(routedMessage);
|
|
32
|
-
this.config.
|
|
34
|
+
this.config.handleMessage(routedMessage.message);
|
|
33
35
|
return (0, exports.createRouteMessageAck)(routedMessage);
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
@@ -38,14 +40,13 @@ class RouterRpcLocal {
|
|
|
38
40
|
}
|
|
39
41
|
async forwardMessage(forwardMessage) {
|
|
40
42
|
if (this.config.duplicateRequestDetector.isMostLikelyDuplicate(forwardMessage.requestId)) {
|
|
41
|
-
logger.trace(`Forwarding message ${forwardMessage.requestId} from ${(0,
|
|
42
|
-
+ `to ${(0,
|
|
43
|
-
return (0, exports.createRouteMessageAck)(forwardMessage,
|
|
43
|
+
logger.trace(`Forwarding message ${forwardMessage.requestId} from ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(forwardMessage.sourcePeer)} `
|
|
44
|
+
+ `to ${(0, identifiers_1.getDhtAddressFromRaw)(forwardMessage.target)} is likely a duplicate`);
|
|
45
|
+
return (0, exports.createRouteMessageAck)(forwardMessage, DhtRpc_1.RouteMessageError.DUPLICATE);
|
|
44
46
|
}
|
|
45
47
|
logger.trace(`Processing received forward routeMessage ${forwardMessage.requestId}`);
|
|
46
|
-
this.config.addContact(forwardMessage.sourcePeer, true);
|
|
47
48
|
this.config.duplicateRequestDetector.add(forwardMessage.requestId);
|
|
48
|
-
if ((0,
|
|
49
|
+
if ((0, utils_1.areEqualBinaries)(this.config.localPeerDescriptor.nodeId, forwardMessage.target)) {
|
|
49
50
|
return this.forwardToDestination(forwardMessage);
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
@@ -55,11 +56,11 @@ class RouterRpcLocal {
|
|
|
55
56
|
forwardToDestination(routedMessage) {
|
|
56
57
|
logger.trace(`Forwarding found message targeted to self ${routedMessage.requestId}`);
|
|
57
58
|
const forwardedMessage = routedMessage.message;
|
|
58
|
-
if ((0,
|
|
59
|
-
this.config.
|
|
59
|
+
if ((0, identifiers_1.areEqualPeerDescriptors)(this.config.localPeerDescriptor, forwardedMessage.targetDescriptor)) {
|
|
60
|
+
this.config.handleMessage(forwardedMessage);
|
|
60
61
|
return (0, exports.createRouteMessageAck)(routedMessage);
|
|
61
62
|
}
|
|
62
|
-
return this.config.doRouteMessage({ ...routedMessage,
|
|
63
|
+
return this.config.doRouteMessage({ ...routedMessage, requestId: (0, uuid_1.v4)(), target: forwardedMessage.targetDescriptor.nodeId });
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
exports.RouterRpcLocal = RouterRpcLocal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterRpcLocal.js","sourceRoot":"","sources":["../../../../src/dht/routing/RouterRpcLocal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RouterRpcLocal.js","sourceRoot":"","sources":["../../../../src/dht/routing/RouterRpcLocal.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,mEAAyI;AAGzI,qDAA8C;AAC9C,mDAA8G;AAC9G,+BAAyB;AAWzB,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,qBAAqB,GAAG,CAAC,aAAkC,EAAE,KAAyB,EAAmB,EAAE;IACpH,MAAM,GAAG,GAAoB;QACzB,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,KAAK;KACR,CAAA;IACD,OAAO,GAAG,CAAA;AACd,CAAC,CAAA;AANY,QAAA,qBAAqB,yBAMjC;AAED,MAAa,cAAc;IAEN,MAAM,CAAsB;IAE7C,YAAY,MAA4B;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,aAAkC;QACjD,IAAI,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YACtF,MAAM,C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
|
import { RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class RouterRpcRemote extends
|
|
2
|
+
import { RouterRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
+
import { RpcRemote } from '../contact/RpcRemote';
|
|
4
|
+
export declare class RouterRpcRemote extends RpcRemote<RouterRpcClient> {
|
|
5
5
|
routeMessage(params: RouteMessageWrapper): Promise<boolean>;
|
|
6
6
|
forwardMessage(params: RouteMessageWrapper): Promise<boolean>;
|
|
7
7
|
}
|
|
@@ -1,66 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RouterRpcRemote = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
6
|
-
const Remote_1 = require("../contact/Remote");
|
|
7
4
|
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
7
|
+
const RpcRemote_1 = require("../contact/RpcRemote");
|
|
8
8
|
const getPreviousPeer_1 = require("./getPreviousPeer");
|
|
9
|
+
const identifiers_1 = require("../../identifiers");
|
|
9
10
|
const logger = new utils_1.Logger(module);
|
|
10
|
-
class RouterRpcRemote extends
|
|
11
|
+
class RouterRpcRemote extends RpcRemote_1.RpcRemote {
|
|
11
12
|
async routeMessage(params) {
|
|
12
13
|
const message = {
|
|
13
|
-
|
|
14
|
+
target: params.target,
|
|
14
15
|
sourcePeer: params.sourcePeer,
|
|
15
16
|
message: params.message,
|
|
16
17
|
requestId: params.requestId ?? (0, uuid_1.v4)(),
|
|
17
18
|
reachableThrough: params.reachableThrough ?? [],
|
|
18
|
-
routingPath: params.routingPath
|
|
19
|
+
routingPath: params.routingPath,
|
|
20
|
+
parallelRootNodeIds: params.parallelRootNodeIds
|
|
19
21
|
};
|
|
20
|
-
const options = this.formDhtRpcOptions(
|
|
22
|
+
const options = this.formDhtRpcOptions({
|
|
23
|
+
connect: false
|
|
24
|
+
});
|
|
21
25
|
try {
|
|
22
26
|
const ack = await this.getClient().routeMessage(message, options);
|
|
23
27
|
// Success signal if sent to destination and error includes duplicate
|
|
24
|
-
if (
|
|
25
|
-
&&
|
|
28
|
+
if (ack.error === DhtRpc_1.RouteMessageError.DUPLICATE
|
|
29
|
+
&& (0, utils_1.areEqualBinaries)(params.target, this.getPeerDescriptor().nodeId)) {
|
|
26
30
|
return true;
|
|
27
31
|
}
|
|
28
|
-
else if (ack.error
|
|
32
|
+
else if (ack.error !== undefined) {
|
|
29
33
|
return false;
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
catch (err) {
|
|
33
37
|
const previousPeer = (0, getPreviousPeer_1.getPreviousPeer)(params);
|
|
34
38
|
const fromNode = previousPeer
|
|
35
|
-
? (0,
|
|
36
|
-
: (0,
|
|
37
|
-
|
|
39
|
+
? (0, identifiers_1.getNodeIdFromPeerDescriptor)(previousPeer)
|
|
40
|
+
: (0, identifiers_1.getNodeIdFromPeerDescriptor)(params.sourcePeer);
|
|
41
|
+
const toNode = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor());
|
|
42
|
+
logger.trace(`Failed to send routeMessage from ${fromNode} to ${toNode} with: ${err}`);
|
|
38
43
|
return false;
|
|
39
44
|
}
|
|
40
45
|
return true;
|
|
41
46
|
}
|
|
42
47
|
async forwardMessage(params) {
|
|
43
48
|
const message = {
|
|
44
|
-
|
|
49
|
+
target: params.target,
|
|
45
50
|
sourcePeer: params.sourcePeer,
|
|
46
51
|
message: params.message,
|
|
47
52
|
requestId: params.requestId ?? (0, uuid_1.v4)(),
|
|
48
53
|
reachableThrough: params.reachableThrough ?? [],
|
|
49
|
-
routingPath: params.routingPath
|
|
54
|
+
routingPath: params.routingPath,
|
|
55
|
+
parallelRootNodeIds: params.parallelRootNodeIds
|
|
50
56
|
};
|
|
51
|
-
const options = this.formDhtRpcOptions(
|
|
57
|
+
const options = this.formDhtRpcOptions({
|
|
58
|
+
connect: false
|
|
59
|
+
});
|
|
52
60
|
try {
|
|
53
61
|
const ack = await this.getClient().forwardMessage(message, options);
|
|
54
|
-
if (ack.error
|
|
62
|
+
if (ack.error !== undefined) {
|
|
55
63
|
return false;
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
catch (err) {
|
|
59
67
|
const previousPeer = (0, getPreviousPeer_1.getPreviousPeer)(params);
|
|
60
68
|
const fromNode = previousPeer
|
|
61
|
-
? (0,
|
|
62
|
-
: (0,
|
|
63
|
-
|
|
69
|
+
? (0, identifiers_1.getNodeIdFromPeerDescriptor)(previousPeer)
|
|
70
|
+
: (0, identifiers_1.getNodeIdFromPeerDescriptor)(params.sourcePeer);
|
|
71
|
+
const toNode = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor());
|
|
72
|
+
logger.trace(`Failed to send forwardMessage from ${fromNode} to ${toNode} with: ${err}`);
|
|
64
73
|
return false;
|
|
65
74
|
}
|
|
66
75
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterRpcRemote.js","sourceRoot":"","sources":["../../../../src/dht/routing/RouterRpcRemote.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RouterRpcRemote.js","sourceRoot":"","sources":["../../../../src/dht/routing/RouterRpcRemote.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,+BAAyB;AACzB,mEAA+F;AAE/F,oDAAgD;AAChD,uDAAmD;AACnD,mDAA+D;AAE/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,eAAgB,SAAQ,qBAA0B;IAE3D,KAAK,CAAC,YAAY,CAAC,MAA2B;QAC1C,MAAM,OAAO,GAAwB;YACjC,MAAM,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AO,IAAI,CAAA;IACf,CAAC;CACJ;AAlED,0CAkEC"}
|
|
@@ -1,49 +1,57 @@
|
|
|
1
1
|
import { DhtNodeRpcRemote } from '../DhtNodeRpcRemote';
|
|
2
|
-
import { PeerID, PeerIDKey } from '../../helpers/PeerID';
|
|
3
2
|
import EventEmitter from 'eventemitter3';
|
|
4
3
|
import { PeerDescriptor, RouteMessageWrapper } from '../../proto/packages/dht/protos/DhtRpc';
|
|
5
4
|
import { RouterRpcRemote } from './RouterRpcRemote';
|
|
6
5
|
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator';
|
|
7
6
|
import { Contact } from '../contact/Contact';
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
import { RecursiveOperationRpcRemote } from '../recursive-operation/RecursiveOperationRpcRemote';
|
|
8
|
+
import { DhtAddress } from '../../identifiers';
|
|
9
|
+
import { RoutingTablesCache } from './RoutingTablesCache';
|
|
10
|
+
export declare class RoutingRemoteContact extends Contact {
|
|
10
11
|
private routerRpcRemote;
|
|
11
|
-
private
|
|
12
|
-
constructor(peer:
|
|
12
|
+
private recursiveOperationRpcRemote;
|
|
13
|
+
constructor(peer: PeerDescriptor, localPeerDescriptor: PeerDescriptor, rpcCommunicator: RoutingRpcCommunicator);
|
|
13
14
|
getRouterRpcRemote(): RouterRpcRemote;
|
|
14
|
-
|
|
15
|
+
getRecursiveOperationRpcRemote(): RecursiveOperationRpcRemote;
|
|
15
16
|
}
|
|
16
17
|
export interface RoutingSessionEvents {
|
|
17
|
-
routingSucceeded: (
|
|
18
|
-
partialSuccess: (
|
|
19
|
-
routingFailed: (
|
|
20
|
-
stopped: (
|
|
18
|
+
routingSucceeded: () => void;
|
|
19
|
+
partialSuccess: () => void;
|
|
20
|
+
routingFailed: () => void;
|
|
21
|
+
stopped: () => void;
|
|
21
22
|
}
|
|
22
23
|
export declare enum RoutingMode {
|
|
23
24
|
ROUTE = 0,
|
|
24
25
|
FORWARD = 1,
|
|
25
|
-
|
|
26
|
+
RECURSIVE = 2
|
|
27
|
+
}
|
|
28
|
+
interface RoutingSessionConfig {
|
|
29
|
+
rpcCommunicator: RoutingRpcCommunicator;
|
|
30
|
+
localPeerDescriptor: PeerDescriptor;
|
|
31
|
+
routedMessage: RouteMessageWrapper;
|
|
32
|
+
connections: Map<DhtAddress, DhtNodeRpcRemote>;
|
|
33
|
+
parallelism: number;
|
|
34
|
+
mode: RoutingMode;
|
|
35
|
+
excludedNodeIds: Set<DhtAddress>;
|
|
36
|
+
routingTablesCache: RoutingTablesCache;
|
|
26
37
|
}
|
|
27
38
|
export declare class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
28
39
|
readonly sessionId: string;
|
|
29
|
-
private readonly rpcCommunicator;
|
|
30
40
|
private ongoingRequests;
|
|
31
|
-
private
|
|
32
|
-
private readonly localPeerDescriptor;
|
|
33
|
-
private readonly messageToRoute;
|
|
34
|
-
private connections;
|
|
35
|
-
private readonly parallelism;
|
|
41
|
+
private contactedPeers;
|
|
36
42
|
private failedHopCounter;
|
|
37
43
|
private successfulHopCounter;
|
|
38
|
-
private readonly mode;
|
|
39
44
|
private stopped;
|
|
40
|
-
|
|
45
|
+
private readonly config;
|
|
46
|
+
constructor(config: RoutingSessionConfig);
|
|
41
47
|
private onRequestFailed;
|
|
42
48
|
private emitFailure;
|
|
43
49
|
private onRequestSucceeded;
|
|
44
50
|
private sendRouteMessageRequest;
|
|
45
|
-
|
|
46
|
-
sendMoreRequests(uncontacted:
|
|
51
|
+
updateAndGetRoutablePeers(): RoutingRemoteContact[];
|
|
52
|
+
sendMoreRequests(uncontacted: RoutingRemoteContact[]): void;
|
|
53
|
+
private addParallelRootIfSource;
|
|
54
|
+
private deleteParallelRootIfSource;
|
|
47
55
|
stop(): void;
|
|
48
56
|
}
|
|
49
57
|
export {};
|
|
@@ -3,87 +3,87 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RoutingSession = exports.RoutingMode = void 0;
|
|
6
|
+
exports.RoutingSession = exports.RoutingMode = exports.RoutingRemoteContact = void 0;
|
|
7
7
|
const SortedContactList_1 = require("../contact/SortedContactList");
|
|
8
|
-
const PeerID_1 = require("../../helpers/PeerID");
|
|
9
|
-
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
10
8
|
const utils_1 = require("@streamr/utils");
|
|
11
9
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
12
10
|
const uuid_1 = require("uuid");
|
|
13
11
|
const RouterRpcRemote_1 = require("./RouterRpcRemote");
|
|
14
12
|
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
15
|
-
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
16
13
|
const Contact_1 = require("../contact/Contact");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
14
|
+
const RecursiveOperationRpcRemote_1 = require("../recursive-operation/RecursiveOperationRpcRemote");
|
|
15
|
+
const RpcRemote_1 = require("../contact/RpcRemote");
|
|
19
16
|
const getPreviousPeer_1 = require("./getPreviousPeer");
|
|
17
|
+
const identifiers_1 = require("../../identifiers");
|
|
18
|
+
const lodash_1 = require("lodash");
|
|
20
19
|
const logger = new utils_1.Logger(module);
|
|
21
20
|
const MAX_FAILED_HOPS = 2;
|
|
22
|
-
|
|
21
|
+
const ROUTING_TABLE_MAX_SIZE = 20;
|
|
22
|
+
class RoutingRemoteContact extends Contact_1.Contact {
|
|
23
|
+
routerRpcRemote;
|
|
24
|
+
recursiveOperationRpcRemote;
|
|
23
25
|
constructor(peer, localPeerDescriptor, rpcCommunicator) {
|
|
24
|
-
super(peer
|
|
25
|
-
this.routerRpcRemote = new RouterRpcRemote_1.RouterRpcRemote(localPeerDescriptor, peer
|
|
26
|
-
this.
|
|
26
|
+
super(peer);
|
|
27
|
+
this.routerRpcRemote = new RouterRpcRemote_1.RouterRpcRemote(localPeerDescriptor, peer, rpcCommunicator, DhtRpc_client_1.RouterRpcClient, RpcRemote_1.EXISTING_CONNECTION_TIMEOUT);
|
|
28
|
+
this.recursiveOperationRpcRemote = new RecursiveOperationRpcRemote_1.RecursiveOperationRpcRemote(localPeerDescriptor, peer, rpcCommunicator, DhtRpc_client_1.RecursiveOperationRpcClient, RpcRemote_1.EXISTING_CONNECTION_TIMEOUT);
|
|
27
29
|
}
|
|
28
30
|
getRouterRpcRemote() {
|
|
29
31
|
return this.routerRpcRemote;
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
return this.
|
|
33
|
+
getRecursiveOperationRpcRemote() {
|
|
34
|
+
return this.recursiveOperationRpcRemote;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
37
|
+
exports.RoutingRemoteContact = RoutingRemoteContact;
|
|
35
38
|
var RoutingMode;
|
|
36
39
|
(function (RoutingMode) {
|
|
37
40
|
RoutingMode[RoutingMode["ROUTE"] = 0] = "ROUTE";
|
|
38
41
|
RoutingMode[RoutingMode["FORWARD"] = 1] = "FORWARD";
|
|
39
|
-
RoutingMode[RoutingMode["
|
|
42
|
+
RoutingMode[RoutingMode["RECURSIVE"] = 2] = "RECURSIVE";
|
|
40
43
|
})(RoutingMode || (exports.RoutingMode = RoutingMode = {}));
|
|
41
44
|
class RoutingSession extends eventemitter3_1.default {
|
|
42
|
-
|
|
45
|
+
sessionId = (0, uuid_1.v4)();
|
|
46
|
+
ongoingRequests = new Set();
|
|
47
|
+
contactedPeers = new Set();
|
|
48
|
+
failedHopCounter = 0;
|
|
49
|
+
successfulHopCounter = 0;
|
|
50
|
+
stopped = false;
|
|
51
|
+
config;
|
|
52
|
+
constructor(config) {
|
|
43
53
|
super();
|
|
44
|
-
this.
|
|
45
|
-
this.ongoingRequests = new Set();
|
|
46
|
-
this.failedHopCounter = 0;
|
|
47
|
-
this.successfulHopCounter = 0;
|
|
48
|
-
this.mode = RoutingMode.ROUTE;
|
|
49
|
-
this.stopped = false;
|
|
50
|
-
this.rpcCommunicator = rpcCommunicator;
|
|
51
|
-
this.localPeerDescriptor = localPeerDescriptor;
|
|
52
|
-
this.messageToRoute = messageToRoute;
|
|
53
|
-
this.connections = connections;
|
|
54
|
-
this.parallelism = parallelism;
|
|
55
|
-
this.mode = mode;
|
|
56
|
-
const previousPeer = (0, getPreviousPeer_1.getPreviousPeer)(messageToRoute);
|
|
57
|
-
const previousId = previousPeer ? PeerID_1.PeerID.fromValue(previousPeer.kademliaId) : undefined;
|
|
58
|
-
this.contactList = new SortedContactList_1.SortedContactList(PeerID_1.PeerID.fromValue(this.messageToRoute.destinationPeer.kademliaId), 10000, undefined, true, previousId, excludedPeerIDs);
|
|
54
|
+
this.config = config;
|
|
59
55
|
}
|
|
60
|
-
onRequestFailed(
|
|
56
|
+
onRequestFailed(nodeId) {
|
|
61
57
|
logger.trace('onRequestFailed() sessionId: ' + this.sessionId);
|
|
62
58
|
if (this.stopped) {
|
|
63
59
|
return;
|
|
64
60
|
}
|
|
65
|
-
if (this.ongoingRequests.has(
|
|
66
|
-
this.ongoingRequests.delete(
|
|
61
|
+
if (this.ongoingRequests.has(nodeId)) {
|
|
62
|
+
this.ongoingRequests.delete(nodeId);
|
|
67
63
|
}
|
|
68
|
-
|
|
64
|
+
this.deleteParallelRootIfSource(nodeId);
|
|
65
|
+
this.failedHopCounter += 1;
|
|
66
|
+
if (this.failedHopCounter >= MAX_FAILED_HOPS) {
|
|
67
|
+
logger.trace(`Stopping routing after ${MAX_FAILED_HOPS} failed attempts for sessionId: ${this.sessionId}`);
|
|
68
|
+
this.emitFailure();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const contacts = this.updateAndGetRoutablePeers();
|
|
69
72
|
if (contacts.length === 0 && this.ongoingRequests.size === 0) {
|
|
70
73
|
logger.trace('routing failed, emitting routingFailed sessionId: ' + this.sessionId);
|
|
71
|
-
// TODO should call this.stop() so that we do cleanup? (after the emitFailure call)
|
|
72
|
-
this.stopped = true;
|
|
73
74
|
this.emitFailure();
|
|
74
75
|
}
|
|
75
76
|
else {
|
|
76
|
-
this.failedHopCounter += 1;
|
|
77
77
|
logger.trace('routing failed, retrying to route sessionId: ' + this.sessionId + ' failedHopCounter: ' + this.failedHopCounter);
|
|
78
78
|
this.sendMoreRequests(contacts);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
emitFailure() {
|
|
82
82
|
if (this.successfulHopCounter >= 1) {
|
|
83
|
-
this.emit('partialSuccess'
|
|
83
|
+
this.emit('partialSuccess');
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
this.emit('routingFailed'
|
|
86
|
+
this.emit('routingFailed');
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
onRequestSucceeded() {
|
|
@@ -92,11 +92,13 @@ class RoutingSession extends eventemitter3_1.default {
|
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
this.successfulHopCounter += 1;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
if (this.successfulHopCounter >= this.config.parallelism) {
|
|
96
|
+
this.emit('routingSucceeded');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const contacts = this.updateAndGetRoutablePeers();
|
|
100
|
+
if (contacts.length === 0) {
|
|
101
|
+
this.emit('routingSucceeded');
|
|
100
102
|
}
|
|
101
103
|
else if (contacts.length > 0 && this.ongoingRequests.size === 0) {
|
|
102
104
|
this.sendMoreRequests(contacts);
|
|
@@ -107,27 +109,43 @@ class RoutingSession extends eventemitter3_1.default {
|
|
|
107
109
|
return false;
|
|
108
110
|
}
|
|
109
111
|
const msg = {
|
|
110
|
-
...this.
|
|
111
|
-
routingPath: this.
|
|
112
|
+
...this.config.routedMessage,
|
|
113
|
+
routingPath: this.config.routedMessage.routingPath.concat([this.config.localPeerDescriptor])
|
|
112
114
|
};
|
|
113
|
-
if (this.mode === RoutingMode.FORWARD) {
|
|
115
|
+
if (this.config.mode === RoutingMode.FORWARD) {
|
|
114
116
|
return contact.getRouterRpcRemote().forwardMessage(msg);
|
|
115
117
|
}
|
|
116
|
-
else if (this.mode === RoutingMode.
|
|
117
|
-
return contact.
|
|
118
|
+
else if (this.config.mode === RoutingMode.RECURSIVE) {
|
|
119
|
+
return contact.getRecursiveOperationRpcRemote().routeRequest(msg);
|
|
118
120
|
}
|
|
119
121
|
else {
|
|
120
122
|
return contact.getRouterRpcRemote().routeMessage(msg);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
|
-
|
|
124
|
-
logger.trace('
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
|
|
125
|
+
updateAndGetRoutablePeers() {
|
|
126
|
+
logger.trace('getRoutablePeers() sessionId: ' + this.sessionId);
|
|
127
|
+
const previousPeer = (0, getPreviousPeer_1.getPreviousPeer)(this.config.routedMessage);
|
|
128
|
+
const previousId = previousPeer ? (0, identifiers_1.getNodeIdFromPeerDescriptor)(previousPeer) : undefined;
|
|
129
|
+
const targetId = (0, identifiers_1.getDhtAddressFromRaw)(this.config.routedMessage.target);
|
|
130
|
+
let routingTable;
|
|
131
|
+
if (this.config.routingTablesCache.has(targetId, previousId)) {
|
|
132
|
+
routingTable = this.config.routingTablesCache.get(targetId, previousId);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
routingTable = new SortedContactList_1.SortedContactList({
|
|
136
|
+
referenceId: (0, identifiers_1.getDhtAddressFromRaw)(this.config.routedMessage.target),
|
|
137
|
+
maxSize: ROUTING_TABLE_MAX_SIZE,
|
|
138
|
+
allowToContainReferenceId: true,
|
|
139
|
+
nodeIdDistanceLimit: previousId,
|
|
140
|
+
emitEvents: false
|
|
141
|
+
});
|
|
142
|
+
const contacts = Array.from(this.config.connections.values())
|
|
143
|
+
.map((peer) => new RoutingRemoteContact(peer.getPeerDescriptor(), this.config.localPeerDescriptor, this.config.rpcCommunicator));
|
|
144
|
+
routingTable.addContacts(contacts);
|
|
145
|
+
this.config.routingTablesCache.set(targetId, routingTable, previousId);
|
|
146
|
+
}
|
|
147
|
+
return routingTable.getAllContacts()
|
|
148
|
+
.filter((contact) => !this.contactedPeers.has(contact.getNodeId()) && !this.config.excludedNodeIds.has(contact.getNodeId()));
|
|
131
149
|
}
|
|
132
150
|
sendMoreRequests(uncontacted) {
|
|
133
151
|
logger.trace('sendMoreRequests() sessionId: ' + this.sessionId);
|
|
@@ -138,17 +156,13 @@ class RoutingSession extends eventemitter3_1.default {
|
|
|
138
156
|
this.emitFailure();
|
|
139
157
|
return;
|
|
140
158
|
}
|
|
141
|
-
|
|
142
|
-
logger.trace(`Stopping routing after ${MAX_FAILED_HOPS} failed attempts for sessionId: ${this.sessionId}`);
|
|
143
|
-
this.emitFailure();
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
while ((this.ongoingRequests.size < this.parallelism) && (uncontacted.length > 0) && !this.stopped) {
|
|
159
|
+
while ((this.ongoingRequests.size < this.config.parallelism) && (uncontacted.length > 0) && !this.stopped) {
|
|
147
160
|
const nextPeer = uncontacted.shift();
|
|
148
161
|
// eslint-disable-next-line max-len
|
|
149
|
-
logger.trace(`Sending routeMessage request to contact: ${(0,
|
|
150
|
-
this.
|
|
151
|
-
this.ongoingRequests.add(nextPeer.
|
|
162
|
+
logger.trace(`Sending routeMessage request to contact: ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(nextPeer.getPeerDescriptor())} (sessionId=${this.sessionId})`);
|
|
163
|
+
this.contactedPeers.add(nextPeer.getNodeId());
|
|
164
|
+
this.ongoingRequests.add(nextPeer.getNodeId());
|
|
165
|
+
this.addParallelRootIfSource(nextPeer.getNodeId());
|
|
152
166
|
setImmediate(async () => {
|
|
153
167
|
try {
|
|
154
168
|
const succeeded = await this.sendRouteMessageRequest(nextPeer);
|
|
@@ -156,7 +170,7 @@ class RoutingSession extends eventemitter3_1.default {
|
|
|
156
170
|
this.onRequestSucceeded();
|
|
157
171
|
}
|
|
158
172
|
else {
|
|
159
|
-
this.onRequestFailed(nextPeer.
|
|
173
|
+
this.onRequestFailed(nextPeer.getNodeId());
|
|
160
174
|
}
|
|
161
175
|
}
|
|
162
176
|
catch (e) {
|
|
@@ -168,10 +182,21 @@ class RoutingSession extends eventemitter3_1.default {
|
|
|
168
182
|
});
|
|
169
183
|
}
|
|
170
184
|
}
|
|
185
|
+
addParallelRootIfSource(nodeId) {
|
|
186
|
+
if (this.config.mode === RoutingMode.RECURSIVE
|
|
187
|
+
&& (0, identifiers_1.areEqualPeerDescriptors)(this.config.localPeerDescriptor, this.config.routedMessage.sourcePeer)) {
|
|
188
|
+
this.config.routedMessage.parallelRootNodeIds.push(nodeId);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
deleteParallelRootIfSource(nodeId) {
|
|
192
|
+
if (this.config.mode === RoutingMode.RECURSIVE
|
|
193
|
+
&& (0, identifiers_1.areEqualPeerDescriptors)(this.config.localPeerDescriptor, this.config.routedMessage.sourcePeer)) {
|
|
194
|
+
(0, lodash_1.pull)(this.config.routedMessage.parallelRootNodeIds, nodeId);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
171
197
|
stop() {
|
|
172
198
|
this.stopped = true;
|
|
173
|
-
this.
|
|
174
|
-
this.emit('stopped', this.sessionId);
|
|
199
|
+
this.emit('stopped');
|
|
175
200
|
this.removeAllListeners();
|
|
176
201
|
}
|
|
177
202
|
}
|