@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,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataEntry, ReplicateDataRequest, PeerDescriptor,
|
|
3
|
+
StoreDataRequest, StoreDataResponse, RecursiveOperation
|
|
4
|
+
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
5
|
+
import { Any } from '../../proto/google/protobuf/any'
|
|
6
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
7
|
+
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator'
|
|
8
|
+
import { RecursiveOperationManager } from '../recursive-operation/RecursiveOperationManager'
|
|
9
|
+
import { Logger, executeSafePromise } from '@streamr/utils'
|
|
10
|
+
import { LocalDataStore } from './LocalDataStore'
|
|
11
|
+
import { StoreRpcRemote } from './StoreRpcRemote'
|
|
12
|
+
import { Timestamp } from '../../proto/google/protobuf/timestamp'
|
|
13
|
+
import { SortedContactList } from '../contact/SortedContactList'
|
|
14
|
+
import { Contact } from '../contact/Contact'
|
|
15
|
+
import { ServiceID } from '../../types/ServiceID'
|
|
16
|
+
import { DhtAddress, areEqualPeerDescriptors, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor, getRawFromDhtAddress } from '../../identifiers'
|
|
17
|
+
import { StoreRpcLocal } from './StoreRpcLocal'
|
|
18
|
+
import { getDistance } from '../PeerManager'
|
|
19
|
+
|
|
20
|
+
interface StoreManagerConfig {
|
|
21
|
+
rpcCommunicator: RoutingRpcCommunicator
|
|
22
|
+
recursiveOperationManager: RecursiveOperationManager
|
|
23
|
+
localPeerDescriptor: PeerDescriptor
|
|
24
|
+
localDataStore: LocalDataStore
|
|
25
|
+
serviceId: ServiceID
|
|
26
|
+
highestTtl: number
|
|
27
|
+
redundancyFactor: number
|
|
28
|
+
getClosestNeighborsTo: (dataKey: DhtAddress, n?: number) => PeerDescriptor[]
|
|
29
|
+
createRpcRemote: (contact: PeerDescriptor) => StoreRpcRemote
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const logger = new Logger(module)
|
|
33
|
+
|
|
34
|
+
export class StoreManager {
|
|
35
|
+
|
|
36
|
+
private readonly config: StoreManagerConfig
|
|
37
|
+
|
|
38
|
+
constructor(config: StoreManagerConfig) {
|
|
39
|
+
this.config = config
|
|
40
|
+
this.registerLocalRpcMethods()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private registerLocalRpcMethods() {
|
|
44
|
+
const rpcLocal = new StoreRpcLocal({
|
|
45
|
+
localDataStore: this.config.localDataStore,
|
|
46
|
+
replicateDataToNeighbors: (incomingPeer: PeerDescriptor, dataEntry: DataEntry) => this.replicateDataToNeighbors(incomingPeer, dataEntry),
|
|
47
|
+
selfIsWithinRedundancyFactor: (key: DhtAddress): boolean => this.selfIsWithinRedundancyFactor(key)
|
|
48
|
+
})
|
|
49
|
+
this.config.rpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData',
|
|
50
|
+
(request: StoreDataRequest) => rpcLocal.storeData(request))
|
|
51
|
+
this.config.rpcCommunicator.registerRpcNotification(ReplicateDataRequest, 'replicateData',
|
|
52
|
+
(request: ReplicateDataRequest, context: ServerCallContext) => rpcLocal.replicateData(request, context))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
onContactAdded(peerDescriptor: PeerDescriptor): void {
|
|
56
|
+
for (const key of this.config.localDataStore.keys()) {
|
|
57
|
+
this.replicateAndUpdateStaleState(key, peerDescriptor)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private replicateAndUpdateStaleState(key: DhtAddress, newNode: PeerDescriptor): void {
|
|
62
|
+
const newNodeId = getNodeIdFromPeerDescriptor(newNode)
|
|
63
|
+
const closestToData = this.config.getClosestNeighborsTo(key, this.config.redundancyFactor)
|
|
64
|
+
const sortedList = new SortedContactList<Contact>({
|
|
65
|
+
referenceId: key,
|
|
66
|
+
maxSize: this.config.redundancyFactor,
|
|
67
|
+
allowToContainReferenceId: true,
|
|
68
|
+
emitEvents: false
|
|
69
|
+
})
|
|
70
|
+
sortedList.addContact(new Contact(this.config.localPeerDescriptor))
|
|
71
|
+
closestToData.forEach((neighbor) => {
|
|
72
|
+
if (newNodeId !== getNodeIdFromPeerDescriptor(neighbor)) {
|
|
73
|
+
sortedList.addContact(new Contact(neighbor))
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
const selfIsPrimaryStorer = (sortedList.getClosestContactId() === getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor))
|
|
77
|
+
if (selfIsPrimaryStorer) {
|
|
78
|
+
sortedList.addContact(new Contact(newNode))
|
|
79
|
+
if (sortedList.getContact(newNodeId) !== undefined) {
|
|
80
|
+
setImmediate(async () => {
|
|
81
|
+
const dataEntries = Array.from(this.config.localDataStore.values(key))
|
|
82
|
+
await Promise.all(dataEntries.map(async (dataEntry) => this.replicateDataToContact(dataEntry, newNode)))
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
} else if (!this.selfIsWithinRedundancyFactor(key)) {
|
|
86
|
+
this.config.localDataStore.setAllEntriesAsStale(key)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private async replicateDataToContact(dataEntry: DataEntry, contact: PeerDescriptor): Promise<void> {
|
|
91
|
+
const rpcRemote = this.config.createRpcRemote(contact)
|
|
92
|
+
try {
|
|
93
|
+
await rpcRemote.replicateData({ entry: dataEntry })
|
|
94
|
+
} catch (e) {
|
|
95
|
+
logger.trace('replicateData() threw an exception ' + e)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public async storeDataToDht(key: DhtAddress, data: Any, creator: DhtAddress): Promise<PeerDescriptor[]> {
|
|
100
|
+
logger.debug(`Storing data to DHT ${this.config.serviceId}`)
|
|
101
|
+
const result = await this.config.recursiveOperationManager.execute(key, RecursiveOperation.FIND_CLOSEST_NODES)
|
|
102
|
+
const closestNodes = result.closestNodes
|
|
103
|
+
const successfulNodes: PeerDescriptor[] = []
|
|
104
|
+
const ttl = this.config.highestTtl // ToDo: make TTL decrease according to some nice curve
|
|
105
|
+
const createdAt = Timestamp.now()
|
|
106
|
+
for (let i = 0; i < closestNodes.length && successfulNodes.length < this.config.redundancyFactor; i++) {
|
|
107
|
+
const keyRaw = getRawFromDhtAddress(key)
|
|
108
|
+
const creatorRaw = getRawFromDhtAddress(creator)
|
|
109
|
+
if (areEqualPeerDescriptors(this.config.localPeerDescriptor, closestNodes[i])) {
|
|
110
|
+
this.config.localDataStore.storeEntry({
|
|
111
|
+
key: keyRaw,
|
|
112
|
+
data,
|
|
113
|
+
creator: creatorRaw,
|
|
114
|
+
createdAt,
|
|
115
|
+
storedAt: Timestamp.now(),
|
|
116
|
+
ttl,
|
|
117
|
+
stale: false,
|
|
118
|
+
deleted: false,
|
|
119
|
+
})
|
|
120
|
+
successfulNodes.push(closestNodes[i])
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
const rpcRemote = this.config.createRpcRemote(closestNodes[i])
|
|
124
|
+
try {
|
|
125
|
+
await rpcRemote.storeData({
|
|
126
|
+
key: keyRaw,
|
|
127
|
+
data,
|
|
128
|
+
creator: creatorRaw,
|
|
129
|
+
createdAt,
|
|
130
|
+
ttl
|
|
131
|
+
})
|
|
132
|
+
successfulNodes.push(closestNodes[i])
|
|
133
|
+
logger.trace('remote.storeData() success')
|
|
134
|
+
} catch (e) {
|
|
135
|
+
logger.trace('remote.storeData() threw an exception ' + e)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return successfulNodes
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private selfIsWithinRedundancyFactor(dataKey: DhtAddress): boolean {
|
|
142
|
+
const closestNeighbors = this.config.getClosestNeighborsTo(dataKey, this.config.redundancyFactor)
|
|
143
|
+
if (closestNeighbors.length < this.config.redundancyFactor) {
|
|
144
|
+
return true
|
|
145
|
+
} else {
|
|
146
|
+
const furthestCloseNeighbor = closestNeighbors[closestNeighbors.length - 1]
|
|
147
|
+
const dataKeyRaw = getRawFromDhtAddress(dataKey)
|
|
148
|
+
return getDistance(dataKeyRaw, this.config.localPeerDescriptor.nodeId) < getDistance(dataKeyRaw, furthestCloseNeighbor.nodeId)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private async replicateDataToClosestNodes(): Promise<void> {
|
|
153
|
+
const dataEntries = Array.from(this.config.localDataStore.values())
|
|
154
|
+
await Promise.all(dataEntries.map(async (dataEntry) => {
|
|
155
|
+
const neighbors = this.config.getClosestNeighborsTo(getDhtAddressFromRaw(dataEntry.key), this.config.redundancyFactor)
|
|
156
|
+
await Promise.all(neighbors.map(async (neighbor) => {
|
|
157
|
+
const rpcRemote = this.config.createRpcRemote(neighbor)
|
|
158
|
+
try {
|
|
159
|
+
await rpcRemote.replicateData({ entry: dataEntry })
|
|
160
|
+
} catch (err) {
|
|
161
|
+
logger.trace('Failed to replicate data in replicateDataToClosestNodes', { error: err })
|
|
162
|
+
}
|
|
163
|
+
}))
|
|
164
|
+
}))
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private replicateDataToNeighbors(incomingPeer: PeerDescriptor, dataEntry: DataEntry): void {
|
|
168
|
+
// sort own contact list according to data id
|
|
169
|
+
const localNodeId = getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor)
|
|
170
|
+
const incomingNodeId = getNodeIdFromPeerDescriptor(incomingPeer)
|
|
171
|
+
const key = getDhtAddressFromRaw(dataEntry.key)
|
|
172
|
+
// TODO use config option or named constant?
|
|
173
|
+
const closestToData = this.config.getClosestNeighborsTo(key, 10)
|
|
174
|
+
const sortedList = new SortedContactList<Contact>({
|
|
175
|
+
referenceId: key,
|
|
176
|
+
maxSize: this.config.redundancyFactor,
|
|
177
|
+
allowToContainReferenceId: true,
|
|
178
|
+
emitEvents: false
|
|
179
|
+
})
|
|
180
|
+
sortedList.addContact(new Contact(this.config.localPeerDescriptor))
|
|
181
|
+
closestToData.forEach((neighbor) => {
|
|
182
|
+
sortedList.addContact(new Contact(neighbor))
|
|
183
|
+
})
|
|
184
|
+
const selfIsPrimaryStorer = (sortedList.getClosestContactId() === localNodeId)
|
|
185
|
+
const targets = selfIsPrimaryStorer
|
|
186
|
+
// if we are the closest to the data, replicate to all storageRedundancyFactor nearest
|
|
187
|
+
? sortedList.getAllContacts()
|
|
188
|
+
// if we are not the closest node to the data, replicate only to the closest one to the data
|
|
189
|
+
: [sortedList.getAllContacts()[0]]
|
|
190
|
+
targets.forEach((contact) => {
|
|
191
|
+
const contactNodeId = contact.getNodeId()
|
|
192
|
+
if ((incomingNodeId !== contactNodeId) && (localNodeId !== contactNodeId)) {
|
|
193
|
+
setImmediate(() => {
|
|
194
|
+
executeSafePromise(async () => {
|
|
195
|
+
await this.replicateDataToContact(dataEntry, contact.getPeerDescriptor())
|
|
196
|
+
logger.trace('replicateDataToContact() returned', {
|
|
197
|
+
node: contactNodeId,
|
|
198
|
+
replicateOnlyToClosest: !selfIsPrimaryStorer
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async destroy(): Promise<void> {
|
|
207
|
+
await this.replicateDataToClosestNodes()
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -1,335 +1,66 @@
|
|
|
1
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
|
+
import { Logger } from '@streamr/utils'
|
|
3
|
+
import { Empty } from '../../proto/google/protobuf/empty'
|
|
4
|
+
import { Timestamp } from '../../proto/google/protobuf/timestamp'
|
|
1
5
|
import {
|
|
2
|
-
DataEntry,
|
|
6
|
+
DataEntry,
|
|
7
|
+
PeerDescriptor,
|
|
8
|
+
ReplicateDataRequest,
|
|
3
9
|
StoreDataRequest, StoreDataResponse
|
|
4
10
|
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
5
|
-
import {
|
|
6
|
-
import { Any } from '../../proto/google/protobuf/any'
|
|
7
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
11
|
+
import { IStoreRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
|
|
8
12
|
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
9
|
-
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
10
|
-
import { StoreRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
|
|
11
|
-
import { RoutingRpcCommunicator } from '../../transport/RoutingRpcCommunicator'
|
|
12
|
-
import { IFinder } from '../find/Finder'
|
|
13
|
-
import { areEqualPeerDescriptors, getNodeIdFromPeerDescriptor, peerIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
|
|
14
|
-
import { Logger } from '@streamr/utils'
|
|
15
13
|
import { LocalDataStore } from './LocalDataStore'
|
|
16
|
-
import {
|
|
17
|
-
import { StoreRpcRemote } from './StoreRpcRemote'
|
|
18
|
-
import { Timestamp } from '../../proto/google/protobuf/timestamp'
|
|
19
|
-
import EventEmitter from 'eventemitter3'
|
|
20
|
-
import { Events } from '../DhtNode'
|
|
21
|
-
import { SortedContactList } from '../contact/SortedContactList'
|
|
22
|
-
import { Contact } from '../contact/Contact'
|
|
23
|
-
import { DhtNodeRpcRemote } from '../DhtNodeRpcRemote'
|
|
24
|
-
import { ServiceID } from '../../types/ServiceID'
|
|
14
|
+
import { DhtAddress, getDhtAddressFromRaw } from '../../identifiers'
|
|
25
15
|
|
|
26
|
-
interface
|
|
27
|
-
rpcCommunicator: RoutingRpcCommunicator
|
|
28
|
-
finder: IFinder
|
|
29
|
-
localPeerDescriptor: PeerDescriptor
|
|
16
|
+
interface StoreRpcLocalConfig {
|
|
30
17
|
localDataStore: LocalDataStore
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
highestTtl: number
|
|
34
|
-
redundancyFactor: number
|
|
35
|
-
dhtNodeEmitter: EventEmitter<Events>
|
|
36
|
-
getNodesClosestToIdFromBucket: (id: Uint8Array, n?: number) => DhtNodeRpcRemote[]
|
|
37
|
-
rpcRequestTimeout?: number
|
|
18
|
+
replicateDataToNeighbors: (incomingPeer: PeerDescriptor, dataEntry: DataEntry) => void
|
|
19
|
+
selfIsWithinRedundancyFactor: (key: DhtAddress) => boolean
|
|
38
20
|
}
|
|
39
21
|
|
|
40
22
|
const logger = new Logger(module)
|
|
41
23
|
|
|
42
24
|
export class StoreRpcLocal implements IStoreRpc {
|
|
43
25
|
|
|
44
|
-
private readonly
|
|
45
|
-
private readonly finder: IFinder
|
|
46
|
-
private readonly localPeerDescriptor: PeerDescriptor
|
|
47
|
-
private readonly localDataStore: LocalDataStore
|
|
48
|
-
private readonly serviceId: ServiceID
|
|
49
|
-
private readonly maxTtl: number
|
|
50
|
-
private readonly highestTtl: number
|
|
51
|
-
private readonly redundancyFactor: number
|
|
52
|
-
private readonly dhtNodeEmitter: EventEmitter<Events>
|
|
53
|
-
private readonly getNodesClosestToIdFromBucket: (id: Uint8Array, n?: number) => DhtNodeRpcRemote[]
|
|
54
|
-
private readonly rpcRequestTimeout?: number
|
|
55
|
-
|
|
56
|
-
constructor(config: DataStoreConfig) {
|
|
57
|
-
this.rpcCommunicator = config.rpcCommunicator
|
|
58
|
-
this.finder = config.finder
|
|
59
|
-
this.localPeerDescriptor = config.localPeerDescriptor
|
|
60
|
-
this.localDataStore = config.localDataStore
|
|
61
|
-
this.serviceId = config.serviceId
|
|
62
|
-
this.maxTtl = config.maxTtl
|
|
63
|
-
this.highestTtl = config.highestTtl
|
|
64
|
-
this.redundancyFactor = config.redundancyFactor
|
|
65
|
-
this.dhtNodeEmitter = config.dhtNodeEmitter
|
|
66
|
-
this.rpcRequestTimeout = config.rpcRequestTimeout
|
|
67
|
-
this.getNodesClosestToIdFromBucket = config.getNodesClosestToIdFromBucket
|
|
68
|
-
this.rpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData',
|
|
69
|
-
(request: StoreDataRequest, context: ServerCallContext) => this.storeData(request, context))
|
|
70
|
-
this.rpcCommunicator.registerRpcMethod(MigrateDataRequest, MigrateDataResponse, 'migrateData',
|
|
71
|
-
(request: MigrateDataRequest, context: ServerCallContext) => this.migrateData(request, context))
|
|
72
|
-
this.rpcCommunicator.registerRpcMethod(DeleteDataRequest, DeleteDataResponse, 'deleteData',
|
|
73
|
-
(request: DeleteDataRequest, context: ServerCallContext) => this.deleteData(request, context))
|
|
74
|
-
|
|
75
|
-
this.dhtNodeEmitter.on('newContact', (peerDescriptor: PeerDescriptor) => {
|
|
76
|
-
this.localDataStore.getStore().forEach((dataMap, _dataKey) => {
|
|
77
|
-
dataMap.forEach((dataEntry) => {
|
|
78
|
-
if (this.shouldMigrateDataToNewNode(dataEntry.dataEntry, peerDescriptor)) {
|
|
79
|
-
this.migrateDataToContact(dataEntry.dataEntry, peerDescriptor)
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private shouldMigrateDataToNewNode(dataEntry: DataEntry, newNode: PeerDescriptor): boolean {
|
|
87
|
-
|
|
88
|
-
const dataId = PeerID.fromValue(dataEntry.kademliaId)
|
|
89
|
-
const newNodeId = PeerID.fromValue(newNode.kademliaId)
|
|
90
|
-
const localPeerId = PeerID.fromValue(this.localPeerDescriptor.kademliaId)
|
|
26
|
+
private readonly config: StoreRpcLocalConfig
|
|
91
27
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const sortedList = new SortedContactList<Contact>(dataId, 20, undefined, true)
|
|
95
|
-
sortedList.addContact(new Contact(this.localPeerDescriptor))
|
|
96
|
-
|
|
97
|
-
closestToData.forEach((con) => {
|
|
98
|
-
if (!newNodeId.equals(PeerID.fromValue(con.getPeerDescriptor().kademliaId))) {
|
|
99
|
-
sortedList.addContact(new Contact(con.getPeerDescriptor()))
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
if (!sortedList.getAllContacts()[0].getPeerId().equals(localPeerId)) {
|
|
104
|
-
// If we are not the closes node to the data, do not migrate
|
|
105
|
-
return false
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const newPeerId = PeerID.fromValue(newNode.kademliaId)
|
|
109
|
-
sortedList.addContact(new Contact(newNode))
|
|
110
|
-
|
|
111
|
-
const sorted = sortedList.getAllContacts()
|
|
112
|
-
|
|
113
|
-
let index = 0
|
|
114
|
-
|
|
115
|
-
for (index = 0; index < sorted.length; index++) {
|
|
116
|
-
if (sorted[index].getPeerId().equals(newPeerId)) {
|
|
117
|
-
break
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// if new node is within the storageRedundancyFactor closest nodes to the data
|
|
122
|
-
// do migrate data to it
|
|
123
|
-
|
|
124
|
-
if (index < this.redundancyFactor) {
|
|
125
|
-
this.localDataStore.setStale(dataId, dataEntry.storer!, false)
|
|
126
|
-
return true
|
|
127
|
-
} else {
|
|
128
|
-
this.localDataStore.setStale(dataId, dataEntry.storer!, true)
|
|
129
|
-
return false
|
|
130
|
-
}
|
|
28
|
+
constructor(config: StoreRpcLocalConfig) {
|
|
29
|
+
this.config = config
|
|
131
30
|
}
|
|
132
31
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const response = await rpcRemote.migrateData({ dataEntry }, doNotConnect)
|
|
143
|
-
if (response.error) {
|
|
144
|
-
logger.trace('migrateData() returned error: ' + response.error)
|
|
145
|
-
}
|
|
146
|
-
} catch (e) {
|
|
147
|
-
logger.trace('migrateData() threw an exception ' + e)
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
public async storeDataToDht(key: Uint8Array, data: Any): Promise<PeerDescriptor[]> {
|
|
152
|
-
logger.debug(`Storing data to DHT ${this.serviceId}`)
|
|
153
|
-
const result = await this.finder.startFind(key)
|
|
154
|
-
const closestNodes = result.closestNodes
|
|
155
|
-
const successfulNodes: PeerDescriptor[] = []
|
|
156
|
-
const ttl = this.highestTtl // ToDo: make TTL decrease according to some nice curve
|
|
157
|
-
const storerTime = Timestamp.now()
|
|
158
|
-
for (let i = 0; i < closestNodes.length && successfulNodes.length < this.redundancyFactor; i++) {
|
|
159
|
-
if (areEqualPeerDescriptors(this.localPeerDescriptor, closestNodes[i])) {
|
|
160
|
-
this.localDataStore.storeEntry({
|
|
161
|
-
kademliaId: key,
|
|
162
|
-
storer: this.localPeerDescriptor,
|
|
163
|
-
ttl,
|
|
164
|
-
storedAt: Timestamp.now(),
|
|
165
|
-
data,
|
|
166
|
-
stale: false,
|
|
167
|
-
deleted: false,
|
|
168
|
-
storerTime
|
|
169
|
-
})
|
|
170
|
-
successfulNodes.push(closestNodes[i])
|
|
171
|
-
continue
|
|
172
|
-
}
|
|
173
|
-
const rpcRemote = new StoreRpcRemote(
|
|
174
|
-
this.localPeerDescriptor,
|
|
175
|
-
closestNodes[i],
|
|
176
|
-
this.serviceId,
|
|
177
|
-
toProtoRpcClient(new StoreRpcClient(this.rpcCommunicator.getRpcClientTransport())),
|
|
178
|
-
this.rpcRequestTimeout
|
|
179
|
-
)
|
|
180
|
-
try {
|
|
181
|
-
const response = await rpcRemote.storeData({ kademliaId: key, data, ttl, storerTime })
|
|
182
|
-
if (!response.error) {
|
|
183
|
-
successfulNodes.push(closestNodes[i])
|
|
184
|
-
logger.trace('remote.storeData() returned success')
|
|
185
|
-
} else {
|
|
186
|
-
logger.trace('remote.storeData() returned error: ' + response.error)
|
|
187
|
-
}
|
|
188
|
-
} catch (e) {
|
|
189
|
-
logger.trace('remote.storeData() threw an exception ' + e)
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return successfulNodes
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private selfIsOneOfClosestPeers(dataId: Uint8Array): boolean {
|
|
196
|
-
const localPeerId = PeerID.fromValue(this.localPeerDescriptor.kademliaId)
|
|
197
|
-
const closestPeers = this.getNodesClosestToIdFromBucket(dataId, this.redundancyFactor)
|
|
198
|
-
const sortedList = new SortedContactList<Contact>(localPeerId, this.redundancyFactor, undefined, true)
|
|
199
|
-
sortedList.addContact(new Contact(this.localPeerDescriptor))
|
|
200
|
-
closestPeers.forEach((con) => sortedList.addContact(new Contact(con.getPeerDescriptor())))
|
|
201
|
-
return sortedList.getClosestContacts().some((node) => node.getPeerId().equals(localPeerId))
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
public async deleteDataFromDht(key: Uint8Array): Promise<void> {
|
|
205
|
-
logger.debug(`Deleting data from DHT ${this.serviceId}`)
|
|
206
|
-
const result = await this.finder.startFind(key)
|
|
207
|
-
const closestNodes = result.closestNodes
|
|
208
|
-
const successfulNodes: PeerDescriptor[] = []
|
|
209
|
-
for (let i = 0; i < closestNodes.length && successfulNodes.length < this.redundancyFactor; i++) {
|
|
210
|
-
if (areEqualPeerDescriptors(this.localPeerDescriptor, closestNodes[i])) {
|
|
211
|
-
this.localDataStore.markAsDeleted(key, peerIdFromPeerDescriptor(this.localPeerDescriptor))
|
|
212
|
-
successfulNodes.push(closestNodes[i])
|
|
213
|
-
continue
|
|
214
|
-
}
|
|
215
|
-
const rpcRemote = new StoreRpcRemote(
|
|
216
|
-
this.localPeerDescriptor,
|
|
217
|
-
closestNodes[i],
|
|
218
|
-
this.serviceId,
|
|
219
|
-
toProtoRpcClient(new StoreRpcClient(this.rpcCommunicator.getRpcClientTransport())),
|
|
220
|
-
this.rpcRequestTimeout
|
|
221
|
-
)
|
|
222
|
-
try {
|
|
223
|
-
const response = await rpcRemote.deleteData({ kademliaId: key })
|
|
224
|
-
if (response.deleted) {
|
|
225
|
-
logger.trace('remote.deleteData() returned success')
|
|
226
|
-
} else {
|
|
227
|
-
logger.trace('could not delete data from ' + getNodeIdFromPeerDescriptor(closestNodes[i]))
|
|
228
|
-
}
|
|
229
|
-
successfulNodes.push(closestNodes[i])
|
|
230
|
-
} catch (e) {
|
|
231
|
-
logger.trace('remote.deleteData() threw an exception ' + e)
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// RPC service implementation
|
|
237
|
-
async storeData(request: StoreDataRequest, context: ServerCallContext): Promise<StoreDataResponse> {
|
|
238
|
-
const ttl = Math.min(request.ttl, this.maxTtl)
|
|
239
|
-
const { incomingSourceDescriptor } = context as DhtCallContext
|
|
240
|
-
const { kademliaId, data, storerTime } = request
|
|
241
|
-
this.localDataStore.storeEntry({
|
|
242
|
-
kademliaId,
|
|
243
|
-
storer: incomingSourceDescriptor!,
|
|
244
|
-
ttl,
|
|
32
|
+
async storeData(request: StoreDataRequest): Promise<StoreDataResponse> {
|
|
33
|
+
logger.trace('storeData()')
|
|
34
|
+
const key = getDhtAddressFromRaw(request.key)
|
|
35
|
+
const selfIsOneOfClosestPeers = this.config.selfIsWithinRedundancyFactor(key)
|
|
36
|
+
this.config.localDataStore.storeEntry({
|
|
37
|
+
key: request.key,
|
|
38
|
+
data: request.data,
|
|
39
|
+
creator: request.creator,
|
|
40
|
+
createdAt: request.createdAt,
|
|
245
41
|
storedAt: Timestamp.now(),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
stale: !this.selfIsOneOfClosestPeers(kademliaId),
|
|
42
|
+
ttl: request.ttl,
|
|
43
|
+
stale: !selfIsOneOfClosestPeers,
|
|
249
44
|
deleted: false
|
|
250
45
|
})
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.localDataStore.setAllEntriesAsStale(PeerID.fromValue(kademliaId))
|
|
46
|
+
if (!selfIsOneOfClosestPeers) {
|
|
47
|
+
this.config.localDataStore.setAllEntriesAsStale(key)
|
|
254
48
|
}
|
|
255
|
-
|
|
256
|
-
logger.trace('storeData()')
|
|
257
|
-
return StoreDataResponse.create()
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// RPC service implementation
|
|
261
|
-
async deleteData(request: DeleteDataRequest, context: ServerCallContext): Promise<DeleteDataResponse> {
|
|
262
|
-
const { incomingSourceDescriptor } = context as DhtCallContext
|
|
263
|
-
const { kademliaId } = request
|
|
264
|
-
const deleted = this.localDataStore.markAsDeleted(kademliaId, peerIdFromPeerDescriptor(incomingSourceDescriptor!))
|
|
265
|
-
return DeleteDataResponse.create({ deleted })
|
|
49
|
+
return {}
|
|
266
50
|
}
|
|
267
51
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const wasStored = this.localDataStore.storeEntry(dataEntry)
|
|
274
|
-
|
|
52
|
+
public async replicateData(request: ReplicateDataRequest, context: ServerCallContext): Promise<Empty> {
|
|
53
|
+
logger.trace('server-side replicateData()')
|
|
54
|
+
const dataEntry = request.entry!
|
|
55
|
+
const wasStored = this.config.localDataStore.storeEntry(dataEntry)
|
|
275
56
|
if (wasStored) {
|
|
276
|
-
this.
|
|
57
|
+
this.config.replicateDataToNeighbors((context as DhtCallContext).incomingSourceDescriptor!, request.entry!)
|
|
277
58
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
logger.trace('server-side migrateData() at end')
|
|
282
|
-
return MigrateDataResponse.create()
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
private migrateDataToNeighborsIfNeeded(incomingPeer: PeerDescriptor, dataEntry: DataEntry): void {
|
|
286
|
-
|
|
287
|
-
// sort own contact list according to data id
|
|
288
|
-
const localPeerId = PeerID.fromValue(this.localPeerDescriptor.kademliaId)
|
|
289
|
-
const dataId = PeerID.fromValue(dataEntry.kademliaId)
|
|
290
|
-
const incomingPeerId = PeerID.fromValue(incomingPeer.kademliaId)
|
|
291
|
-
const closestToData = this.getNodesClosestToIdFromBucket(dataEntry.kademliaId, 10)
|
|
292
|
-
|
|
293
|
-
const sortedList = new SortedContactList<Contact>(dataId, this.redundancyFactor, undefined, true)
|
|
294
|
-
sortedList.addContact(new Contact(this.localPeerDescriptor))
|
|
295
|
-
|
|
296
|
-
closestToData.forEach((con) => {
|
|
297
|
-
sortedList.addContact(new Contact(con.getPeerDescriptor()))
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
if (!sortedList.getAllContacts()[0].getPeerId().equals(localPeerId)) {
|
|
301
|
-
// If we are not the closest node to the data, migrate only to the
|
|
302
|
-
// closest one to the data
|
|
303
|
-
|
|
304
|
-
const contact = sortedList.getAllContacts()[0]
|
|
305
|
-
const contactPeerId = PeerID.fromValue(contact.getPeerDescriptor().kademliaId)
|
|
306
|
-
if (!incomingPeerId.equals(contactPeerId) && !localPeerId.equals(contactPeerId)) {
|
|
307
|
-
setImmediate(async () => {
|
|
308
|
-
try {
|
|
309
|
-
await this.migrateDataToContact(dataEntry, contact.getPeerDescriptor())
|
|
310
|
-
logger.trace('migrateDataToContact() returned when migrating to only the closest contact')
|
|
311
|
-
} catch (e) {
|
|
312
|
-
logger.error('migrating data to only the closest contact failed ' + e)
|
|
313
|
-
}
|
|
314
|
-
})
|
|
315
|
-
}
|
|
316
|
-
} else {
|
|
317
|
-
// if we are the closest to the data, migrate to all storageRedundancyFactor nearest
|
|
318
|
-
sortedList.getAllContacts().forEach((contact) => {
|
|
319
|
-
const contactPeerId = PeerID.fromValue(contact.getPeerDescriptor().kademliaId)
|
|
320
|
-
if (!incomingPeerId.equals(contactPeerId) && !localPeerId.equals(contactPeerId)) {
|
|
321
|
-
if (!incomingPeerId.equals(contactPeerId) && !localPeerId.equals(contactPeerId)) {
|
|
322
|
-
setImmediate(async () => {
|
|
323
|
-
try {
|
|
324
|
-
await this.migrateDataToContact(dataEntry, contact.getPeerDescriptor())
|
|
325
|
-
logger.trace('migrateDataToContact() returned')
|
|
326
|
-
} catch (e) {
|
|
327
|
-
logger.error('migrating data to one of the closest contacts failed ' + e)
|
|
328
|
-
}
|
|
329
|
-
})
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
})
|
|
59
|
+
const key = getDhtAddressFromRaw(dataEntry.key)
|
|
60
|
+
if (!this.config.selfIsWithinRedundancyFactor(key)) {
|
|
61
|
+
this.config.localDataStore.setAllEntriesAsStale(key)
|
|
333
62
|
}
|
|
63
|
+
logger.trace('server-side replicateData() at end')
|
|
64
|
+
return {}
|
|
334
65
|
}
|
|
335
66
|
}
|
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DeleteDataResponse,
|
|
6
|
-
MigrateDataRequest,
|
|
7
|
-
MigrateDataResponse,
|
|
8
|
-
StoreDataRequest,
|
|
9
|
-
StoreDataResponse
|
|
1
|
+
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
2
|
+
import {
|
|
3
|
+
ReplicateDataRequest,
|
|
4
|
+
StoreDataRequest
|
|
10
5
|
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
11
|
-
import {
|
|
6
|
+
import { StoreRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client'
|
|
7
|
+
import { EXISTING_CONNECTION_TIMEOUT, RpcRemote } from '../contact/RpcRemote'
|
|
12
8
|
|
|
13
|
-
export class StoreRpcRemote extends
|
|
9
|
+
export class StoreRpcRemote extends RpcRemote<StoreRpcClient> {
|
|
14
10
|
|
|
15
|
-
async storeData(request: StoreDataRequest): Promise<
|
|
11
|
+
async storeData(request: StoreDataRequest): Promise<void> {
|
|
16
12
|
const options = this.formDhtRpcOptions()
|
|
17
13
|
try {
|
|
18
|
-
|
|
14
|
+
await this.getClient().storeData(request, options)
|
|
19
15
|
} catch (err) {
|
|
20
16
|
const to = getNodeIdFromPeerDescriptor(this.getPeerDescriptor())
|
|
21
17
|
const from = getNodeIdFromPeerDescriptor(this.getLocalPeerDescriptor())
|
|
22
|
-
throw Error(
|
|
23
|
-
`Could not store data to ${to} from ${from} ${err}`
|
|
24
|
-
)
|
|
18
|
+
throw new Error(`Could not store data to ${to} from ${from} ${err}`)
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
|
|
28
|
-
async
|
|
29
|
-
const options = this.formDhtRpcOptions()
|
|
30
|
-
try {
|
|
31
|
-
return await this.getClient().deleteData(request, options)
|
|
32
|
-
} catch (err) {
|
|
33
|
-
throw Error(
|
|
34
|
-
`Could not call delete data to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} ${err}`
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async migrateData(request: MigrateDataRequest, doNotConnect: boolean = false): Promise<MigrateDataResponse> {
|
|
22
|
+
async replicateData(request: ReplicateDataRequest): Promise<void> {
|
|
40
23
|
const options = this.formDhtRpcOptions({
|
|
41
|
-
timeout: EXISTING_CONNECTION_TIMEOUT
|
|
42
|
-
doNotConnect
|
|
24
|
+
timeout: EXISTING_CONNECTION_TIMEOUT
|
|
43
25
|
})
|
|
44
|
-
return this.getClient().
|
|
26
|
+
return this.getClient().replicateData(request, options)
|
|
45
27
|
}
|
|
46
28
|
|
|
47
29
|
}
|
package/src/exports.ts
CHANGED
|
@@ -7,13 +7,23 @@ export { getRandomRegion, getRegionDelayMatrix } from './connection/simulator/pi
|
|
|
7
7
|
export { PeerDescriptor, Message, NodeType, DataEntry } from './proto/packages/dht/protos/DhtRpc'
|
|
8
8
|
export { ITransport } from './transport/ITransport'
|
|
9
9
|
export { ConnectionManager, ConnectionLocker, PortRange, TlsCertificate } from './connection/ConnectionManager'
|
|
10
|
+
export { LockID } from './connection/ConnectionLockHandler'
|
|
10
11
|
export { DefaultConnectorFacade } from './connection/ConnectorFacade'
|
|
11
12
|
export { DhtRpcOptions } from './rpc-protocol/DhtRpcOptions'
|
|
12
|
-
export {
|
|
13
|
-
export { areEqualPeerDescriptors } from './helpers/peerIdFromPeerDescriptor'
|
|
13
|
+
export { RpcRemote, EXISTING_CONNECTION_TIMEOUT } from './dht/contact/RpcRemote'
|
|
14
14
|
export { IceServer } from './connection/webrtc/WebrtcConnector'
|
|
15
15
|
export { DhtCallContext } from './rpc-protocol/DhtCallContext'
|
|
16
16
|
export { ClientWebsocket } from './connection/websocket/ClientWebsocket'
|
|
17
17
|
export { ManagedConnection } from './connection/ManagedConnection'
|
|
18
18
|
export { ConnectionType } from './connection/IConnection'
|
|
19
|
-
export {
|
|
19
|
+
export { ServiceID } from './types/ServiceID'
|
|
20
|
+
export { RingContacts } from './dht/contact/RingContactList'
|
|
21
|
+
export {
|
|
22
|
+
DhtAddress,
|
|
23
|
+
DhtAddressRaw,
|
|
24
|
+
getDhtAddressFromRaw,
|
|
25
|
+
getRawFromDhtAddress,
|
|
26
|
+
createRandomDhtAddress,
|
|
27
|
+
areEqualPeerDescriptors,
|
|
28
|
+
getNodeIdFromPeerDescriptor
|
|
29
|
+
} from './identifiers'
|