@streamr/dht 101.1.2 → 102.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -1
- package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +16 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +16 -2
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/package.json +11 -11
- package/dist/src/connection/Connection.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
- package/dist/src/connection/ConnectionLockStates.js +14 -0
- package/dist/src/connection/ConnectionLockStates.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -1
- package/dist/src/connection/ConnectionManager.js +78 -24
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectionsView.d.ts +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +1 -1
- package/dist/src/connection/Handshaker.d.ts +1 -1
- package/dist/src/connection/Handshaker.js +2 -2
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +24 -1
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/PendingConnection.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +2 -1
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +1 -1
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -1
- package/dist/src/connection/simulator/Simulator.js +2 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +9 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +7 -7
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +4 -2
- package/dist/src/dht/DhtNode.js +17 -6
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
- package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +1 -1
- package/dist/src/dht/PeerManager.js +10 -10
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +1 -1
- package/dist/src/dht/contact/Contact.js +1 -1
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +1 -1
- package/dist/src/dht/contact/RingContactList.js +1 -1
- package/dist/src/dht/contact/RingContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
- package/dist/src/dht/contact/SortedContactList.js +1 -1
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/Router.d.ts +4 -1
- package/dist/src/dht/routing/Router.js +17 -9
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +5 -6
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +2 -2
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js +7 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +6 -6
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +1 -1
- package/dist/src/helpers/Connectivity.js +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -2
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/identifiers.d.ts +5 -5
- package/dist/src/identifiers.js +11 -11
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
- package/dist/src/transport/ITransport.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
- package/{src/proto → generated}/google/protobuf/any.ts +11 -4
- package/{src/proto → generated}/google/protobuf/empty.ts +0 -1
- package/{src/proto → generated}/google/protobuf/timestamp.ts +9 -3
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.client.ts +12 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.server.ts +5 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.ts +23 -1
- package/package.json +11 -11
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +5 -0
- package/src/connection/Connection.ts +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +16 -7
- package/src/connection/ConnectionLockRpcRemote.ts +18 -6
- package/src/connection/ConnectionLockStates.ts +18 -0
- package/src/connection/ConnectionManager.ts +92 -26
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +3 -3
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +2 -1
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +4 -4
- package/src/connection/simulator/SimulatorConnection.ts +10 -10
- package/src/connection/simulator/SimulatorConnector.ts +5 -5
- package/src/connection/simulator/SimulatorTransport.ts +3 -2
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -9
- package/src/connection/webrtc/WebrtcConnector.ts +10 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
- package/src/connection/websocket/WebsocketServerConnector.ts +8 -8
- package/src/dht/DhtNode.ts +21 -8
- package/src/dht/DhtNodeRpcLocal.ts +7 -7
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/ExternalApiRpcLocal.ts +8 -8
- package/src/dht/ExternalApiRpcRemote.ts +6 -6
- package/src/dht/PeerManager.ts +12 -12
- package/src/dht/contact/Contact.ts +3 -3
- package/src/dht/contact/RingContactList.ts +3 -3
- package/src/dht/contact/RpcRemote.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +2 -2
- package/src/dht/contact/ringIdentifiers.ts +1 -1
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +12 -12
- package/src/dht/discovery/RingDiscoverySession.ts +3 -3
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
- package/src/dht/routing/Router.ts +19 -10
- package/src/dht/routing/RouterRpcLocal.ts +7 -7
- package/src/dht/routing/RouterRpcRemote.ts +9 -9
- package/src/dht/routing/RoutingSession.ts +7 -8
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +4 -4
- package/src/dht/store/StoreManager.ts +12 -12
- package/src/dht/store/StoreRpcLocal.ts +8 -8
- package/src/dht/store/StoreRpcRemote.ts +10 -7
- package/src/exports.ts +5 -5
- package/src/helpers/Connectivity.ts +1 -1
- package/src/helpers/createPeerDescriptor.ts +3 -3
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
- package/src/helpers/protoClasses.ts +1 -1
- package/src/identifiers.ts +7 -7
- package/src/rpc-protocol/DhtCallContext.ts +1 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
- package/src/transport/ITransport.ts +2 -1
- package/src/transport/ListeningRpcCommunicator.ts +14 -6
- package/src/transport/RoutingRpcCommunicator.ts +2 -2
- package/test/benchmark/Find.test.ts +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +5 -5
- package/test/benchmark/RingCorrectness.test.ts +5 -5
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +1 -1
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
- package/test/end-to-end/memory-leak.test.ts +4 -4
- package/test/integration/ConnectionLocking.test.ts +16 -15
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +2 -1
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +4 -4
- package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
- package/test/integration/DhtRpc.test.ts +12 -13
- package/test/integration/Find.test.ts +5 -5
- package/test/integration/GeoIpConnectivityChecking.test.ts +2 -1
- package/test/integration/Layer1-scale.test.ts +2 -2
- package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
- package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
- package/test/integration/ReplicateData.test.ts +10 -11
- package/test/integration/RouteMessage.test.ts +9 -9
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +13 -12
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +9 -9
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/StoreRpcRemote.test.ts +10 -10
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -3
- package/test/integration/WebrtcConnectorRpc.test.ts +9 -9
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +8 -9
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +4 -3
- package/test/unit/ConnectionManager.test.ts +4 -3
- package/test/unit/ConnectivityHelpers.test.ts +1 -1
- package/test/unit/DiscoverySession.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +1 -1
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +13 -13
- package/test/unit/PendingConnection.test.ts +1 -1
- package/test/unit/ProtobufMessage.test.ts +1 -1
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/RecursiveOperationManager.test.ts +3 -3
- package/test/unit/RecursiveOperationSession.test.ts +4 -4
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +6 -6
- package/test/unit/SortedContactList.test.ts +5 -5
- package/test/unit/StoreManager.test.ts +10 -10
- package/test/unit/StoreRpcLocal.test.ts +9 -9
- package/test/unit/WebrtcConnection.test.ts +29 -0
- package/test/unit/WebsocketClientConnector.test.ts +1 -1
- package/test/unit/WebsocketServerConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +1 -1
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +3 -3
- package/test/utils/mock/MockConnectionsView.ts +1 -1
- package/test/utils/mock/MockRouter.ts +5 -1
- package/test/utils/mock/MockTransport.ts +6 -1
- package/test/utils/mock/mockDataEntry.ts +6 -6
- package/test/utils/topology.ts +3 -3
- package/test/utils/utils.ts +9 -9
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/tests.d.ts +0 -39
- package/dist/src/proto/tests.js +0 -34
- package/dist/src/proto/tests.js.map +0 -1
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.ts +0 -0
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toNodeId } from '../../identifiers'
|
|
2
2
|
import {
|
|
3
3
|
ReplicateDataRequest,
|
|
4
4
|
StoreDataRequest
|
|
5
|
-
} from '
|
|
6
|
-
import { StoreRpcClient } from '
|
|
5
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
6
|
+
import { StoreRpcClient } from '../../../generated/packages/dht/protos/DhtRpc.client'
|
|
7
7
|
import { EXISTING_CONNECTION_TIMEOUT, RpcRemote } from '../contact/RpcRemote'
|
|
8
8
|
|
|
9
9
|
export class StoreRpcRemote extends RpcRemote<StoreRpcClient> {
|
|
@@ -13,15 +13,18 @@ export class StoreRpcRemote extends RpcRemote<StoreRpcClient> {
|
|
|
13
13
|
try {
|
|
14
14
|
await this.getClient().storeData(request, options)
|
|
15
15
|
} catch (err) {
|
|
16
|
-
const to =
|
|
17
|
-
const from =
|
|
16
|
+
const to = toNodeId(this.getPeerDescriptor())
|
|
17
|
+
const from = toNodeId(this.getLocalPeerDescriptor())
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
18
19
|
throw new Error(`Could not store data to ${to} from ${from} ${err}`)
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
async replicateData(request: ReplicateDataRequest): Promise<void> {
|
|
23
|
+
async replicateData(request: ReplicateDataRequest, connect: boolean): Promise<void> {
|
|
23
24
|
const options = this.formDhtRpcOptions({
|
|
24
|
-
timeout: EXISTING_CONNECTION_TIMEOUT
|
|
25
|
+
timeout: EXISTING_CONNECTION_TIMEOUT,
|
|
26
|
+
notification: true,
|
|
27
|
+
connect
|
|
25
28
|
})
|
|
26
29
|
return this.getClient().replicateData(request, options)
|
|
27
30
|
}
|
package/src/exports.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { RoutingRpcCommunicator } from './transport/RoutingRpcCommunicator'
|
|
|
4
4
|
export { Simulator, LatencyType } from './connection/simulator/Simulator'
|
|
5
5
|
export { SimulatorTransport } from './connection/simulator/SimulatorTransport'
|
|
6
6
|
export { getRandomRegion, getRegionDelayMatrix } from './connection/simulator/pings'
|
|
7
|
-
export { PeerDescriptor, Message, NodeType, DataEntry } from '
|
|
7
|
+
export { PeerDescriptor, Message, NodeType, DataEntry } from '../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
export { ITransport, TransportEvents } from './transport/ITransport'
|
|
9
9
|
export { ConnectionManager, ConnectionLocker, PortRange, TlsCertificate } from './connection/ConnectionManager'
|
|
10
10
|
export { ConnectionsView } from './connection/ConnectionsView'
|
|
@@ -25,9 +25,9 @@ export { createOutgoingHandshaker } from './connection/Handshaker'
|
|
|
25
25
|
export {
|
|
26
26
|
DhtAddress,
|
|
27
27
|
DhtAddressRaw,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
toDhtAddress,
|
|
29
|
+
toDhtAddressRaw,
|
|
30
|
+
randomDhtAddress,
|
|
31
31
|
areEqualPeerDescriptors,
|
|
32
|
-
|
|
32
|
+
toNodeId
|
|
33
33
|
} from './identifiers'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionType } from '../connection/IConnection'
|
|
2
|
-
import { ConnectivityMethod, NodeType, PeerDescriptor } from '
|
|
2
|
+
import { ConnectivityMethod, NodeType, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { isPrivateIPv4 } from './AddressTools'
|
|
4
4
|
|
|
5
5
|
export const canOpenConnectionFromBrowser = (websocketServer: ConnectivityMethod): boolean => {
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
import crypto from 'crypto'
|
|
6
6
|
import { isBrowserEnvironment } from '../helpers/browser/isBrowserEnvironment'
|
|
7
7
|
import { createPeerDescriptorSignaturePayload } from '../helpers/createPeerDescriptorSignaturePayload'
|
|
8
|
-
import { DhtAddress, DhtAddressRaw,
|
|
8
|
+
import { DhtAddress, DhtAddressRaw, toDhtAddressRaw } from '../identifiers'
|
|
9
9
|
import {
|
|
10
10
|
ConnectivityResponse,
|
|
11
11
|
NodeType,
|
|
12
12
|
PeerDescriptor
|
|
13
|
-
} from '
|
|
13
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
14
14
|
|
|
15
15
|
const calculateNodeIdRaw = (ipAddress: number, privateKey: Uint8Array): DhtAddressRaw => {
|
|
16
16
|
// nodeId is calculated as
|
|
@@ -34,7 +34,7 @@ export const createPeerDescriptor = (connectivityResponse: ConnectivityResponse,
|
|
|
34
34
|
const publicKey = crypto.randomBytes(20) // TODO calculate publicKey from privateKey
|
|
35
35
|
let nodeIdRaw: DhtAddressRaw
|
|
36
36
|
if (nodeId !== undefined) {
|
|
37
|
-
nodeIdRaw =
|
|
37
|
+
nodeIdRaw = toDhtAddressRaw(nodeId)
|
|
38
38
|
} else {
|
|
39
39
|
nodeIdRaw = calculateNodeIdRaw(connectivityResponse.ipAddress, privateKey)
|
|
40
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectivityMethod, PeerDescriptor } from '
|
|
1
|
+
import { ConnectivityMethod, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
|
|
3
3
|
function convertUnsignedIntegerToBuffer(number: number): Buffer {
|
|
4
4
|
const buffer = Buffer.alloc(4)
|
package/src/identifiers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BrandedString, areEqualBinaries, binaryToHex, hexToBinary } from '@streamr/utils'
|
|
2
2
|
import crypto from 'crypto'
|
|
3
|
-
import { PeerDescriptor } from '
|
|
3
|
+
import { PeerDescriptor } from '../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
|
|
5
5
|
// https://www.scs.stanford.edu/~dm/home/papers/kpos.pdf
|
|
6
6
|
export const KADEMLIA_ID_LENGTH_IN_BYTES = 20
|
|
@@ -8,22 +8,22 @@ export const KADEMLIA_ID_LENGTH_IN_BYTES = 20
|
|
|
8
8
|
export type DhtAddress = BrandedString<'DhtAddress'>
|
|
9
9
|
export type DhtAddressRaw = Uint8Array
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const toDhtAddress = (raw: DhtAddressRaw): DhtAddress => {
|
|
12
12
|
return binaryToHex(raw) as unknown as DhtAddress
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const toDhtAddressRaw = (address: DhtAddress): DhtAddressRaw => {
|
|
16
16
|
return hexToBinary(address) as unknown as DhtAddressRaw
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const
|
|
20
|
-
return
|
|
19
|
+
export const toNodeId = (peerDescriptor: PeerDescriptor): DhtAddress => {
|
|
20
|
+
return toDhtAddress(peerDescriptor.nodeId)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const areEqualPeerDescriptors = (peerDescriptor1: PeerDescriptor, peerDescriptor2: PeerDescriptor): boolean => {
|
|
24
24
|
return areEqualBinaries(peerDescriptor1.nodeId, peerDescriptor2.nodeId)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
return
|
|
27
|
+
export const randomDhtAddress = (): DhtAddress => {
|
|
28
|
+
return toDhtAddress(crypto.randomBytes(KADEMLIA_ID_LENGTH_IN_BYTES))
|
|
29
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtoCallContext } from '@streamr/proto-rpc'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { DhtRpcOptions } from './DhtRpcOptions'
|
|
4
4
|
|
|
5
5
|
export class DhtCallContext extends ProtoCallContext implements DhtRpcOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtoRpcOptions } from '@streamr/proto-rpc'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
|
|
4
4
|
export interface DhtRpcOptions extends ProtoRpcOptions {
|
|
5
5
|
targetDescriptor?: PeerDescriptor
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, PeerDescriptor } from '
|
|
1
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
|
|
3
3
|
export interface TransportEvents {
|
|
4
4
|
disconnected: (peerDescriptor: PeerDescriptor, gracefulLeave: boolean) => void
|
|
@@ -33,4 +33,5 @@ export interface ITransport {
|
|
|
33
33
|
send(msg: Message, opts?: SendOptions): Promise<void>
|
|
34
34
|
getLocalPeerDescriptor(): PeerDescriptor
|
|
35
35
|
stop(): void | Promise<void>
|
|
36
|
+
getDiagnosticInfo(): Record<string, unknown>
|
|
36
37
|
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { ITransport } from './ITransport'
|
|
2
2
|
import { RoutingRpcCommunicator } from './RoutingRpcCommunicator'
|
|
3
|
-
import { RpcCommunicatorOptions } from '@streamr/proto-rpc'
|
|
4
|
-
import { Message } from '
|
|
3
|
+
import { RpcCommunicatorOptions, RpcError } from '@streamr/proto-rpc'
|
|
4
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { ServiceID } from '../types/ServiceID'
|
|
6
|
+
import { areEqualPeerDescriptors } from '../identifiers'
|
|
6
7
|
|
|
7
8
|
export class ListeningRpcCommunicator extends RoutingRpcCommunicator {
|
|
8
9
|
private readonly transport: ITransport
|
|
9
|
-
private readonly
|
|
10
|
+
private readonly messageListener: (msg: Message) => void
|
|
11
|
+
private readonly disconnectedListener: (peerDescriptor: PeerDescriptor) => void
|
|
10
12
|
|
|
11
13
|
constructor(ownServiceId: ServiceID, transport: ITransport, options?: RpcCommunicatorOptions) {
|
|
12
14
|
super(ownServiceId, (msg, opts) => transport.send(msg, opts), options)
|
|
13
|
-
this.
|
|
15
|
+
this.messageListener = (msg: Message) => {
|
|
14
16
|
this.handleMessageFromPeer(msg)
|
|
15
17
|
}
|
|
18
|
+
this.disconnectedListener = (peerDescriptor: PeerDescriptor) => {
|
|
19
|
+
const requests = this.getRequestIds((request) => areEqualPeerDescriptors(peerDescriptor, request.getCallContext().targetDescriptor!))
|
|
20
|
+
requests.forEach((id) => this.handleClientError(id, new RpcError.Disconnected('Peer disconnected')))
|
|
21
|
+
}
|
|
16
22
|
this.transport = transport
|
|
17
|
-
transport.on('message', this.
|
|
23
|
+
transport.on('message', this.messageListener)
|
|
24
|
+
transport.on('disconnected', this.disconnectedListener)
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
destroy(): void {
|
|
21
|
-
this.transport.off('message', this.
|
|
28
|
+
this.transport.off('message', this.messageListener)
|
|
29
|
+
this.transport.off('disconnected', this.disconnectedListener)
|
|
22
30
|
this.stop()
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Message, PeerDescriptor } from '
|
|
1
|
+
import { Message, PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { v4 } from 'uuid'
|
|
3
3
|
import { RpcCommunicator, RpcCommunicatorOptions } from '@streamr/proto-rpc'
|
|
4
4
|
import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
|
|
5
|
-
import { RpcMessage } from '
|
|
5
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { ServiceID } from '../types/ServiceID'
|
|
7
7
|
import { DEFAULT_SEND_OPTIONS, SendOptions } from './ITransport'
|
|
8
8
|
|
|
@@ -6,7 +6,7 @@ import { execSync } from 'child_process'
|
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
import { Logger, wait } from '@streamr/utils'
|
|
8
8
|
import { debugVars } from '../../src/helpers/debugHelpers'
|
|
9
|
-
import {
|
|
9
|
+
import { toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
10
10
|
|
|
11
11
|
const logger = new Logger(module)
|
|
12
12
|
|
|
@@ -26,10 +26,10 @@ describe('Find correctness', () => {
|
|
|
26
26
|
beforeEach(async () => {
|
|
27
27
|
|
|
28
28
|
nodes = []
|
|
29
|
-
entryPoint = await createMockConnectionDhtNode(simulator,
|
|
29
|
+
entryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), undefined)
|
|
30
30
|
|
|
31
31
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
32
|
-
const node = await createMockConnectionDhtNode(simulator,
|
|
32
|
+
const node = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)), undefined)
|
|
33
33
|
nodes.push(node)
|
|
34
34
|
}
|
|
35
35
|
})
|
|
@@ -55,7 +55,7 @@ describe('Find correctness', () => {
|
|
|
55
55
|
debugVars['waiting'] = false
|
|
56
56
|
logger.info('waiting over')
|
|
57
57
|
|
|
58
|
-
nodes.forEach((node) => logger.info(
|
|
58
|
+
nodes.forEach((node) => logger.info(toNodeId(node.getLocalPeerDescriptor()) + ': connections:' +
|
|
59
59
|
node.getConnectionsView().getConnectionCount() + ', kbucket: ' + node.getNeighborCount()
|
|
60
60
|
+ ', localLocked: ' + node.getLocalLockedConnectionCount()
|
|
61
61
|
+ ', remoteLocked: ' + node.getRemoteLockedConnectionCount()
|
|
@@ -63,10 +63,10 @@ describe('Find correctness', () => {
|
|
|
63
63
|
|
|
64
64
|
logger.info('starting find')
|
|
65
65
|
const targetId = Uint8Array.from(dhtIds[9].data)
|
|
66
|
-
const closestNodes = await nodes[159].findClosestNodesFromDht(
|
|
66
|
+
const closestNodes = await nodes[159].findClosestNodesFromDht(toDhtAddress(targetId))
|
|
67
67
|
logger.info('find over')
|
|
68
68
|
expect(closestNodes).toBeGreaterThanOrEqual(5)
|
|
69
|
-
expect(
|
|
69
|
+
expect(toDhtAddress(targetId)).toEqual(toNodeId(closestNodes[0]))
|
|
70
70
|
|
|
71
71
|
}, 180000)
|
|
72
72
|
})
|
|
@@ -4,7 +4,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
4
4
|
import { createMockConnectionDhtNode } from '../utils/utils'
|
|
5
5
|
import { execSync } from 'child_process'
|
|
6
6
|
import fs from 'fs'
|
|
7
|
-
import { DhtAddress,
|
|
7
|
+
import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
8
8
|
import { Logger } from '@streamr/utils'
|
|
9
9
|
|
|
10
10
|
const logger = new Logger(module)
|
|
@@ -28,12 +28,12 @@ describe('Kademlia correctness', () => {
|
|
|
28
28
|
|
|
29
29
|
beforeEach(async () => {
|
|
30
30
|
nodes = []
|
|
31
|
-
entryPoint = await createMockConnectionDhtNode(simulator,
|
|
31
|
+
entryPoint = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), 8)
|
|
32
32
|
nodes.push(entryPoint)
|
|
33
33
|
nodeIndicesById[entryPoint.getNodeId()] = 0
|
|
34
34
|
|
|
35
35
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
36
|
-
const node = await createMockConnectionDhtNode(simulator,
|
|
36
|
+
const node = await createMockConnectionDhtNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)))
|
|
37
37
|
nodeIndicesById[node.getNodeId()] = i
|
|
38
38
|
nodes.push(node)
|
|
39
39
|
}
|
|
@@ -68,7 +68,7 @@ describe('Kademlia correctness', () => {
|
|
|
68
68
|
groundTruthString += groundTruth[i + ''][j].name + ','
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) =>
|
|
71
|
+
const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => toNodeId(p))
|
|
72
72
|
|
|
73
73
|
let kadString = 'kademliaNeighbors: '
|
|
74
74
|
kademliaNeighbors.forEach((neighbor) => {
|
|
@@ -84,7 +84,7 @@ describe('Kademlia correctness', () => {
|
|
|
84
84
|
correctNeighbors++
|
|
85
85
|
}
|
|
86
86
|
} catch {
|
|
87
|
-
console.error('Node ' +
|
|
87
|
+
console.error('Node ' + toNodeId(nodes[i].getLocalPeerDescriptor()) + ' had only '
|
|
88
88
|
+ kademliaNeighbors.length + ' kademlia neighbors')
|
|
89
89
|
}
|
|
90
90
|
if (correctNeighbors === 0) {
|
|
@@ -4,7 +4,7 @@ import { DhtNode } from '../../src/dht/DhtNode'
|
|
|
4
4
|
import { createMockRingNode } from '../utils/utils'
|
|
5
5
|
import { execSync } from 'child_process'
|
|
6
6
|
import fs from 'fs'
|
|
7
|
-
import { DhtAddress,
|
|
7
|
+
import { DhtAddress, toDhtAddress, toNodeId } from '../../src/identifiers'
|
|
8
8
|
import { Logger } from '@streamr/utils'
|
|
9
9
|
import { getRingIdRawFromPeerDescriptor } from '../../src/dht/contact/ringIdentifiers'
|
|
10
10
|
|
|
@@ -43,12 +43,12 @@ describe('Ring correctness', () => {
|
|
|
43
43
|
beforeEach(async () => {
|
|
44
44
|
jest.setTimeout(60000)
|
|
45
45
|
nodes = []
|
|
46
|
-
entryPoint = await createMockRingNode(simulator,
|
|
46
|
+
entryPoint = await createMockRingNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[0].data)), regions[0])
|
|
47
47
|
nodes.push(entryPoint)
|
|
48
48
|
nodeIndicesById[entryPoint.getNodeId()] = 0
|
|
49
49
|
|
|
50
50
|
for (let i = 1; i < NUM_NODES; i++) {
|
|
51
|
-
const node = await createMockRingNode(simulator,
|
|
51
|
+
const node = await createMockRingNode(simulator, toDhtAddress(Uint8Array.from(dhtIds[i].data)), regions[i + 1])
|
|
52
52
|
nodeIndicesById[node.getNodeId()] = i
|
|
53
53
|
nodes.push(node)
|
|
54
54
|
}
|
|
@@ -111,7 +111,7 @@ describe('Ring correctness', () => {
|
|
|
111
111
|
groundTruthString += groundTruth[i + ''][j].name + ','
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) =>
|
|
114
|
+
const kademliaNeighbors = nodes[i].getClosestContacts(8).map((p) => toNodeId(p))
|
|
115
115
|
|
|
116
116
|
let kadString = 'kademliaNeighbors: '
|
|
117
117
|
kademliaNeighbors.forEach((neighbor) => {
|
|
@@ -127,7 +127,7 @@ describe('Ring correctness', () => {
|
|
|
127
127
|
correctNeighbors++
|
|
128
128
|
}
|
|
129
129
|
} catch {
|
|
130
|
-
console.error('Node ' +
|
|
130
|
+
console.error('Node ' + toNodeId(nodes[i].getLocalPeerDescriptor()) + ' had only '
|
|
131
131
|
+ kademliaNeighbors.length + ' kademlia neighbors')
|
|
132
132
|
}
|
|
133
133
|
if (correctNeighbors === 0) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import KBucket from 'k-bucket'
|
|
4
4
|
import { SortedContactList } from '../../src/dht/contact/SortedContactList'
|
|
5
|
-
import { DhtAddress, DhtAddressRaw,
|
|
5
|
+
import { DhtAddress, DhtAddressRaw, randomDhtAddress, toDhtAddressRaw } from '../../src/identifiers'
|
|
6
6
|
|
|
7
7
|
const NUM_ADDS = 1000
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ interface Item {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const createRandomItem = (index: number): Item => {
|
|
16
|
-
const nodeId =
|
|
17
|
-
const nodeIdRaw =
|
|
16
|
+
const nodeId = randomDhtAddress()
|
|
17
|
+
const nodeIdRaw = toDhtAddressRaw(nodeId)
|
|
18
18
|
return {
|
|
19
19
|
getNodeId: () => nodeId,
|
|
20
20
|
id: nodeIdRaw,
|
|
@@ -38,7 +38,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
38
38
|
randomIds.push(createRandomItem(i))
|
|
39
39
|
}
|
|
40
40
|
const list = new SortedContactList({
|
|
41
|
-
referenceId:
|
|
41
|
+
referenceId: randomDhtAddress(),
|
|
42
42
|
allowToContainReferenceId: true
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
48
48
|
}
|
|
49
49
|
console.timeEnd('SortedContactList.addContact()')
|
|
50
50
|
|
|
51
|
-
const kBucket = new KBucket<Item>({ localNodeId:
|
|
51
|
+
const kBucket = new KBucket<Item>({ localNodeId: toDhtAddressRaw(randomDhtAddress()) })
|
|
52
52
|
console.time('KBucket.add()')
|
|
53
53
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
54
54
|
kBucket.add(randomIds[i])
|
|
@@ -64,14 +64,14 @@ describe('SortedContactListBenchmark', () => {
|
|
|
64
64
|
|
|
65
65
|
console.time('kBucket closest()')
|
|
66
66
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
67
|
-
kBucket.closest(
|
|
67
|
+
kBucket.closest(toDhtAddressRaw(randomDhtAddress()), 20)
|
|
68
68
|
}
|
|
69
69
|
console.timeEnd('kBucket closest()')
|
|
70
70
|
|
|
71
71
|
console.time('SortedContactList.getClosestContacts()')
|
|
72
72
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
73
73
|
const closest = new SortedContactList<Item>({
|
|
74
|
-
referenceId:
|
|
74
|
+
referenceId: randomDhtAddress(),
|
|
75
75
|
allowToContainReferenceId: true
|
|
76
76
|
})
|
|
77
77
|
|
|
@@ -84,7 +84,7 @@ describe('SortedContactListBenchmark', () => {
|
|
|
84
84
|
console.time('SortedContactList.getClosestContacts() and addContacts()')
|
|
85
85
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
86
86
|
const closest = new SortedContactList<Item>({
|
|
87
|
-
referenceId:
|
|
87
|
+
referenceId: randomDhtAddress(),
|
|
88
88
|
allowToContainReferenceId: true
|
|
89
89
|
})
|
|
90
90
|
|
|
@@ -97,10 +97,10 @@ describe('SortedContactListBenchmark', () => {
|
|
|
97
97
|
const shuffled = shuffleArray(kBucket.toArray())
|
|
98
98
|
console.time('kbucket add and closest')
|
|
99
99
|
for (let i = 0; i < NUM_ADDS; i++) {
|
|
100
|
-
const bucket2 = new KBucket<Item>({ localNodeId:
|
|
100
|
+
const bucket2 = new KBucket<Item>({ localNodeId: toDhtAddressRaw(randomDhtAddress()) })
|
|
101
101
|
|
|
102
102
|
shuffled.forEach((contact) => bucket2.add(contact))
|
|
103
|
-
bucket2.closest(
|
|
103
|
+
bucket2.closest(toDhtAddressRaw(randomDhtAddress()), 20)
|
|
104
104
|
}
|
|
105
105
|
console.timeEnd('kbucket add and closest')
|
|
106
106
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectivityResponse, PeerDescriptor } from '../../../
|
|
1
|
+
import { ConnectivityResponse, PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { createPeerDescriptor } from '../../../src/helpers/createPeerDescriptor'
|
|
3
3
|
import { NatType } from '../../../src/connection/ConnectionManager'
|
|
4
4
|
import { ipv4ToNumber, Logger } from '@streamr/utils'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import {
|
|
2
|
+
import { randomDhtAddress, toNodeId } from '../../src/identifiers'
|
|
3
3
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
4
|
|
|
5
5
|
describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
@@ -26,25 +26,25 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
26
26
|
|
|
27
27
|
layer0EntryPoint = new DhtNode({ peerDescriptor: entrypointDescriptor, websocketServerEnableTls: false })
|
|
28
28
|
|
|
29
|
-
const layer0Node1Id =
|
|
29
|
+
const layer0Node1Id = randomDhtAddress()
|
|
30
30
|
layer0Node1 = new DhtNode({
|
|
31
31
|
nodeId: layer0Node1Id,
|
|
32
32
|
entryPoints: [entrypointDescriptor]
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
const layer0Node2Id =
|
|
35
|
+
const layer0Node2Id = randomDhtAddress()
|
|
36
36
|
layer0Node2 = new DhtNode({
|
|
37
37
|
nodeId: layer0Node2Id,
|
|
38
38
|
entryPoints: [entrypointDescriptor]
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
const layer0Node3Id =
|
|
41
|
+
const layer0Node3Id = randomDhtAddress()
|
|
42
42
|
layer0Node3 = new DhtNode({
|
|
43
43
|
nodeId: layer0Node3Id,
|
|
44
44
|
entryPoints: [entrypointDescriptor]
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
const layer0Node4Id =
|
|
47
|
+
const layer0Node4Id = randomDhtAddress()
|
|
48
48
|
layer0Node4 = new DhtNode({
|
|
49
49
|
nodeId: layer0Node4Id,
|
|
50
50
|
entryPoints: [entrypointDescriptor]
|
|
@@ -57,7 +57,7 @@ describe('Layer 1 on Layer 0 with mocked connections', () => {
|
|
|
57
57
|
await layer0Node4.start()
|
|
58
58
|
|
|
59
59
|
layer1EntryPoint = new DhtNode({
|
|
60
|
-
nodeId:
|
|
60
|
+
nodeId: toNodeId(entrypointDescriptor),
|
|
61
61
|
transport: layer0EntryPoint,
|
|
62
62
|
connectionsView: layer0EntryPoint.getConnectionsView(),
|
|
63
63
|
serviceId: 'layer1'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { areEqualBinaries, waitForEvent3 } from '@streamr/utils'
|
|
2
2
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { PeerDescriptor } from '../../
|
|
4
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
|
-
import {
|
|
6
|
+
import { toNodeId } from '../../src/exports'
|
|
7
7
|
|
|
8
8
|
describe('Layer0 with WebRTC connections', () => {
|
|
9
9
|
|
|
@@ -64,8 +64,8 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
64
64
|
node2.joinDht([epPeerDescriptor]),
|
|
65
65
|
node1.joinDht([epPeerDescriptor])
|
|
66
66
|
])
|
|
67
|
-
const nodeId1 =
|
|
68
|
-
const nodeId2 =
|
|
67
|
+
const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
|
|
68
|
+
const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
|
|
69
69
|
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
70
70
|
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
71
71
|
}, 60000)
|
|
@@ -77,8 +77,8 @@ describe('Layer0 with WebRTC connections', () => {
|
|
|
77
77
|
node3.joinDht([epPeerDescriptor]),
|
|
78
78
|
node4.joinDht([epPeerDescriptor])
|
|
79
79
|
])
|
|
80
|
-
const nodeId1 =
|
|
81
|
-
const nodeId2 =
|
|
80
|
+
const nodeId1 = toNodeId(node1.getLocalPeerDescriptor())
|
|
81
|
+
const nodeId2 = toNodeId(node2.getLocalPeerDescriptor())
|
|
82
82
|
expect((node1.getTransport() as ConnectionManager).hasConnection(nodeId2)).toEqual(true)
|
|
83
83
|
expect((node2.getTransport() as ConnectionManager).hasConnection(nodeId1)).toEqual(true)
|
|
84
84
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
2
|
-
import { PeerDescriptor } from '../../
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import os from 'os'
|
|
4
4
|
|
|
5
5
|
describe('Failed autocertification', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../
|
|
1
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
2
2
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
3
3
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
4
4
|
import { waitForCondition } from '@streamr/utils'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import LeakDetector from 'jest-leak-detector'
|
|
2
2
|
import { waitForCondition } from '@streamr/utils'
|
|
3
3
|
import { DhtNode } from '../../src/dht/DhtNode'
|
|
4
|
-
import { Message } from '../../
|
|
5
|
-
import { RpcMessage } from '../../
|
|
4
|
+
import { Message } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { RpcMessage } from '../../generated/packages/proto-rpc/protos/ProtoRpc'
|
|
6
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
|
-
import {
|
|
7
|
+
import { toNodeId } from '../../src/identifiers'
|
|
8
8
|
|
|
9
9
|
const MESSAGE_ID = 'mock-message-id'
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ describe('memory leak', () => {
|
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
21
|
let entryPoint: DhtNode | undefined = new DhtNode({
|
|
22
|
-
nodeId:
|
|
22
|
+
nodeId: toNodeId(entryPointDescriptor),
|
|
23
23
|
websocketHost: entryPointDescriptor.websocket!.host,
|
|
24
24
|
websocketPortRange: {
|
|
25
25
|
min: entryPointDescriptor.websocket!.port,
|