@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +7 -7
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +8 -8
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +4 -6
- package/dist/src/connection/ConnectionManager.js +128 -103
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +15 -14
- package/dist/src/connection/ConnectorFacade.js +70 -52
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +9 -2
- package/dist/src/connection/Handshaker.js +117 -27
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +13 -38
- package/dist/src/connection/ManagedConnection.js +31 -252
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/OutputBuffer.d.ts +9 -0
- package/dist/src/connection/OutputBuffer.js +26 -0
- package/dist/src/connection/OutputBuffer.js.map +1 -0
- package/dist/src/connection/PendingConnection.d.ts +19 -0
- package/dist/src/connection/PendingConnection.js +59 -0
- package/dist/src/connection/PendingConnection.js.map +1 -0
- package/dist/src/connection/connectivityChecker.js +3 -3
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +2 -2
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -3
- package/dist/src/connection/simulator/Simulator.js +1 -4
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +1 -2
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +3 -3
- package/dist/src/connection/simulator/SimulatorConnector.js +28 -21
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +3 -20
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +11 -6
- package/dist/src/connection/webrtc/WebrtcConnector.js +57 -42
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +8 -10
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +21 -44
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +8 -2
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +3 -3
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +8 -8
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +1 -1
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +26 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.js +86 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +19 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +23 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +5 -0
- package/dist/src/connection/websocket/{WebsocketConnectorRpcRemote.js → WebsocketClientConnectorRpcRemote.js} +4 -4
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketServer.d.ts +8 -5
- package/dist/src/connection/websocket/WebsocketServer.js +11 -11
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{WebsocketConnector.d.ts → WebsocketServerConnector.d.ts} +16 -21
- package/dist/src/connection/websocket/{WebsocketConnector.js → WebsocketServerConnector.js} +112 -160
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +4 -4
- package/dist/src/dht/DhtNode.js +85 -84
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +9 -9
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +5 -5
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +4 -4
- package/dist/src/dht/PeerManager.js +22 -22
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +3 -3
- package/dist/src/dht/contact/SortedContactList.js +9 -9
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js +21 -21
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -3
- package/dist/src/dht/discovery/PeerDiscovery.js +46 -44
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +3 -3
- package/dist/src/dht/discovery/RingDiscoverySession.js +19 -19
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +33 -33
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +4 -4
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +24 -24
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -4
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -5
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +3 -3
- package/dist/src/dht/routing/Router.js +20 -20
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -3
- package/dist/src/dht/routing/RouterRpcLocal.js +16 -16
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
- package/dist/src/dht/routing/RoutingSession.js +24 -24
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +3 -3
- package/dist/src/dht/store/StoreManager.js +25 -25
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +12 -12
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/exports.d.ts +3 -0
- package/dist/src/exports.js +5 -1
- package/dist/src/exports.js.map +1 -1
- package/dist/src/proto/google/protobuf/any.d.ts +5 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +1 -0
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +4 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -2
- package/dist/src/transport/ListeningRpcCommunicator.js +2 -2
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -2
- package/dist/src/transport/RoutingRpcCommunicator.js +2 -2
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +7 -7
- package/protos/DhtRpc.proto +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +9 -9
- package/src/connection/ConnectionLockRpcRemote.ts +1 -1
- package/src/connection/ConnectionManager.ts +153 -111
- package/src/connection/ConnectorFacade.ts +84 -61
- package/src/connection/Handshaker.ts +131 -27
- package/src/connection/ManagedConnection.ts +41 -304
- package/src/connection/OutputBuffer.ts +28 -0
- package/src/connection/PendingConnection.ts +68 -0
- package/src/connection/connectivityChecker.ts +2 -2
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +1 -5
- package/src/connection/simulator/SimulatorConnection.ts +1 -2
- package/src/connection/simulator/SimulatorConnector.ts +34 -33
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -6
- package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -24
- package/src/connection/webrtc/WebrtcConnector.ts +73 -62
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +26 -56
- package/src/connection/websocket/AbstractWebsocketClientConnection.ts +8 -2
- package/src/connection/websocket/AutoCertifierClientFacade.ts +11 -11
- package/src/connection/websocket/NodeWebsocketClientConnection.ts +1 -1
- package/src/connection/websocket/WebsocketClientConnector.ts +119 -0
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +39 -0
- package/src/connection/websocket/{WebsocketConnectorRpcRemote.ts → WebsocketClientConnectorRpcRemote.ts} +2 -2
- package/src/connection/websocket/WebsocketServer.ts +18 -14
- package/src/connection/websocket/{WebsocketConnector.ts → WebsocketServerConnector.ts} +128 -205
- package/src/dht/DhtNode.ts +90 -89
- package/src/dht/DhtNodeRpcLocal.ts +11 -11
- package/src/dht/ExternalApiRpcLocal.ts +6 -6
- package/src/dht/ExternalApiRpcRemote.ts +2 -2
- package/src/dht/PeerManager.ts +24 -24
- package/src/dht/contact/SortedContactList.ts +10 -10
- package/src/dht/discovery/DiscoverySession.ts +24 -24
- package/src/dht/discovery/PeerDiscovery.ts +47 -45
- package/src/dht/discovery/RingDiscoverySession.ts +23 -23
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +36 -36
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +25 -25
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +7 -7
- package/src/dht/routing/Router.ts +21 -21
- package/src/dht/routing/RouterRpcLocal.ts +17 -17
- package/src/dht/routing/RoutingSession.ts +26 -26
- package/src/dht/store/StoreManager.ts +27 -27
- package/src/dht/store/StoreRpcLocal.ts +13 -13
- package/src/exports.ts +3 -0
- package/src/proto/google/protobuf/any.ts +6 -9
- package/src/proto/google/protobuf/empty.ts +2 -1
- package/src/proto/google/protobuf/timestamp.ts +2 -11
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
- package/src/proto/packages/dht/protos/DhtRpc.ts +4 -4
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/transport/ListeningRpcCommunicator.ts +3 -3
- package/src/transport/RoutingRpcCommunicator.ts +3 -3
- package/test/end-to-end/Layer0Webrtc.test.ts +0 -10
- package/test/integration/ConnectionManager.test.ts +3 -2
- package/test/integration/GeoIpConnectivityChecking.test.ts +1 -1
- package/test/integration/SimultaneousConnections.test.ts +2 -2
- package/test/integration/WebrtcConnectionManagement.test.ts +2 -10
- package/test/integration/{WebsocketConnectorRpc.test.ts → WebsocketClientConnectorRpc.test.ts} +9 -9
- package/test/integration/WebsocketConnectionManagement.test.ts +11 -29
- package/test/unit/ConnectionManager.test.ts +64 -0
- package/test/unit/DiscoverySession.test.ts +1 -1
- package/test/unit/Handshaker.test.ts +169 -0
- package/test/unit/ManagedConnection.test.ts +58 -0
- package/test/unit/PendingConnection.test.ts +57 -0
- package/test/unit/WebrtcConnector.test.ts +56 -0
- package/test/unit/{WebsocketConnector.test.ts → WebsocketClientConnector.test.ts} +56 -11
- package/test/unit/WebsocketServerConnector.test.ts +102 -0
- package/test/utils/FakeConnectorFacade.ts +41 -0
- package/test/utils/mock/MockConnection.ts +26 -0
- package/test/utils/utils.ts +2 -2
- package/dist/src/connection/IConnectionSource.d.ts +0 -4
- package/dist/src/connection/IConnectionSource.js +0 -3
- package/dist/src/connection/IConnectionSource.js.map +0 -1
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.d.ts +0 -7
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.js +0 -20
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnector.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +0 -19
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +0 -23
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +0 -5
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +0 -1
- package/src/connection/IConnectionSource.ts +0 -6
- package/src/connection/webrtc/ManagedWebrtcConnection.ts +0 -27
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +0 -39
|
@@ -7,6 +7,7 @@ const getClosestNodes_1 = require("../contact/getClosestNodes");
|
|
|
7
7
|
const ringIdentifiers_1 = require("../contact/ringIdentifiers");
|
|
8
8
|
const DiscoverySession_1 = require("./DiscoverySession");
|
|
9
9
|
const RingDiscoverySession_1 = require("./RingDiscoverySession");
|
|
10
|
+
const DhtNode_1 = require("../DhtNode");
|
|
10
11
|
const createDistantDhtAddress = (address) => {
|
|
11
12
|
const raw = (0, identifiers_1.getRawFromDhtAddress)(address);
|
|
12
13
|
const flipped = raw.map((val) => ~val);
|
|
@@ -20,15 +21,15 @@ class PeerDiscovery {
|
|
|
20
21
|
rejoinOngoing = false;
|
|
21
22
|
joinCalled = false;
|
|
22
23
|
recoveryIntervalStarted = false;
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
25
|
-
this.
|
|
24
|
+
options;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.options = options;
|
|
26
27
|
}
|
|
27
28
|
async joinDht(entryPoints, doAdditionalDistantPeerDiscovery = true, retry = true) {
|
|
28
29
|
const contactedPeers = new Set();
|
|
29
|
-
const
|
|
30
|
+
const distantJoinOptions = doAdditionalDistantPeerDiscovery
|
|
30
31
|
? { enabled: true, contactedPeers: new Set() } : { enabled: false };
|
|
31
|
-
await Promise.all(entryPoints.map((entryPoint) => this.joinThroughEntryPoint(entryPoint, contactedPeers,
|
|
32
|
+
await Promise.all(entryPoints.map((entryPoint) => this.joinThroughEntryPoint(entryPoint, contactedPeers, distantJoinOptions, retry)));
|
|
32
33
|
}
|
|
33
34
|
async joinThroughEntryPoint(entryPointDescriptor,
|
|
34
35
|
// Note that this set is mutated by DiscoverySession
|
|
@@ -37,47 +38,48 @@ class PeerDiscovery {
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
this.joinCalled = true;
|
|
40
|
-
logger.debug(`Joining ${this.
|
|
41
|
+
logger.debug(`Joining ${this.options.serviceId === DhtNode_1.CONTROL_LAYER_NODE_SERVICE_ID
|
|
42
|
+
? 'The Streamr Network' : `Control Layer for ${this.options.serviceId}`}`
|
|
41
43
|
+ ` via entrypoint ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(entryPointDescriptor)}`);
|
|
42
|
-
if ((0, identifiers_1.areEqualPeerDescriptors)(entryPointDescriptor, this.
|
|
44
|
+
if ((0, identifiers_1.areEqualPeerDescriptors)(entryPointDescriptor, this.options.localPeerDescriptor)) {
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
const targetId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.
|
|
47
|
+
this.options.connectionLocker?.lockConnection(entryPointDescriptor, `${this.options.serviceId}::joinDht`);
|
|
48
|
+
this.options.peerManager.addContact(entryPointDescriptor);
|
|
49
|
+
const targetId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.options.localPeerDescriptor);
|
|
48
50
|
const sessions = [this.createSession(targetId, contactedPeers)];
|
|
49
51
|
if (additionalDistantJoin.enabled) {
|
|
50
52
|
sessions.push(this.createSession((0, exports.createDistantDhtAddress)(targetId), additionalDistantJoin.contactedPeers));
|
|
51
53
|
}
|
|
52
54
|
await this.runSessions(sessions, entryPointDescriptor, retry);
|
|
53
|
-
this.
|
|
55
|
+
this.options.connectionLocker?.unlockConnection(entryPointDescriptor, `${this.options.serviceId}::joinDht`);
|
|
54
56
|
}
|
|
55
57
|
async joinRing() {
|
|
56
58
|
const contactedPeers = new Set();
|
|
57
|
-
const sessions = [this.createRingSession((0, ringIdentifiers_1.getRingIdRawFromPeerDescriptor)(this.
|
|
59
|
+
const sessions = [this.createRingSession((0, ringIdentifiers_1.getRingIdRawFromPeerDescriptor)(this.options.localPeerDescriptor), contactedPeers)];
|
|
58
60
|
await this.runRingSessions(sessions);
|
|
59
61
|
}
|
|
60
62
|
createSession(targetId, contactedPeers) {
|
|
61
63
|
const sessionOptions = {
|
|
62
64
|
targetId,
|
|
63
|
-
parallelism: this.
|
|
64
|
-
noProgressLimit: this.
|
|
65
|
-
peerManager: this.
|
|
65
|
+
parallelism: this.options.parallelism,
|
|
66
|
+
noProgressLimit: this.options.joinNoProgressLimit,
|
|
67
|
+
peerManager: this.options.peerManager,
|
|
66
68
|
contactedPeers,
|
|
67
|
-
abortSignal: this.
|
|
68
|
-
createDhtNodeRpcRemote: this.
|
|
69
|
+
abortSignal: this.options.abortSignal,
|
|
70
|
+
createDhtNodeRpcRemote: this.options.createDhtNodeRpcRemote
|
|
69
71
|
};
|
|
70
72
|
return new DiscoverySession_1.DiscoverySession(sessionOptions);
|
|
71
73
|
}
|
|
72
74
|
createRingSession(targetId, contactedPeers) {
|
|
73
75
|
const sessionOptions = {
|
|
74
76
|
targetId,
|
|
75
|
-
parallelism: this.
|
|
76
|
-
noProgressLimit: this.
|
|
77
|
-
peerManager: this.
|
|
77
|
+
parallelism: this.options.parallelism,
|
|
78
|
+
noProgressLimit: this.options.joinNoProgressLimit,
|
|
79
|
+
peerManager: this.options.peerManager,
|
|
78
80
|
contactedPeers,
|
|
79
|
-
abortSignal: this.
|
|
80
|
-
createDhtNodeRpcRemote: this.
|
|
81
|
+
abortSignal: this.options.abortSignal,
|
|
82
|
+
createDhtNodeRpcRemote: this.options.createDhtNodeRpcRemote
|
|
81
83
|
};
|
|
82
84
|
return new RingDiscoverySession_1.RingDiscoverySession(sessionOptions);
|
|
83
85
|
}
|
|
@@ -85,19 +87,19 @@ class PeerDiscovery {
|
|
|
85
87
|
try {
|
|
86
88
|
for (const session of sessions) {
|
|
87
89
|
this.ongoingDiscoverySessions.set(session.id, session);
|
|
88
|
-
await session.findClosestNodes(this.
|
|
90
|
+
await session.findClosestNodes(this.options.joinTimeout);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
catch (_e) {
|
|
92
|
-
logger.debug(`DHT join on ${this.
|
|
94
|
+
logger.debug(`DHT join on ${this.options.serviceId} timed out`);
|
|
93
95
|
}
|
|
94
96
|
finally {
|
|
95
97
|
if (!this.isStopped()) {
|
|
96
|
-
if (this.
|
|
98
|
+
if (this.options.peerManager.getNeighborCount() === 0) {
|
|
97
99
|
if (retry) {
|
|
98
100
|
// TODO should we catch possible promise rejection?
|
|
99
|
-
// TODO use
|
|
100
|
-
(0, utils_1.setAbortableTimeout)(() => this.rejoinDht(entryPointDescriptor), 1000, this.
|
|
101
|
+
// TODO use options option or named constant?
|
|
102
|
+
(0, utils_1.setAbortableTimeout)(() => this.rejoinDht(entryPointDescriptor), 1000, this.options.abortSignal);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
else {
|
|
@@ -111,11 +113,11 @@ class PeerDiscovery {
|
|
|
111
113
|
try {
|
|
112
114
|
for (const session of sessions) {
|
|
113
115
|
this.ongoingRingDiscoverySessions.set(session.id, session);
|
|
114
|
-
await session.findClosestNodes(this.
|
|
116
|
+
await session.findClosestNodes(this.options.joinTimeout);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
catch (_e) {
|
|
118
|
-
logger.debug(`Ring join on ${this.
|
|
120
|
+
logger.debug(`Ring join on ${this.options.serviceId} timed out`);
|
|
119
121
|
}
|
|
120
122
|
finally {
|
|
121
123
|
sessions.forEach((session) => this.ongoingDiscoverySessions.delete(session.id));
|
|
@@ -125,18 +127,18 @@ class PeerDiscovery {
|
|
|
125
127
|
if (this.isStopped() || this.rejoinOngoing) {
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
128
|
-
logger.debug(`Rejoining DHT ${this.
|
|
130
|
+
logger.debug(`Rejoining DHT ${this.options.serviceId}`);
|
|
129
131
|
this.rejoinOngoing = true;
|
|
130
132
|
try {
|
|
131
133
|
await this.joinThroughEntryPoint(entryPoint, contactedPeers, { enabled: true, contactedPeers: distantJoinContactPeers });
|
|
132
|
-
logger.debug(`Rejoined DHT successfully ${this.
|
|
134
|
+
logger.debug(`Rejoined DHT successfully ${this.options.serviceId}!`);
|
|
133
135
|
}
|
|
134
136
|
catch (err) {
|
|
135
|
-
logger.warn(`Rejoining DHT ${this.
|
|
137
|
+
logger.warn(`Rejoining DHT ${this.options.serviceId} failed`);
|
|
136
138
|
if (!this.isStopped()) {
|
|
137
139
|
// TODO should we catch possible promise rejection?
|
|
138
|
-
// TODO use
|
|
139
|
-
(0, utils_1.setAbortableTimeout)(() => this.rejoinDht(entryPoint), 5000, this.
|
|
140
|
+
// TODO use options option or named constant?
|
|
141
|
+
(0, utils_1.setAbortableTimeout)(() => this.rejoinDht(entryPoint), 5000, this.options.abortSignal);
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
finally {
|
|
@@ -146,36 +148,36 @@ class PeerDiscovery {
|
|
|
146
148
|
async ensureRecoveryIntervalIsRunning() {
|
|
147
149
|
if (!this.recoveryIntervalStarted) {
|
|
148
150
|
this.recoveryIntervalStarted = true;
|
|
149
|
-
// TODO use
|
|
150
|
-
await (0, utils_1.scheduleAtInterval)(() => this.fetchClosestAndRandomNeighbors(), 60000, true, this.
|
|
151
|
+
// TODO use options option or named constant?
|
|
152
|
+
await (0, utils_1.scheduleAtInterval)(() => this.fetchClosestAndRandomNeighbors(), 60000, true, this.options.abortSignal);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
async fetchClosestAndRandomNeighbors() {
|
|
154
156
|
if (this.isStopped()) {
|
|
155
157
|
return;
|
|
156
158
|
}
|
|
157
|
-
const localNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.
|
|
158
|
-
const nodes = this.getClosestNeighbors(localNodeId, this.
|
|
159
|
+
const localNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.options.localPeerDescriptor);
|
|
160
|
+
const nodes = this.getClosestNeighbors(localNodeId, this.options.parallelism);
|
|
159
161
|
const randomNodes = this.getClosestNeighbors((0, identifiers_1.createRandomDhtAddress)(), 1);
|
|
160
162
|
await Promise.allSettled([
|
|
161
163
|
...nodes.map(async (node) => {
|
|
162
|
-
const remote = this.
|
|
164
|
+
const remote = this.options.createDhtNodeRpcRemote(node);
|
|
163
165
|
const contacts = await remote.getClosestPeers(localNodeId);
|
|
164
166
|
for (const contact of contacts) {
|
|
165
|
-
this.
|
|
167
|
+
this.options.peerManager.addContact(contact);
|
|
166
168
|
}
|
|
167
169
|
}),
|
|
168
170
|
...randomNodes.map(async (node) => {
|
|
169
|
-
const remote = this.
|
|
171
|
+
const remote = this.options.createDhtNodeRpcRemote(node);
|
|
170
172
|
const contacts = await remote.getClosestPeers((0, identifiers_1.createRandomDhtAddress)());
|
|
171
173
|
for (const contact of contacts) {
|
|
172
|
-
this.
|
|
174
|
+
this.options.peerManager.addContact(contact);
|
|
173
175
|
}
|
|
174
176
|
})
|
|
175
177
|
]);
|
|
176
178
|
}
|
|
177
179
|
getClosestNeighbors(referenceId, maxCount) {
|
|
178
|
-
return (0, getClosestNodes_1.getClosestNodes)(referenceId, this.
|
|
180
|
+
return (0, getClosestNodes_1.getClosestNodes)(referenceId, this.options.peerManager.getNeighbors().map((n) => n.getPeerDescriptor()), { maxCount });
|
|
179
181
|
}
|
|
180
182
|
isJoinOngoing() {
|
|
181
183
|
return !this.joinCalled ? true : this.ongoingDiscoverySessions.size > 0;
|
|
@@ -184,7 +186,7 @@ class PeerDiscovery {
|
|
|
184
186
|
return this.joinCalled;
|
|
185
187
|
}
|
|
186
188
|
isStopped() {
|
|
187
|
-
return this.
|
|
189
|
+
return this.options.abortSignal.aborted;
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
exports.PeerDiscovery = PeerDiscovery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeerDiscovery.js","sourceRoot":"","sources":["../../../../src/dht/discovery/PeerDiscovery.ts"],"names":[],"mappings":";;;AAAA,0CAAgF;AAEhF,mDAO0B;AAK1B,gEAA4D;AAC5D,gEAAsF;AACtF,yDAAqD;AACrD,iEAA6D;
|
|
1
|
+
{"version":3,"file":"PeerDiscovery.js","sourceRoot":"","sources":["../../../../src/dht/discovery/PeerDiscovery.ts"],"names":[],"mappings":";;;AAAA,0CAAgF;AAEhF,mDAO0B;AAK1B,gEAA4D;AAC5D,gEAAsF;AACtF,yDAAqD;AACrD,iEAA6D;AAC7D,wCAA0D;AAcnD,MAAM,uBAAuB,GAAG,CAAC,OAAmB,EAAc,EAAE;IACvE,MAAM,GAAG,GAAG,IAAA,kCAAoB,EAAC,OAAO,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;IACtC,OAAO,IAAA,kCAAoB,EAAC,OAAO,CAAC,CAAA;AACxC,CAAC,CAAA;AAJY,QAAA,uBAAuB,2BAInC;AAED,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,aAAa;IAEd,wBAAwB,GAAkC,IAAI,GAAG,EAAE,CAAA;IACnE,4BAA4B,GAAsC,IAAI,GAAG,EAAE,CAAA;IAE3E,aAAa,GAAG,KAAK,CAAA;IACrB,UAAU,GAAG,KAAK,CAAA;IAClB,uBAAuB,GAAG,KAAK,CAAA;IACtB,OAAO,CAAsB;IAE9C,YAAY,OAA6B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO,CACT,WAA6B,EAC7B,gCAAgC,GAAG,IAAI,EACvC,KAAK,GAAG,IAAI;QAEZ,MAAM,cAAc,GAA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;QAChB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,GAAG,CAAC,CAAA;IAC3E,CAAC;IAEM,YAAY;QACf,OAAO,IAAI,CAAC,UAAU,CAAA;IAC1B,CAAC;IAEO,SAAS;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAA;IAC3C,CAAC;CACJ;AA3MD,sCA2MC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { DhtAddress } from '../../identifiers';
|
|
3
3
|
import { PeerManager } from '../PeerManager';
|
|
4
4
|
import { RingIdRaw } from '../contact/ringIdentifiers';
|
|
5
|
-
interface
|
|
5
|
+
interface RingDiscoverySessionOptions {
|
|
6
6
|
targetId: RingIdRaw;
|
|
7
7
|
parallelism: number;
|
|
8
8
|
noProgressLimit: number;
|
|
@@ -15,10 +15,10 @@ export declare class RingDiscoverySession {
|
|
|
15
15
|
private noProgressCounter;
|
|
16
16
|
private ongoingRequests;
|
|
17
17
|
private doneGate;
|
|
18
|
-
private readonly
|
|
18
|
+
private readonly options;
|
|
19
19
|
private numContactedPeers;
|
|
20
20
|
private targetIdAsRingId;
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(options: RingDiscoverySessionOptions);
|
|
22
22
|
private addContacts;
|
|
23
23
|
private fetchClosestContactsFromRemote;
|
|
24
24
|
private onRequestSucceeded;
|
|
@@ -11,30 +11,30 @@ class RingDiscoverySession {
|
|
|
11
11
|
noProgressCounter = 0;
|
|
12
12
|
ongoingRequests = new Set();
|
|
13
13
|
doneGate = new utils_1.Gate(false);
|
|
14
|
-
|
|
14
|
+
options;
|
|
15
15
|
numContactedPeers = 0;
|
|
16
16
|
targetIdAsRingId;
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
19
|
-
this.targetIdAsRingId = (0, ringIdentifiers_1.getRingIdFromRaw)(this.
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.targetIdAsRingId = (0, ringIdentifiers_1.getRingIdFromRaw)(this.options.targetId);
|
|
20
20
|
}
|
|
21
21
|
addContacts(contacts) {
|
|
22
|
-
if (this.
|
|
22
|
+
if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
for (const contact of contacts) {
|
|
26
|
-
this.
|
|
26
|
+
this.options.peerManager.addContact(contact);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
async fetchClosestContactsFromRemote(contact) {
|
|
30
|
-
if (this.
|
|
30
|
+
if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
|
|
31
31
|
return { left: [], right: [] };
|
|
32
32
|
}
|
|
33
33
|
logger.trace(`Getting closest ring peers from contact: ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(contact.getPeerDescriptor())}`);
|
|
34
34
|
this.numContactedPeers++;
|
|
35
|
-
this.
|
|
36
|
-
const returnedContacts = await contact.getClosestRingPeers(this.
|
|
37
|
-
this.
|
|
35
|
+
this.options.contactedPeers.add(contact.getNodeId());
|
|
36
|
+
const returnedContacts = await contact.getClosestRingPeers(this.options.targetId);
|
|
37
|
+
this.options.peerManager.setContactActive(contact.getNodeId());
|
|
38
38
|
return returnedContacts;
|
|
39
39
|
}
|
|
40
40
|
onRequestSucceeded(nodeId, contacts) {
|
|
@@ -42,11 +42,11 @@ class RingDiscoverySession {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
this.ongoingRequests.delete(nodeId);
|
|
45
|
-
const oldClosestContacts = this.
|
|
45
|
+
const oldClosestContacts = this.options.peerManager.getClosestRingContactsTo(this.options.targetId, 1);
|
|
46
46
|
const oldClosestLeftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(oldClosestContacts.left[0].getPeerDescriptor()));
|
|
47
47
|
const oldClosestRightDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(oldClosestContacts.right[0].getPeerDescriptor()));
|
|
48
48
|
this.addContacts(contacts.left.concat(contacts.right));
|
|
49
|
-
const newClosestContacts = this.
|
|
49
|
+
const newClosestContacts = this.options.peerManager.getClosestRingContactsTo(this.options.targetId, 1);
|
|
50
50
|
const newClosestLeftDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(newClosestContacts.left[0].getPeerDescriptor()));
|
|
51
51
|
const newClosestRightDistance = (0, ringIdentifiers_1.getLeftDistance)(this.targetIdAsRingId, (0, ringIdentifiers_1.getRingIdFromPeerDescriptor)(newClosestContacts.right[0].getPeerDescriptor()));
|
|
52
52
|
if (newClosestLeftDistance >= oldClosestLeftDistance && newClosestRightDistance >= oldClosestRightDistance) {
|
|
@@ -58,15 +58,15 @@ class RingDiscoverySession {
|
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
this.ongoingRequests.delete(peer.getNodeId());
|
|
61
|
-
this.
|
|
61
|
+
this.options.peerManager.removeContact(peer.getNodeId());
|
|
62
62
|
}
|
|
63
63
|
findMoreContacts() {
|
|
64
|
-
if (this.
|
|
64
|
+
if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
const uncontacted = this.
|
|
67
|
+
const uncontacted = this.options.peerManager.getClosestRingContactsTo(this.options.targetId, this.options.parallelism, this.options.contactedPeers);
|
|
68
68
|
if ((uncontacted.left.length === 0 && uncontacted.right.length === 0)
|
|
69
|
-
|| this.noProgressCounter >= this.
|
|
69
|
+
|| this.noProgressCounter >= this.options.noProgressLimit) {
|
|
70
70
|
this.doneGate.open();
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
@@ -89,7 +89,7 @@ class RingDiscoverySession {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
for (const nextPeer of merged) {
|
|
92
|
-
if (this.ongoingRequests.size >= this.
|
|
92
|
+
if (this.ongoingRequests.size >= this.options.parallelism) {
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
95
|
this.ongoingRequests.add(nextPeer.getNodeId());
|
|
@@ -103,13 +103,13 @@ class RingDiscoverySession {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
async findClosestNodes(timeout) {
|
|
106
|
-
if (this.
|
|
106
|
+
if (this.options.peerManager.getNearbyContactCount(this.options.contactedPeers) === 0) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
setImmediate(() => {
|
|
110
110
|
this.findMoreContacts();
|
|
111
111
|
});
|
|
112
|
-
await (0, utils_1.withTimeout)(this.doneGate.waitUntilOpen(), timeout, 'discovery session timed out', this.
|
|
112
|
+
await (0, utils_1.withTimeout)(this.doneGate.waitUntilOpen(), timeout, 'discovery session timed out', this.options.abortSignal);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
exports.RingDiscoverySession = RingDiscoverySession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RingDiscoverySession.js","sourceRoot":"","sources":["../../../../src/dht/discovery/RingDiscoverySession.ts"],"names":[],"mappings":";;;AAAA,0CAA0D;AAC1D,+BAAyB;AACzB,mDAA2E;AAK3E,gEAA8H;AAE9H,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAYjC,MAAa,oBAAoB;IAEb,EAAE,GAAG,IAAA,SAAE,GAAE,CAAA;IACjB,iBAAiB,GAAG,CAAC,CAAA;IACrB,eAAe,GAAoB,IAAI,GAAG,EAAE,CAAA;IAC5C,QAAQ,GAAG,IAAI,YAAI,CAAC,KAAK,CAAC,CAAA;IACjB,
|
|
1
|
+
{"version":3,"file":"RingDiscoverySession.js","sourceRoot":"","sources":["../../../../src/dht/discovery/RingDiscoverySession.ts"],"names":[],"mappings":";;;A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iceID';
|
|
8
8
|
import { DhtAddress } from '../../identifiers';
|
|
9
9
|
import { ConnectionsView } from '../../exports';
|
|
10
|
-
interface
|
|
10
|
+
interface RecursiveOperationManagerOptions {
|
|
11
11
|
rpcCommunicator: RoutingRpcCommunicator;
|
|
12
12
|
sessionTransport: ITransport;
|
|
13
13
|
router: Router;
|
|
@@ -25,8 +25,8 @@ export interface RecursiveOperationResult {
|
|
|
25
25
|
export declare class RecursiveOperationManager {
|
|
26
26
|
private ongoingSessions;
|
|
27
27
|
private stopped;
|
|
28
|
-
private readonly
|
|
29
|
-
constructor(
|
|
28
|
+
private readonly options;
|
|
29
|
+
constructor(options: RecursiveOperationManagerOptions);
|
|
30
30
|
private registerLocalRpcMethods;
|
|
31
31
|
execute(targetId: DhtAddress, operation: RecursiveOperation, excludedPeer?: DhtAddress, waitForCompletion?: boolean): Promise<RecursiveOperationResult>;
|
|
32
32
|
private sendResponse;
|
|
@@ -18,19 +18,19 @@ const logger = new utils_1.Logger(module);
|
|
|
18
18
|
class RecursiveOperationManager {
|
|
19
19
|
ongoingSessions = new Map();
|
|
20
20
|
stopped = false;
|
|
21
|
-
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
21
|
+
options;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.options = options;
|
|
24
24
|
this.registerLocalRpcMethods();
|
|
25
25
|
}
|
|
26
26
|
registerLocalRpcMethods() {
|
|
27
27
|
const rpcLocal = new RecursiveOperationRpcLocal_1.RecursiveOperationRpcLocal({
|
|
28
28
|
doRouteRequest: (routedMessage) => this.doRouteRequest(routedMessage),
|
|
29
|
-
addContact: (contact) => this.
|
|
30
|
-
isMostLikelyDuplicate: (requestId) => this.
|
|
31
|
-
addToDuplicateDetector: (requestId) => this.
|
|
29
|
+
addContact: (contact) => this.options.addContact(contact),
|
|
30
|
+
isMostLikelyDuplicate: (requestId) => this.options.router.isMostLikelyDuplicate(requestId),
|
|
31
|
+
addToDuplicateDetector: (requestId) => this.options.router.addToDuplicateDetector(requestId)
|
|
32
32
|
});
|
|
33
|
-
this.
|
|
33
|
+
this.options.rpcCommunicator.registerRpcMethod(DhtRpc_1.RouteMessageWrapper, DhtRpc_1.RouteMessageAck, 'routeRequest', async (routedMessage) => {
|
|
34
34
|
if (this.stopped) {
|
|
35
35
|
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage, DhtRpc_1.RouteMessageError.STOPPED);
|
|
36
36
|
}
|
|
@@ -44,27 +44,27 @@ class RecursiveOperationManager {
|
|
|
44
44
|
return { closestNodes: [] };
|
|
45
45
|
}
|
|
46
46
|
const session = new RecursiveOperationSession_1.RecursiveOperationSession({
|
|
47
|
-
transport: this.
|
|
47
|
+
transport: this.options.sessionTransport,
|
|
48
48
|
targetId,
|
|
49
|
-
localPeerDescriptor: this.
|
|
50
|
-
// TODO use
|
|
51
|
-
waitedRoutingPathCompletions: this.
|
|
49
|
+
localPeerDescriptor: this.options.localPeerDescriptor,
|
|
50
|
+
// TODO use options option or named constant?
|
|
51
|
+
waitedRoutingPathCompletions: this.options.connectionsView.getConnectionCount() > 1 ? 2 : 1,
|
|
52
52
|
operation,
|
|
53
53
|
// TODO would it make sense to give excludedPeer as one of the fields RecursiveOperationSession?
|
|
54
54
|
doRouteRequest: (routedMessage) => {
|
|
55
55
|
return this.doRouteRequest(routedMessage, excludedPeer);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
-
if (this.
|
|
59
|
-
const dataEntries = Array.from(this.
|
|
60
|
-
session.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.
|
|
58
|
+
if (this.options.connectionsView.getConnectionCount() === 0) {
|
|
59
|
+
const dataEntries = Array.from(this.options.localDataStore.values(targetId));
|
|
60
|
+
session.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.options.localPeerDescriptor), [this.options.localPeerDescriptor], [this.options.localPeerDescriptor], dataEntries, true);
|
|
61
61
|
return session.getResults();
|
|
62
62
|
}
|
|
63
63
|
this.ongoingSessions.set(session.getId(), session);
|
|
64
64
|
if (waitForCompletion === true) {
|
|
65
65
|
try {
|
|
66
|
-
await (0, utils_1.runAndWaitForEvents3)([() => session.start(this.
|
|
67
|
-
// TODO use
|
|
66
|
+
await (0, utils_1.runAndWaitForEvents3)([() => session.start(this.options.serviceId)], [[session, 'completed']],
|
|
67
|
+
// TODO use options option or named constant?
|
|
68
68
|
15000);
|
|
69
69
|
}
|
|
70
70
|
catch (err) {
|
|
@@ -72,35 +72,35 @@ class RecursiveOperationManager {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
session.start(this.
|
|
75
|
+
session.start(this.options.serviceId);
|
|
76
76
|
// Wait for delete operation to be sent out by the router
|
|
77
77
|
// TODO: Add a feature to wait for the router to pass the message?
|
|
78
78
|
await (0, utils_1.wait)(50);
|
|
79
79
|
}
|
|
80
80
|
if (operation === DhtRpc_1.RecursiveOperation.FETCH_DATA) {
|
|
81
|
-
const dataEntries = Array.from(this.
|
|
81
|
+
const dataEntries = Array.from(this.options.localDataStore.values(targetId));
|
|
82
82
|
if (dataEntries.length > 0) {
|
|
83
|
-
this.sendResponse([this.
|
|
83
|
+
this.sendResponse([this.options.localPeerDescriptor], this.options.localPeerDescriptor, session.getId(), [], dataEntries, true);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
else if (operation === DhtRpc_1.RecursiveOperation.DELETE_DATA) {
|
|
87
|
-
this.
|
|
87
|
+
this.options.localDataStore.markAsDeleted(targetId, (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.options.localPeerDescriptor));
|
|
88
88
|
}
|
|
89
89
|
this.ongoingSessions.delete(session.getId());
|
|
90
90
|
session.stop();
|
|
91
91
|
return session.getResults();
|
|
92
92
|
}
|
|
93
93
|
sendResponse(routingPath, targetPeerDescriptor, serviceId, closestConnectedNodes, dataEntries, noCloserNodesFound = false) {
|
|
94
|
-
const isOwnNode = (0, identifiers_1.areEqualPeerDescriptors)(this.
|
|
94
|
+
const isOwnNode = (0, identifiers_1.areEqualPeerDescriptors)(this.options.localPeerDescriptor, targetPeerDescriptor);
|
|
95
95
|
if (isOwnNode && this.ongoingSessions.has(serviceId)) {
|
|
96
96
|
this.ongoingSessions.get(serviceId)
|
|
97
|
-
.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.
|
|
97
|
+
.onResponseReceived((0, identifiers_1.getNodeIdFromPeerDescriptor)(this.options.localPeerDescriptor), routingPath, closestConnectedNodes, dataEntries, noCloserNodesFound);
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
|
-
// TODO use
|
|
101
|
-
const remoteCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(serviceId, this.
|
|
102
|
-
const rpcRemote = new RecursiveOperationSessionRpcRemote_1.RecursiveOperationSessionRpcRemote(this.
|
|
103
|
-
// TODO use
|
|
100
|
+
// TODO use options option or named constant?
|
|
101
|
+
const remoteCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(serviceId, this.options.sessionTransport, { rpcRequestTimeout: 15000 });
|
|
102
|
+
const rpcRemote = new RecursiveOperationSessionRpcRemote_1.RecursiveOperationSessionRpcRemote(this.options.localPeerDescriptor, targetPeerDescriptor, remoteCommunicator, DhtRpc_client_1.RecursiveOperationSessionRpcClient,
|
|
103
|
+
// TODO use options option or named constant?
|
|
104
104
|
10000);
|
|
105
105
|
rpcRemote.sendResponse(routingPath, closestConnectedNodes, dataEntries, noCloserNodesFound);
|
|
106
106
|
remoteCommunicator.destroy();
|
|
@@ -112,21 +112,21 @@ class RecursiveOperationManager {
|
|
|
112
112
|
}
|
|
113
113
|
const targetId = (0, identifiers_1.getDhtAddressFromRaw)(routedMessage.target);
|
|
114
114
|
const request = routedMessage.message.body.recursiveOperationRequest;
|
|
115
|
-
// TODO use
|
|
115
|
+
// TODO use options option or named constant?
|
|
116
116
|
const closestConnectedNodes = this.getClosestConnectedNodes(targetId, 5);
|
|
117
117
|
const dataEntries = (request.operation === DhtRpc_1.RecursiveOperation.FETCH_DATA)
|
|
118
|
-
? Array.from(this.
|
|
118
|
+
? Array.from(this.options.localDataStore.values(targetId))
|
|
119
119
|
: [];
|
|
120
120
|
if (request.operation === DhtRpc_1.RecursiveOperation.DELETE_DATA) {
|
|
121
|
-
this.
|
|
121
|
+
this.options.localDataStore.markAsDeleted(targetId, (0, identifiers_1.getNodeIdFromPeerDescriptor)(routedMessage.sourcePeer));
|
|
122
122
|
}
|
|
123
|
-
if ((0, utils_1.areEqualBinaries)(this.
|
|
123
|
+
if ((0, utils_1.areEqualBinaries)(this.options.localPeerDescriptor.nodeId, routedMessage.target)) {
|
|
124
124
|
// TODO this is also very similar case to what we do at line 255, could simplify the code paths?
|
|
125
125
|
this.sendResponse(routedMessage.routingPath, routedMessage.sourcePeer, request.sessionId, closestConnectedNodes, dataEntries, true);
|
|
126
126
|
return (0, RouterRpcLocal_1.createRouteMessageAck)(routedMessage);
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
|
-
const ack = this.
|
|
129
|
+
const ack = this.options.router.doRouteMessage(routedMessage, RoutingSession_1.RoutingMode.RECURSIVE, excludedPeer);
|
|
130
130
|
if ((ack.error === undefined) || (ack.error === DhtRpc_1.RouteMessageError.NO_TARGETS)) {
|
|
131
131
|
const noCloserContactsFound = (ack.error === DhtRpc_1.RouteMessageError.NO_TARGETS) ||
|
|
132
132
|
(closestConnectedNodes.length > 0
|
|
@@ -138,7 +138,7 @@ class RecursiveOperationManager {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
getClosestConnectedNodes(referenceId, limit) {
|
|
141
|
-
const connectedNodes = this.
|
|
141
|
+
const connectedNodes = this.options.connectionsView.getConnections().map((c) => this.options.createDhtNodeRpcRemote(c));
|
|
142
142
|
const sorted = new SortedContactList_1.SortedContactList({
|
|
143
143
|
referenceId,
|
|
144
144
|
maxSize: limit,
|
|
@@ -150,7 +150,7 @@ class RecursiveOperationManager {
|
|
|
150
150
|
isPeerCloserToIdThanSelf(peer, nodeIdOrDataKey) {
|
|
151
151
|
const nodeIdOrDataKeyRaw = (0, identifiers_1.getRawFromDhtAddress)(nodeIdOrDataKey);
|
|
152
152
|
const distance1 = (0, PeerManager_1.getDistance)(peer.nodeId, nodeIdOrDataKeyRaw);
|
|
153
|
-
const distance2 = (0, PeerManager_1.getDistance)(this.
|
|
153
|
+
const distance2 = (0, PeerManager_1.getDistance)(this.options.localPeerDescriptor.nodeId, nodeIdOrDataKeyRaw);
|
|
154
154
|
return distance1 < distance2;
|
|
155
155
|
}
|
|
156
156
|
stop() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecursiveOperationManager.js","sourceRoot":"","sources":["../../../../src/dht/recursive-operation/RecursiveOperationManager.ts"],"names":[],"mappings":";;;AAAA,mEAQ+C;AAE/C,8DAAuD;AACvD,0CAAqF;AAErF,6FAAyF;AACzF,2EAAwG;AAIxG,uFAAmF;AACnF,iFAAkG;AAClG,oEAAgE;AAChE,gEAA4D;AAC5D,8DAAiE;AAEjE,6EAAyE;AACzE,mDAAgJ;AAChJ,gDAA4C;AAiB5C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,yBAAyB;IAE1B,eAAe,GAA2C,IAAI,GAAG,EAAE,CAAA;IACnE,OAAO,GAAG,KAAK,CAAA;IACN,
|
|
1
|
+
{"version":3,"file":"RecursiveOperationManager.js","sourceRoot":"","sources":["../../../../src/dht/recursive-operation/RecursiveOperationManager.ts"],"names":[],"mappings":";;;AAAA,mEAQ+C;AAE/C,8DAAuD;AACvD,0CAAqF;AAErF,6FAAyF;AACzF,2EAAwG;AAIxG,uFAAmF;AACnF,iFAAkG;AAClG,oEAAgE;AAChE,gEAA4D;AAC5D,8DAAiE;AAEjE,6EAAyE;AACzE,mDAAgJ;AAChJ,gDAA4C;AAiB5C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,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