@streamr/dht 100.0.0-pretestnet.4 → 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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RingContactList = void 0;
|
|
7
|
+
const ordered_map_1 = require("@js-sdsl/ordered-map");
|
|
8
|
+
const ringIdentifiers_1 = require("./ringIdentifiers");
|
|
9
|
+
const identifiers_1 = require("../../identifiers");
|
|
10
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
11
|
+
class RingContactList extends eventemitter3_1.default {
|
|
12
|
+
numNeighborsPerSide = 5;
|
|
13
|
+
referenceId;
|
|
14
|
+
excludedIds;
|
|
15
|
+
leftNeighbors;
|
|
16
|
+
rightNeighbors;
|
|
17
|
+
emitEvents;
|
|
18
|
+
constructor(rawReferenceId, emitEvents, excludedIds) {
|
|
19
|
+
super();
|
|
20
|
+
this.referenceId = (0, ringIdentifiers_1.getRingIdFromRaw)(rawReferenceId);
|
|
21
|
+
this.emitEvents = emitEvents;
|
|
22
|
+
this.excludedIds = excludedIds ?? new Set();
|
|
23
|
+
this.leftNeighbors = new ordered_map_1.OrderedMap();
|
|
24
|
+
this.rightNeighbors = new ordered_map_1.OrderedMap();
|
|
25
|
+
}
|
|
26
|
+
addContact(contact) {
|
|
27
|
+
const id = (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(contact.getPeerDescriptor());
|
|
28
|
+
if (id === this.referenceId || this.excludedIds.has((0, identifiers_1.getNodeIdFromPeerDescriptor)(contact.getPeerDescriptor()))) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let elementAdded = false;
|
|
32
|
+
let elementRemoved = false;
|
|
33
|
+
const leftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.referenceId, id);
|
|
34
|
+
const lastLeftNeighbor = this.leftNeighbors.back();
|
|
35
|
+
if (lastLeftNeighbor === undefined || leftDistance < lastLeftNeighbor[0]) {
|
|
36
|
+
this.leftNeighbors.setElement(leftDistance, contact);
|
|
37
|
+
elementAdded = true;
|
|
38
|
+
if (this.leftNeighbors.size() > this.numNeighborsPerSide) {
|
|
39
|
+
this.leftNeighbors.eraseElementByIterator(this.leftNeighbors.rBegin());
|
|
40
|
+
elementRemoved = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const rightDistance = (0, ringIdentifiers_1.getRightDistance)(this.referenceId, id);
|
|
44
|
+
const lastRightNeighbor = this.rightNeighbors.back();
|
|
45
|
+
if (lastRightNeighbor === undefined || rightDistance < lastRightNeighbor[0]) {
|
|
46
|
+
this.rightNeighbors.setElement(rightDistance, contact);
|
|
47
|
+
elementAdded = true;
|
|
48
|
+
if (this.rightNeighbors.size() > this.numNeighborsPerSide) {
|
|
49
|
+
this.rightNeighbors.eraseElementByIterator(this.rightNeighbors.rBegin());
|
|
50
|
+
elementRemoved = true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (this.emitEvents && (elementAdded || elementRemoved)) {
|
|
54
|
+
const closestContacts = this.getClosestContacts();
|
|
55
|
+
const closestDescriptors = {
|
|
56
|
+
left: closestContacts.left.map((c) => c.getPeerDescriptor()),
|
|
57
|
+
right: closestContacts.right.map((c) => c.getPeerDescriptor())
|
|
58
|
+
};
|
|
59
|
+
if (elementAdded) {
|
|
60
|
+
this.emit('ringContactAdded', contact.getPeerDescriptor(), closestDescriptors);
|
|
61
|
+
}
|
|
62
|
+
if (elementRemoved) {
|
|
63
|
+
this.emit('ringContactRemoved', contact.getPeerDescriptor(), closestDescriptors);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
removeContact(contact) {
|
|
68
|
+
if (contact === undefined) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const id = (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(contact.getPeerDescriptor());
|
|
72
|
+
const leftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.referenceId, id);
|
|
73
|
+
const rightDistance = (0, ringIdentifiers_1.getRightDistance)(this.referenceId, id);
|
|
74
|
+
let elementRemoved = false;
|
|
75
|
+
if (this.leftNeighbors.eraseElementByKey(leftDistance)) {
|
|
76
|
+
elementRemoved = true;
|
|
77
|
+
}
|
|
78
|
+
if (this.rightNeighbors.eraseElementByKey(rightDistance)) {
|
|
79
|
+
elementRemoved = true;
|
|
80
|
+
}
|
|
81
|
+
if (this.emitEvents && elementRemoved) {
|
|
82
|
+
const closestContacts = this.getClosestContacts();
|
|
83
|
+
const closestDescriptors = { left: closestContacts.left.map((c) => c.getPeerDescriptor()),
|
|
84
|
+
right: closestContacts.right.map((c) => c.getPeerDescriptor()) };
|
|
85
|
+
this.emit('ringContactRemoved', contact.getPeerDescriptor(), closestDescriptors);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
getContact(peerDescriptor) {
|
|
89
|
+
const id = (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(peerDescriptor);
|
|
90
|
+
const leftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.referenceId, id);
|
|
91
|
+
const rightDistance = (0, ringIdentifiers_1.getRightDistance)(this.referenceId, id);
|
|
92
|
+
if (this.leftNeighbors.getElementByKey(leftDistance)) {
|
|
93
|
+
return this.leftNeighbors.getElementByKey(leftDistance);
|
|
94
|
+
}
|
|
95
|
+
if (this.rightNeighbors.getElementByKey(rightDistance)) {
|
|
96
|
+
return this.rightNeighbors.getElementByKey(rightDistance);
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
getClosestContacts(limitPerSide) {
|
|
101
|
+
const leftContacts = [];
|
|
102
|
+
const rightContacts = [];
|
|
103
|
+
let leftCount = 0;
|
|
104
|
+
for (const item of this.leftNeighbors) {
|
|
105
|
+
if (limitPerSide != undefined && leftCount >= limitPerSide) {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
leftContacts.push(item[1]);
|
|
109
|
+
leftCount++;
|
|
110
|
+
}
|
|
111
|
+
let rightCount = 0;
|
|
112
|
+
for (const item of this.rightNeighbors) {
|
|
113
|
+
if (limitPerSide != undefined && rightCount >= limitPerSide) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
rightContacts.push(item[1]);
|
|
117
|
+
rightCount++;
|
|
118
|
+
}
|
|
119
|
+
return { left: leftContacts, right: rightContacts };
|
|
120
|
+
}
|
|
121
|
+
getAllContacts() {
|
|
122
|
+
const ret = [];
|
|
123
|
+
for (const item of this.leftNeighbors) {
|
|
124
|
+
ret.push(item[1]);
|
|
125
|
+
}
|
|
126
|
+
for (const item of this.rightNeighbors) {
|
|
127
|
+
ret.push(item[1]);
|
|
128
|
+
}
|
|
129
|
+
return ret;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.RingContactList = RingContactList;
|
|
133
|
+
//# sourceMappingURL=RingContactList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RingContactList.js","sourceRoot":"","sources":["../../../../src/dht/contact/RingContactList.ts"],"names":[],"mappings":";;;;;;AACA,sDAAiD;AACjD,uDAAqJ;AACrJ,mDAA2E;AAC3E,kEAAwC;AAUxC,MAAa,eAAmE,SAAQ,uBAAmC;IAEtG,mBAAmB,GAAG,CAAC,CAAA;IACvB,WAAW,CAAQ;IACnB,WAAW,CAAiB;IAC5B,aAAa,CAA6B;IAC1C,cAAc,CAA6B;IAC3C,UAAU,CAAS;IAEpC,YAAY,cAAyB,EAAE,UAAmB,EAAE,WAA6B;QACrF,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,WAAW,GAAG,IAAA,kCAAgB,EAAC,cAAc,CAAC,CAAA;QACnD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,IAAI,GAAG,EAAE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C,aAAa,EAAE,CAAC;YACpC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACrB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;QACrB,CAAC;QACD,OAAO,GAAG,CAAA;IACd,CAAC;CACJ;AAxID,0CAwIC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import type { ServiceInfo } from '@protobuf-ts/runtime-rpc';
|
|
2
|
+
import { ClassType, ClientTransport, ProtoRpcClient, RpcCommunicator } from '@streamr/proto-rpc';
|
|
1
3
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
-
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
3
4
|
import { DhtRpcOptions } from '../../rpc-protocol/DhtRpcOptions';
|
|
4
|
-
import {
|
|
5
|
+
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext';
|
|
5
6
|
export declare const EXISTING_CONNECTION_TIMEOUT = 5000;
|
|
6
|
-
export declare abstract class
|
|
7
|
+
export declare abstract class RpcRemote<T extends ServiceInfo & ClassType> {
|
|
7
8
|
private readonly localPeerDescriptor;
|
|
8
9
|
private readonly remotePeerDescriptor;
|
|
9
|
-
private readonly serviceId;
|
|
10
10
|
private readonly client;
|
|
11
|
-
private readonly
|
|
12
|
-
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor,
|
|
11
|
+
private readonly timeout?;
|
|
12
|
+
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, rpcCommunicator: RpcCommunicator<DhtCallContext>, clientClass: {
|
|
13
|
+
new (clientTransport: ClientTransport): T;
|
|
14
|
+
}, timeout?: number);
|
|
13
15
|
getPeerDescriptor(): PeerDescriptor;
|
|
14
16
|
getLocalPeerDescriptor(): PeerDescriptor;
|
|
15
|
-
getServiceId(): string;
|
|
16
17
|
getClient(): ProtoRpcClient<T>;
|
|
17
18
|
formDhtRpcOptions(opts?: Omit<DhtRpcOptions, 'sourceDescriptor' | 'targetDescriptor'>): DhtRpcOptions;
|
|
18
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RpcRemote = exports.EXISTING_CONNECTION_TIMEOUT = void 0;
|
|
4
|
+
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
4
5
|
const IConnection_1 = require("../../connection/IConnection");
|
|
5
6
|
const Connectivity_1 = require("../../helpers/Connectivity");
|
|
6
7
|
// Should connect directly to the server, timeout can be low
|
|
@@ -12,7 +13,7 @@ const WEBSOCKET_SERVER_TIMEOUT = 7500;
|
|
|
12
13
|
const WEBRTC_TIMEOUT = 15000;
|
|
13
14
|
// default timeout for existing connections
|
|
14
15
|
exports.EXISTING_CONNECTION_TIMEOUT = 5000;
|
|
15
|
-
const
|
|
16
|
+
const getTimeout = (localPeerDescriptor, remotePeerDescriptor) => {
|
|
16
17
|
const connectionType = (0, Connectivity_1.expectedConnectionType)(localPeerDescriptor, remotePeerDescriptor);
|
|
17
18
|
if (connectionType === IConnection_1.ConnectionType.WEBSOCKET_CLIENT) {
|
|
18
19
|
return WEBSOCKET_CLIENT_TIMEOUT;
|
|
@@ -25,13 +26,18 @@ const getRpcTimeout = (localPeerDescriptor, remotePeerDescriptor) => {
|
|
|
25
26
|
}
|
|
26
27
|
return WEBRTC_TIMEOUT;
|
|
27
28
|
};
|
|
28
|
-
class
|
|
29
|
-
|
|
29
|
+
class RpcRemote {
|
|
30
|
+
localPeerDescriptor;
|
|
31
|
+
remotePeerDescriptor;
|
|
32
|
+
client;
|
|
33
|
+
timeout;
|
|
34
|
+
constructor(localPeerDescriptor, remotePeerDescriptor, rpcCommunicator,
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/prefer-function-type
|
|
36
|
+
clientClass, timeout) {
|
|
30
37
|
this.localPeerDescriptor = localPeerDescriptor;
|
|
31
38
|
this.remotePeerDescriptor = remotePeerDescriptor;
|
|
32
|
-
this.client =
|
|
33
|
-
this.
|
|
34
|
-
this.rpcTimeout = rpcTimeout;
|
|
39
|
+
this.client = (0, proto_rpc_1.toProtoRpcClient)(new clientClass(rpcCommunicator.getRpcClientTransport()));
|
|
40
|
+
this.timeout = timeout;
|
|
35
41
|
}
|
|
36
42
|
getPeerDescriptor() {
|
|
37
43
|
return this.remotePeerDescriptor;
|
|
@@ -39,9 +45,6 @@ class Remote {
|
|
|
39
45
|
getLocalPeerDescriptor() {
|
|
40
46
|
return this.localPeerDescriptor;
|
|
41
47
|
}
|
|
42
|
-
getServiceId() {
|
|
43
|
-
return this.serviceId;
|
|
44
|
-
}
|
|
45
48
|
getClient() {
|
|
46
49
|
return this.client;
|
|
47
50
|
}
|
|
@@ -49,10 +52,10 @@ class Remote {
|
|
|
49
52
|
return {
|
|
50
53
|
sourceDescriptor: this.localPeerDescriptor,
|
|
51
54
|
targetDescriptor: this.remotePeerDescriptor,
|
|
52
|
-
timeout: this.
|
|
55
|
+
timeout: this.timeout ?? getTimeout(this.localPeerDescriptor, this.remotePeerDescriptor),
|
|
53
56
|
...opts
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
exports.
|
|
58
|
-
//# sourceMappingURL=
|
|
60
|
+
exports.RpcRemote = RpcRemote;
|
|
61
|
+
//# sourceMappingURL=RpcRemote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RpcRemote.js","sourceRoot":"","sources":["../../../../src/dht/contact/RpcRemote.ts"],"names":[],"mappings":";;;AACA,kDAAkH;AAClH,8DAA6D;AAC7D,6DAAmE;AAKnE,4DAA4D;AAC5D,MAAM,wBAAwB,GAAG,IAAI,CAAA;AACrC,uGAAuG;AACvG,kDAAkD;AAClD,MAAM,w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B,CAAC;IAED,iBAAiB,CAAC,IAAmE;QACjF,OAAO;YACH,gBAAgB,EAAE,IAAI,CAAC,mBAAmB;YAC1C,gBAAgB,EAAE,IAAI,CAAC,oBAAoB;YAC3C,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,CAAC;YACxF,GAAG,IAAI;SACV,CAAA;IACL,CAAC;CACJ;AAzCD,8BAyCC"}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ContactState, Events } from './ContactList';
|
|
2
|
+
import EventEmitter from 'eventemitter3';
|
|
3
|
+
import { DhtAddress } from '../../identifiers';
|
|
4
|
+
export interface SortedContactListConfig {
|
|
5
|
+
referenceId: DhtAddress;
|
|
6
|
+
allowToContainReferenceId: boolean;
|
|
7
|
+
emitEvents: boolean;
|
|
8
|
+
maxSize?: number;
|
|
9
|
+
nodeIdDistanceLimit?: DhtAddress;
|
|
10
|
+
excludedNodeIds?: Set<DhtAddress>;
|
|
11
|
+
}
|
|
3
12
|
export declare class SortedContactList<C extends {
|
|
4
|
-
|
|
5
|
-
}> extends
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
constructor(
|
|
10
|
-
getClosestContactId():
|
|
11
|
-
getContactIds():
|
|
13
|
+
getNodeId: () => DhtAddress;
|
|
14
|
+
}> extends EventEmitter<Events<C>> {
|
|
15
|
+
private config;
|
|
16
|
+
private contactsById;
|
|
17
|
+
private contactIds;
|
|
18
|
+
constructor(config: SortedContactListConfig);
|
|
19
|
+
getClosestContactId(): DhtAddress;
|
|
20
|
+
getContactIds(): DhtAddress[];
|
|
12
21
|
addContact(contact: C): void;
|
|
13
22
|
addContacts(contacts: C[]): void;
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
getContact(id: DhtAddress): ContactState<C> | undefined;
|
|
24
|
+
setContacted(contactId: DhtAddress): void;
|
|
25
|
+
setActive(contactId: DhtAddress): void;
|
|
16
26
|
getClosestContacts(limit?: number): C[];
|
|
17
27
|
getUncontactedContacts(num: number): C[];
|
|
18
28
|
getActiveContacts(limit?: number): C[];
|
|
19
|
-
compareIds(id1:
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
compareIds(id1: DhtAddress, id2: DhtAddress): number;
|
|
30
|
+
private distanceToReferenceId;
|
|
31
|
+
removeContact(id: DhtAddress): boolean;
|
|
32
|
+
isActive(id: DhtAddress): boolean;
|
|
22
33
|
getAllContacts(): C[];
|
|
34
|
+
getSize(): number;
|
|
35
|
+
clear(): void;
|
|
36
|
+
stop(): void;
|
|
23
37
|
}
|
|
@@ -4,15 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SortedContactList = void 0;
|
|
7
|
-
const k_bucket_1 = __importDefault(require("k-bucket"));
|
|
8
7
|
const ContactList_1 = require("./ContactList");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
10
|
+
const PeerManager_1 = require("../PeerManager");
|
|
11
|
+
const identifiers_1 = require("../../identifiers");
|
|
12
|
+
class SortedContactList extends eventemitter3_1.default {
|
|
13
|
+
config;
|
|
14
|
+
contactsById = new Map();
|
|
15
|
+
contactIds = [];
|
|
16
|
+
constructor(config) {
|
|
17
|
+
super();
|
|
18
|
+
this.config = config;
|
|
12
19
|
this.compareIds = this.compareIds.bind(this);
|
|
13
|
-
this.allowLocalPeerId = allowLocalPeerId;
|
|
14
|
-
this.peerIdDistanceLimit = peerIdDistanceLimit;
|
|
15
|
-
this.excludedPeerIDs = excludedPeerIDs;
|
|
16
20
|
}
|
|
17
21
|
getClosestContactId() {
|
|
18
22
|
return this.contactIds[0];
|
|
@@ -21,59 +25,73 @@ class SortedContactList extends ContactList_1.ContactList {
|
|
|
21
25
|
return this.contactIds;
|
|
22
26
|
}
|
|
23
27
|
addContact(contact) {
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const contactId = contact.getNodeId();
|
|
29
|
+
if (this.config.excludedNodeIds !== undefined && this.config.excludedNodeIds.has(contactId)) {
|
|
26
30
|
return;
|
|
27
31
|
}
|
|
28
|
-
if ((!this.
|
|
29
|
-
(this.
|
|
32
|
+
if ((!this.config.allowToContainReferenceId && (this.config.referenceId === contactId)) ||
|
|
33
|
+
(this.config.nodeIdDistanceLimit !== undefined && this.compareIds(this.config.nodeIdDistanceLimit, contactId) < 0)) {
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
|
-
if (!this.contactsById.has(
|
|
33
|
-
if (this.contactIds.length < this.maxSize) {
|
|
34
|
-
this.contactsById.set(
|
|
35
|
-
this.contactIds
|
|
36
|
-
this.contactIds.
|
|
36
|
+
if (!this.contactsById.has(contactId)) {
|
|
37
|
+
if ((this.config.maxSize === undefined) || (this.contactIds.length < this.config.maxSize)) {
|
|
38
|
+
this.contactsById.set(contactId, new ContactList_1.ContactState(contact));
|
|
39
|
+
const index = (0, lodash_1.sortedIndexBy)(this.contactIds, contactId, (id) => { return this.distanceToReferenceId(id); });
|
|
40
|
+
this.contactIds.splice(index, 0, contactId);
|
|
41
|
+
if (this.config.emitEvents) {
|
|
42
|
+
this.emit('contactAdded', contact, this.getClosestContacts());
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
|
-
else if (this.compareIds(this.contactIds[this.maxSize - 1],
|
|
45
|
+
else if (this.compareIds(this.contactIds[this.config.maxSize - 1], contactId) > 0) {
|
|
39
46
|
const removedId = this.contactIds.pop();
|
|
40
|
-
const removedContact = this.contactsById.get(removedId
|
|
41
|
-
this.contactsById.delete(removedId
|
|
42
|
-
this.contactsById.set(
|
|
43
|
-
this.contactIds
|
|
44
|
-
this.contactIds.
|
|
45
|
-
|
|
47
|
+
const removedContact = this.contactsById.get(removedId).contact;
|
|
48
|
+
this.contactsById.delete(removedId);
|
|
49
|
+
this.contactsById.set(contactId, new ContactList_1.ContactState(contact));
|
|
50
|
+
const index = (0, lodash_1.sortedIndexBy)(this.contactIds, contactId, (id) => { return this.distanceToReferenceId(id); });
|
|
51
|
+
this.contactIds.splice(index, 0, contactId);
|
|
52
|
+
if (this.config.emitEvents) {
|
|
53
|
+
const closestContacts = this.getClosestContacts();
|
|
54
|
+
this.emit('contactRemoved', removedContact, closestContacts);
|
|
55
|
+
this.emit('contactAdded', contact, closestContacts);
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
|
-
this.emit('newContact', contact, this.getClosestContacts());
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
addContacts(contacts) {
|
|
51
61
|
contacts.forEach((contact) => this.addContact(contact));
|
|
52
62
|
}
|
|
63
|
+
getContact(id) {
|
|
64
|
+
return this.contactsById.get(id);
|
|
65
|
+
}
|
|
53
66
|
setContacted(contactId) {
|
|
54
|
-
if (this.contactsById.has(contactId
|
|
55
|
-
this.contactsById.get(contactId
|
|
67
|
+
if (this.contactsById.has(contactId)) {
|
|
68
|
+
this.contactsById.get(contactId).contacted = true;
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
setActive(contactId) {
|
|
59
|
-
if (this.contactsById.has(contactId
|
|
60
|
-
this.contactsById.get(contactId
|
|
72
|
+
if (this.contactsById.has(contactId)) {
|
|
73
|
+
this.contactsById.get(contactId).active = true;
|
|
61
74
|
}
|
|
62
75
|
}
|
|
63
|
-
getClosestContacts(limit
|
|
76
|
+
getClosestContacts(limit) {
|
|
64
77
|
const ret = [];
|
|
65
78
|
this.contactIds.forEach((contactId) => {
|
|
66
|
-
const contact = this.contactsById.get(contactId
|
|
79
|
+
const contact = this.contactsById.get(contactId);
|
|
67
80
|
if (contact) {
|
|
68
81
|
ret.push(contact.contact);
|
|
69
82
|
}
|
|
70
83
|
});
|
|
71
|
-
|
|
84
|
+
if (limit === undefined) {
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return ret.slice(0, limit);
|
|
89
|
+
}
|
|
72
90
|
}
|
|
73
91
|
getUncontactedContacts(num) {
|
|
74
92
|
const ret = [];
|
|
75
93
|
for (const contactId of this.contactIds) {
|
|
76
|
-
const contact = this.contactsById.get(contactId
|
|
94
|
+
const contact = this.contactsById.get(contactId);
|
|
77
95
|
if (contact && !contact.contacted) {
|
|
78
96
|
ret.push(contact.contact);
|
|
79
97
|
if (ret.length >= num) {
|
|
@@ -86,7 +104,7 @@ class SortedContactList extends ContactList_1.ContactList {
|
|
|
86
104
|
getActiveContacts(limit) {
|
|
87
105
|
const ret = [];
|
|
88
106
|
this.contactIds.forEach((contactId) => {
|
|
89
|
-
const contact = this.contactsById.get(contactId
|
|
107
|
+
const contact = this.contactsById.get(contactId);
|
|
90
108
|
if (contact && contact.active) {
|
|
91
109
|
ret.push(contact.contact);
|
|
92
110
|
}
|
|
@@ -99,26 +117,45 @@ class SortedContactList extends ContactList_1.ContactList {
|
|
|
99
117
|
}
|
|
100
118
|
}
|
|
101
119
|
compareIds(id1, id2) {
|
|
102
|
-
const distance1 =
|
|
103
|
-
const distance2 =
|
|
120
|
+
const distance1 = this.distanceToReferenceId(id1);
|
|
121
|
+
const distance2 = this.distanceToReferenceId(id2);
|
|
104
122
|
return distance1 - distance2;
|
|
105
123
|
}
|
|
124
|
+
// TODO inline this method?
|
|
125
|
+
distanceToReferenceId(id) {
|
|
126
|
+
// TODO maybe this class should store the referenceId also as DhtAddressRaw so that we don't need to convert it here?
|
|
127
|
+
return (0, PeerManager_1.getDistance)((0, identifiers_1.getRawFromDhtAddress)(this.config.referenceId), (0, identifiers_1.getRawFromDhtAddress)(id));
|
|
128
|
+
}
|
|
106
129
|
removeContact(id) {
|
|
107
|
-
if (this.contactsById.has(id
|
|
108
|
-
const removed = this.contactsById.get(id
|
|
109
|
-
|
|
130
|
+
if (this.contactsById.has(id)) {
|
|
131
|
+
const removed = this.contactsById.get(id).contact;
|
|
132
|
+
// TODO use sortedIndexBy?
|
|
133
|
+
const index = this.contactIds.findIndex((nodeId) => (nodeId === id));
|
|
110
134
|
this.contactIds.splice(index, 1);
|
|
111
|
-
this.contactsById.delete(id
|
|
112
|
-
|
|
135
|
+
this.contactsById.delete(id);
|
|
136
|
+
if (this.config.emitEvents) {
|
|
137
|
+
this.emit('contactRemoved', removed, this.getClosestContacts());
|
|
138
|
+
}
|
|
113
139
|
return true;
|
|
114
140
|
}
|
|
115
141
|
return false;
|
|
116
142
|
}
|
|
117
143
|
isActive(id) {
|
|
118
|
-
return this.contactsById.has(id
|
|
144
|
+
return this.contactsById.has(id) ? this.contactsById.get(id).active : false;
|
|
119
145
|
}
|
|
120
146
|
getAllContacts() {
|
|
121
|
-
return this.contactIds.map((
|
|
147
|
+
return this.contactIds.map((nodeId) => this.contactsById.get(nodeId).contact);
|
|
148
|
+
}
|
|
149
|
+
getSize() {
|
|
150
|
+
return this.contactIds.length;
|
|
151
|
+
}
|
|
152
|
+
clear() {
|
|
153
|
+
this.contactsById.clear();
|
|
154
|
+
this.contactIds = [];
|
|
155
|
+
}
|
|
156
|
+
stop() {
|
|
157
|
+
this.removeAllListeners();
|
|
158
|
+
this.clear();
|
|
122
159
|
}
|
|
123
160
|
}
|
|
124
161
|
exports.SortedContactList = SortedContactList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortedContactList.js","sourceRoot":"","sources":["../../../../src/dht/contact/SortedContactList.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"SortedContactList.js","sourceRoot":"","sources":["../../../../src/dht/contact/SortedContactList.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAoD;AACpD,mCAAsC;AACtC,kEAAwC;AACxC,gDAA4C;AAC5C,mDAAoE;AAepE,MAAa,iBAA6D,SAAQ,uBAAuB;IAE7F,MAAM,CAAyB;IAC/B,YAAY,GAAqC,IAAI,GAAG,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CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAA;IAChF,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,OAAO,CAAC,CAAA;IAClF,CAAC;IAEM,OAAO;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAA;IACjC,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACxB,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,kBAAkB,EAAE,CAAA;QACzB,IAAI,CAAC,KAAK,EAAE,CAAA;IAChB,CAAC;CACJ;AAvLD,8CAuLC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
export type RingIdRaw = Uint8Array & {
|
|
3
|
+
__ringIdRaw: never;
|
|
4
|
+
};
|
|
5
|
+
export type RingId = number & {
|
|
6
|
+
__ringId: never;
|
|
7
|
+
};
|
|
8
|
+
export type RingDistance = number & {
|
|
9
|
+
__ringDistance: never;
|
|
10
|
+
};
|
|
11
|
+
export declare const RING_SIZE: number;
|
|
12
|
+
export declare const getRingIdFromRaw: (raw: RingIdRaw) => RingId;
|
|
13
|
+
export declare const getRingIdRawFromPeerDescriptor: (peerDescriptor: PeerDescriptor) => RingIdRaw;
|
|
14
|
+
export declare const getRingIdFromPeerDescriptor: (peerDescriptor: PeerDescriptor) => RingId;
|
|
15
|
+
export declare const getLeftDistance: (referenceId: RingId, id: RingId) => RingDistance;
|
|
16
|
+
export declare const getRightDistance: (referenceId: RingId, id: RingId) => RingDistance;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRightDistance = exports.getLeftDistance = exports.getRingIdFromPeerDescriptor = exports.getRingIdRawFromPeerDescriptor = exports.getRingIdFromRaw = exports.RING_SIZE = void 0;
|
|
4
|
+
exports.RING_SIZE = 2 ** 120 - 1; // 2^120 - 1
|
|
5
|
+
const binaryToBigInt = (binary) => {
|
|
6
|
+
return binary.reduce((acc, val) => (acc << BigInt(8)) | BigInt(val), BigInt(0));
|
|
7
|
+
};
|
|
8
|
+
const getRingIdFromRaw = (raw) => Number(binaryToBigInt(raw));
|
|
9
|
+
exports.getRingIdFromRaw = getRingIdFromRaw;
|
|
10
|
+
const getRingIdRawFromPeerDescriptor = (peerDescriptor) => {
|
|
11
|
+
const regionAsBuffer = Buffer.alloc(4);
|
|
12
|
+
regionAsBuffer.writeUInt32BE(peerDescriptor.region ?? 0, 0);
|
|
13
|
+
const ipAsbuffer = Buffer.alloc(4);
|
|
14
|
+
ipAsbuffer.writeUInt32BE(peerDescriptor.ipAddress ?? 0, 0);
|
|
15
|
+
const uniquePartAsBuffer = Buffer.from(peerDescriptor.nodeId.subarray(peerDescriptor.nodeId.length - 7, peerDescriptor.nodeId.length));
|
|
16
|
+
const arr = [
|
|
17
|
+
regionAsBuffer,
|
|
18
|
+
ipAsbuffer,
|
|
19
|
+
uniquePartAsBuffer
|
|
20
|
+
];
|
|
21
|
+
const buffer = Buffer.concat(arr);
|
|
22
|
+
return new Uint8Array(buffer);
|
|
23
|
+
};
|
|
24
|
+
exports.getRingIdRawFromPeerDescriptor = getRingIdRawFromPeerDescriptor;
|
|
25
|
+
const getRingIdFromPeerDescriptor = (peerDescriptor) => {
|
|
26
|
+
const raw = (0, exports.getRingIdRawFromPeerDescriptor)(peerDescriptor);
|
|
27
|
+
return Number(binaryToBigInt(raw));
|
|
28
|
+
};
|
|
29
|
+
exports.getRingIdFromPeerDescriptor = getRingIdFromPeerDescriptor;
|
|
30
|
+
const getLeftDistance = (referenceId, id) => {
|
|
31
|
+
const diff = Math.abs(referenceId - id);
|
|
32
|
+
if (referenceId > id) {
|
|
33
|
+
// if id is smaller than referenceId, then the distance is the difference
|
|
34
|
+
return diff;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// if id is bigger than referenceId, then the distance is the ringSize - difference
|
|
38
|
+
return exports.RING_SIZE - diff;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getLeftDistance = getLeftDistance;
|
|
42
|
+
const getRightDistance = (referenceId, id) => {
|
|
43
|
+
const diff = Math.abs(referenceId - id);
|
|
44
|
+
if (referenceId > id) {
|
|
45
|
+
// if id is smaller than referenceId, then the distance is the ringSize - difference
|
|
46
|
+
return exports.RING_SIZE - diff;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// if id is bigger than referenceId, then the distance is the difference
|
|
50
|
+
return diff;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.getRightDistance = getRightDistance;
|
|
54
|
+
//# sourceMappingURL=ringIdentifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ringIdentifiers.js","sourceRoot":"","sources":["../../../../src/dht/contact/ringIdentifiers.ts"],"names":[],"mappings":";;;AAUa,QAAA,SAAS,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,CAAA,CAAG,YAAY;AAEpD,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAU,EAAE;IAClD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACnF,CAAC,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,GAAc,EAAU,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAW,CAAA;AAAp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