@streamr/dht 0.0.1-tatum.6 → 0.0.1-tatum.8
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/src/connection/ConnectionLockHandler.d.ts +1 -1
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +10 -0
- package/dist/src/connection/{RemoteConnectionLocker.js → ConnectionLockRpcRemote.js} +21 -35
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +17 -41
- package/dist/src/connection/ConnectionManager.js +148 -212
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.js +16 -13
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +49 -0
- package/dist/src/connection/ConnectorFacade.js +83 -0
- package/dist/src/connection/ConnectorFacade.js.map +1 -0
- package/dist/src/connection/Handshaker.d.ts +1 -2
- package/dist/src/connection/Handshaker.js +1 -4
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +2 -6
- package/dist/src/connection/ManagedConnection.js +27 -36
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.js +2 -2
- package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -1
- package/dist/src/connection/Simulator/Simulator.d.ts +0 -2
- package/dist/src/connection/Simulator/Simulator.js +0 -5
- package/dist/src/connection/Simulator/Simulator.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js +16 -13
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +2 -3
- package/dist/src/connection/Simulator/SimulatorConnector.js +12 -14
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js +6 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +3 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +12 -12
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -1
- package/dist/src/connection/WebRTC/{WebRtcConnector.d.ts → WebRtcConnectorRpcLocal.d.ts} +13 -13
- package/dist/src/connection/WebRTC/{WebRtcConnector.js → WebRtcConnectorRpcLocal.js} +46 -38
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.d.ts +11 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js +55 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebRTC/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/WebSocket/{WebSocketConnector.d.ts → WebSocketConnectorRpcLocal.d.ts} +21 -11
- package/dist/src/connection/WebSocket/{WebSocketConnector.js → WebSocketConnectorRpcLocal.js} +80 -59
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.d.ts +8 -0
- package/dist/src/connection/WebSocket/{RemoteWebSocketConnector.js → WebSocketConnectorRpcRemote.js} +12 -16
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +11 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js +15 -10
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +18 -55
- package/dist/src/dht/DhtNode.js +122 -145
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/{RemoteExternalApi.d.ts → ExternalApiRpcRemote.d.ts} +2 -2
- package/dist/src/dht/{RemoteExternalApi.js → ExternalApiRpcRemote.js} +5 -6
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -0
- package/dist/src/dht/{DhtPeer.d.ts → RemoteDhtNode.d.ts} +2 -3
- package/dist/src/dht/{DhtPeer.js → RemoteDhtNode.js} +21 -19
- package/dist/src/dht/RemoteDhtNode.js.map +1 -0
- package/dist/src/dht/contact/ContactList.d.ts +0 -1
- package/dist/src/dht/contact/ContactList.js +0 -3
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +0 -1
- package/dist/src/dht/contact/RandomContactList.js +0 -3
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +0 -3
- package/dist/src/dht/contact/SortedContactList.js +0 -9
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +5 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -10
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +12 -11
- package/dist/src/dht/discovery/PeerDiscovery.js +33 -37
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/RecursiveFindSession.d.ts +9 -10
- package/dist/src/dht/find/RecursiveFindSession.js +13 -13
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -1
- package/dist/src/dht/find/RecursiveFinder.d.ts +9 -11
- package/dist/src/dht/find/RecursiveFinder.js +35 -36
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js +4 -4
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.js +4 -3
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +1 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +1 -2
- package/dist/src/dht/routing/DuplicateDetector.js +2 -7
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +12 -15
- package/dist/src/dht/routing/Router.js +30 -33
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/{RemoteRouter.d.ts → RouterRpcRemote.d.ts} +2 -2
- package/dist/src/dht/routing/{RemoteRouter.js → RouterRpcRemote.js} +5 -5
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -4
- package/dist/src/dht/routing/RoutingSession.js +6 -5
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/{DataStore.d.ts → StoreRpcLocal.d.ts} +6 -6
- package/dist/src/dht/store/{DataStore.js → StoreRpcLocal.js} +34 -34
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -0
- package/dist/src/dht/store/{RemoteStore.d.ts → StoreRpcRemote.d.ts} +2 -2
- package/dist/src/dht/store/{RemoteStore.js → StoreRpcRemote.js} +4 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -0
- package/dist/src/exports.d.ts +2 -8
- package/dist/src/exports.js +2 -14
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/PeerID.d.ts +0 -1
- package/dist/src/helpers/PeerID.js +0 -6
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js +6 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js.map +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js +7 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +1 -0
- package/dist/src/helpers/kademliaId.d.ts +1 -0
- package/dist/src/helpers/kademliaId.js +14 -0
- package/dist/src/helpers/kademliaId.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +3 -3
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +2 -2
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +29 -29
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +39 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +49 -162
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +47 -88
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +15 -15
- package/dist/src/transport/RoutingRpcCommunicator.js +1 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +10 -9
- package/protos/DhtRpc.proto +30 -60
- package/src/connection/ConnectionLockHandler.ts +1 -1
- package/src/connection/ConnectionLockRpcRemote.ts +62 -0
- package/src/connection/ConnectionManager.ts +178 -274
- package/src/connection/ConnectivityChecker.ts +15 -12
- package/src/connection/ConnectorFacade.ts +140 -0
- package/src/connection/Handshaker.ts +0 -5
- package/src/connection/ManagedConnection.ts +26 -40
- package/src/connection/ManagedWebRtcConnection.ts +0 -2
- package/src/connection/Simulator/Simulator.ts +0 -7
- package/src/connection/Simulator/SimulatorConnection.ts +16 -13
- package/src/connection/Simulator/SimulatorConnector.ts +13 -19
- package/src/connection/Simulator/SimulatorTransport.ts +6 -1
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +15 -14
- package/src/connection/WebRTC/{WebRtcConnector.ts → WebRtcConnectorRpcLocal.ts} +68 -56
- package/src/connection/WebRTC/WebRtcConnectorRpcRemote.ts +71 -0
- package/src/connection/WebRTC/iceServerAsString.ts +1 -1
- package/src/connection/WebSocket/{WebSocketConnector.ts → WebSocketConnectorRpcLocal.ts} +102 -79
- package/src/connection/WebSocket/WebSocketConnectorRpcRemote.ts +45 -0
- package/src/connection/WebSocket/WebSocketServer.ts +26 -8
- package/src/dht/DhtNode.ts +176 -203
- package/src/dht/{RemoteExternalApi.ts → ExternalApiRpcRemote.ts} +3 -4
- package/src/dht/{DhtPeer.ts → RemoteDhtNode.ts} +11 -9
- package/src/dht/contact/ContactList.ts +0 -4
- package/src/dht/contact/RandomContactList.ts +0 -4
- package/src/dht/contact/SortedContactList.ts +0 -12
- package/src/dht/discovery/DiscoverySession.ts +20 -23
- package/src/dht/discovery/PeerDiscovery.ts +47 -45
- package/src/dht/find/RecursiveFindSession.ts +21 -22
- package/src/dht/find/RecursiveFinder.ts +45 -49
- package/src/dht/find/RemoteRecursiveFindSession.ts +6 -6
- package/src/dht/registerExternalApiRpcMethods.ts +8 -5
- package/src/dht/routing/DuplicateDetector.ts +3 -10
- package/src/dht/routing/Router.ts +39 -45
- package/src/dht/routing/{RemoteRouter.ts → RouterRpcRemote.ts} +4 -4
- package/src/dht/routing/RoutingSession.ts +15 -15
- package/src/dht/store/{DataStore.ts → StoreRpcLocal.ts} +42 -42
- package/src/dht/store/{RemoteStore.ts → StoreRpcRemote.ts} +2 -2
- package/src/exports.ts +2 -8
- package/src/helpers/PeerID.ts +0 -7
- package/src/helpers/browser/isBrowserEnvironment.ts +1 -0
- package/src/helpers/browser/isBrowserEnvironment_override.ts +3 -0
- package/src/helpers/kademliaId.ts +8 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +1 -1
- package/src/helpers/protoClasses.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +54 -54
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +15 -15
- package/src/proto/packages/dht/protos/DhtRpc.ts +77 -216
- package/src/transport/RoutingRpcCommunicator.ts +1 -0
- package/test/benchmark/KademliaCorrectness.test.ts +4 -2
- package/test/benchmark/RecursiveFind.test.ts +6 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +9 -9
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +5 -5
- package/test/end-to-end/Layer0WebRTC.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +13 -8
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +15 -10
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +5 -5
- package/test/integration/ConnectionLocking.test.ts +32 -26
- package/test/integration/ConnectionManager.test.ts +90 -93
- package/test/integration/DhtJoinPeerDiscovery.test.ts +53 -0
- package/test/integration/DhtRpc.test.ts +4 -6
- package/test/integration/Layer1-scale.test.ts +8 -8
- package/test/integration/MigrateData.test.ts +9 -9
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -2
- package/test/integration/RecursiveFind.test.ts +5 -5
- package/test/integration/{DhtPeer.test.ts → RemoteDhtNode.test.ts} +11 -12
- package/test/integration/RouteMessage.test.ts +7 -9
- package/test/integration/{RemoteRouter.test.ts → RouterRpcRemote.test.ts} +13 -14
- package/test/integration/RpcErrors.test.ts +25 -10
- package/test/integration/ScaleDownDht.test.ts +8 -8
- package/test/integration/SimultaneousConnections.test.ts +35 -36
- package/test/integration/Store.test.ts +8 -9
- package/test/integration/StoreAndDelete.test.ts +11 -11
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/{RemoteStore.test.ts → StoreRpcRemote.test.ts} +17 -18
- package/test/integration/WebRtcConnectionManagement.test.ts +26 -19
- package/test/integration/WebRtcConnectorRpc.test.ts +17 -32
- package/test/integration/WebSocket.test.ts +4 -2
- package/test/integration/WebSocketConnectionManagement.test.ts +30 -17
- package/test/integration/WebSocketConnectorRpc.test.ts +10 -15
- package/test/unit/DuplicateDetector.test.ts +3 -4
- package/test/unit/LocalDataStore.test.ts +6 -8
- package/test/unit/RandomContactList.test.ts +1 -1
- package/test/unit/RecursiveFinder.test.ts +13 -18
- package/test/unit/Router.test.ts +18 -21
- package/test/unit/WebSocketConnectorRpcLocal.test.ts +64 -0
- package/test/unit/WebSocketServer.test.ts +24 -12
- package/test/unit/{webrtcReplaceInternalIpWithExternalIp.ts → webrtcReplaceInternalIpWithExternalIp.test.ts} +1 -1
- package/test/utils/mock/RecursiveFinder.ts +2 -2
- package/test/utils/mock/Router.ts +9 -11
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +55 -74
- package/dist/src/connection/RemoteConnectionLocker.d.ts +0 -13
- package/dist/src/connection/RemoteConnectionLocker.js.map +0 -1
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +0 -12
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +0 -74
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +0 -9
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +0 -1
- package/dist/src/dht/DhtPeer.js.map +0 -1
- package/dist/src/dht/RemoteExternalApi.js.map +0 -1
- package/dist/src/dht/routing/RemoteRouter.js.map +0 -1
- package/dist/src/dht/store/DataStore.js.map +0 -1
- package/dist/src/dht/store/RemoteStore.js.map +0 -1
- package/dist/src/helpers/browser/isBrowser.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowser.js +0 -6
- package/dist/src/helpers/browser/isBrowser.js.map +0 -1
- package/dist/src/helpers/browser/isNodeJS.d.ts +0 -1
- package/dist/src/helpers/browser/isNodeJS.js +0 -6
- package/dist/src/helpers/browser/isNodeJS.js.map +0 -1
- package/src/connection/RemoteConnectionLocker.ts +0 -84
- package/src/connection/WebRTC/RemoteWebrtcConnector.ts +0 -93
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +0 -49
- package/src/helpers/browser/isBrowser.ts +0 -1
- package/src/helpers/browser/isNodeJS.ts +0 -1
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +0 -46
- package/test/integration/DhtWithMockConnections.test.ts +0 -46
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +0 -47
package/src/dht/DhtNode.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RemoteDhtNode } from './RemoteDhtNode'
|
|
2
2
|
import KBucket from 'k-bucket'
|
|
3
3
|
import { EventEmitter } from 'eventemitter3'
|
|
4
4
|
import { SortedContactList } from './contact/SortedContactList'
|
|
@@ -15,35 +15,37 @@ import {
|
|
|
15
15
|
PeerDescriptor,
|
|
16
16
|
PingRequest,
|
|
17
17
|
PingResponse,
|
|
18
|
-
FindMode,
|
|
19
18
|
DataEntry,
|
|
20
19
|
} from '../proto/packages/dht/protos/DhtRpc'
|
|
21
20
|
import { DisconnectionType, ITransport, TransportEvents } from '../transport/ITransport'
|
|
22
|
-
import { ConnectionManager,
|
|
23
|
-
import { DhtRpcServiceClient,
|
|
21
|
+
import { ConnectionManager, PortRange, TlsCertificate } from '../connection/ConnectionManager'
|
|
22
|
+
import { DhtRpcServiceClient, ExternalApiRpcClient } from '../proto/packages/dht/protos/DhtRpc.client'
|
|
24
23
|
import {
|
|
25
24
|
Logger,
|
|
26
25
|
MetricsContext,
|
|
27
26
|
hexToBinary,
|
|
28
|
-
|
|
27
|
+
merge,
|
|
28
|
+
waitForCondition
|
|
29
29
|
} from '@streamr/utils'
|
|
30
30
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
31
31
|
import { RandomContactList } from './contact/RandomContactList'
|
|
32
32
|
import { Empty } from '../proto/google/protobuf/empty'
|
|
33
33
|
import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
|
|
34
34
|
import { Any } from '../proto/google/protobuf/any'
|
|
35
|
-
import {
|
|
35
|
+
import { areEqualPeerDescriptors, keyFromPeerDescriptor, peerIdFromPeerDescriptor } from '../helpers/peerIdFromPeerDescriptor'
|
|
36
36
|
import { Router } from './routing/Router'
|
|
37
37
|
import { RecursiveFinder, RecursiveFindResult } from './find/RecursiveFinder'
|
|
38
|
-
import {
|
|
38
|
+
import { StoreRpcLocal } from './store/StoreRpcLocal'
|
|
39
39
|
import { PeerDiscovery } from './discovery/PeerDiscovery'
|
|
40
40
|
import { LocalDataStore } from './store/LocalDataStore'
|
|
41
|
-
import { IceServer } from '../connection/WebRTC/
|
|
41
|
+
import { IceServer } from '../connection/WebRTC/WebRtcConnectorRpcLocal'
|
|
42
42
|
import { registerExternalApiRpcMethods } from './registerExternalApiRpcMethods'
|
|
43
|
-
import {
|
|
44
|
-
import { UUID } from '../
|
|
45
|
-
import {
|
|
43
|
+
import { ExternalApiRpcRemote } from './ExternalApiRpcRemote'
|
|
44
|
+
import { UUID } from '../helpers/UUID'
|
|
45
|
+
import { isBrowserEnvironment } from '../helpers/browser/isBrowserEnvironment'
|
|
46
46
|
import { sample } from 'lodash'
|
|
47
|
+
import { DefaultConnectorFacade, DefaultConnectorFacadeConfig } from '../connection/ConnectorFacade'
|
|
48
|
+
import { MarkRequired } from 'ts-essentials'
|
|
47
49
|
|
|
48
50
|
export interface DhtNodeEvents {
|
|
49
51
|
newContact: (peerDescriptor: PeerDescriptor, closestPeers: PeerDescriptor[]) => void
|
|
@@ -63,19 +65,21 @@ export interface DhtNodeOptions {
|
|
|
63
65
|
maxNeighborListSize?: number
|
|
64
66
|
numberOfNodesPerKBucket?: number
|
|
65
67
|
joinNoProgressLimit?: number
|
|
68
|
+
peerDiscoveryQueryBatchSize?: number
|
|
66
69
|
dhtJoinTimeout?: number
|
|
67
70
|
metricsContext?: MetricsContext
|
|
68
71
|
storeHighestTtl?: number
|
|
69
72
|
storeMaxTtl?: number
|
|
73
|
+
networkConnectivityTimeout?: number
|
|
74
|
+
storageRedundancyFactor?: number
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
transport?: ITransport
|
|
72
77
|
peerDescriptor?: PeerDescriptor
|
|
73
78
|
entryPoints?: PeerDescriptor[]
|
|
74
79
|
websocketHost?: string
|
|
75
80
|
websocketPortRange?: PortRange
|
|
76
81
|
peerId?: string
|
|
77
82
|
|
|
78
|
-
nodeName?: string
|
|
79
83
|
rpcRequestTimeout?: number
|
|
80
84
|
iceServers?: IceServer[]
|
|
81
85
|
webrtcAllowPrivateAddresses?: boolean
|
|
@@ -83,67 +87,41 @@ export interface DhtNodeOptions {
|
|
|
83
87
|
webrtcDatachannelBufferThresholdHigh?: number
|
|
84
88
|
webrtcNewConnectionTimeout?: number
|
|
85
89
|
webrtcPortRange?: PortRange
|
|
90
|
+
maxMessageSize?: number
|
|
86
91
|
maxConnections?: number
|
|
87
92
|
tlsCertificate?: TlsCertificate
|
|
88
93
|
externalIp?: string
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
serviceId
|
|
93
|
-
joinParallelism
|
|
94
|
-
maxNeighborListSize
|
|
95
|
-
numberOfNodesPerKBucket
|
|
96
|
-
joinNoProgressLimit
|
|
97
|
-
dhtJoinTimeout
|
|
98
|
-
|
|
99
|
-
maxConnections
|
|
100
|
-
storeHighestTtl
|
|
101
|
-
storeMaxTtl
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
transportLayer?: ITransport
|
|
107
|
-
peerDescriptor?: PeerDescriptor
|
|
108
|
-
entryPoints?: PeerDescriptor[]
|
|
109
|
-
websocketHost?: string
|
|
110
|
-
websocketPortRange?: PortRange
|
|
111
|
-
nodeName?: string
|
|
112
|
-
rpcRequestTimeout?: number
|
|
113
|
-
iceServers?: IceServer[]
|
|
114
|
-
webrtcAllowPrivateAddresses?: boolean
|
|
115
|
-
webrtcDatachannelBufferThresholdLow?: number
|
|
116
|
-
webrtcDatachannelBufferThresholdHigh?: number
|
|
117
|
-
webrtcNewConnectionTimeout?: number
|
|
118
|
-
externalIp?: string
|
|
119
|
-
webrtcPortRange?: PortRange
|
|
120
|
-
tlsCertificate?: TlsCertificate
|
|
121
|
-
|
|
122
|
-
constructor(conf: Partial<DhtNodeOptions>) {
|
|
123
|
-
// assign given non-undefined config vars over defaults
|
|
124
|
-
let k: keyof typeof conf
|
|
125
|
-
for (k in conf) {
|
|
126
|
-
if (conf[k] === undefined) {
|
|
127
|
-
delete conf[k]
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
Object.assign(this, conf)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
96
|
+
type StrictDhtNodeOptions = MarkRequired<DhtNodeOptions,
|
|
97
|
+
'serviceId' |
|
|
98
|
+
'joinParallelism' |
|
|
99
|
+
'maxNeighborListSize' |
|
|
100
|
+
'numberOfNodesPerKBucket' |
|
|
101
|
+
'joinNoProgressLimit' |
|
|
102
|
+
'dhtJoinTimeout' |
|
|
103
|
+
'peerDiscoveryQueryBatchSize' |
|
|
104
|
+
'maxConnections' |
|
|
105
|
+
'storeHighestTtl' |
|
|
106
|
+
'storeMaxTtl' |
|
|
107
|
+
'networkConnectivityTimeout' |
|
|
108
|
+
'storageRedundancyFactor' |
|
|
109
|
+
'metricsContext' |
|
|
110
|
+
'peerId'>
|
|
133
111
|
|
|
134
112
|
const logger = new Logger(module)
|
|
135
113
|
|
|
136
114
|
export type Events = TransportEvents & DhtNodeEvents
|
|
137
115
|
|
|
138
|
-
export const createPeerDescriptor = (msg?: ConnectivityResponse, peerId?: string
|
|
116
|
+
export const createPeerDescriptor = (msg?: ConnectivityResponse, peerId?: string): PeerDescriptor => {
|
|
139
117
|
let kademliaId: Uint8Array
|
|
140
118
|
if (msg) {
|
|
141
119
|
kademliaId = peerId ? hexToBinary(peerId) : PeerID.fromIp(msg.host).value
|
|
142
120
|
} else {
|
|
143
121
|
kademliaId = hexToBinary(peerId!)
|
|
144
122
|
}
|
|
145
|
-
const nodeType =
|
|
146
|
-
const ret: PeerDescriptor = { kademliaId,
|
|
123
|
+
const nodeType = isBrowserEnvironment() ? NodeType.BROWSER : NodeType.NODEJS
|
|
124
|
+
const ret: PeerDescriptor = { kademliaId, type: nodeType }
|
|
147
125
|
if (msg && msg.websocket) {
|
|
148
126
|
ret.websocket = { host: msg.websocket.host, port: msg.websocket.port, tls: msg.websocket.tls }
|
|
149
127
|
ret.openInternet = true
|
|
@@ -152,19 +130,18 @@ export const createPeerDescriptor = (msg?: ConnectivityResponse, peerId?: string
|
|
|
152
130
|
}
|
|
153
131
|
|
|
154
132
|
export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
155
|
-
private readonly config: DhtNodeConfig
|
|
156
133
|
|
|
157
|
-
private
|
|
158
|
-
private
|
|
159
|
-
private
|
|
160
|
-
private
|
|
161
|
-
private
|
|
134
|
+
private readonly config: StrictDhtNodeOptions
|
|
135
|
+
private bucket?: KBucket<RemoteDhtNode>
|
|
136
|
+
private connections: Map<PeerIDKey, RemoteDhtNode> = new Map()
|
|
137
|
+
private neighborList?: SortedContactList<RemoteDhtNode>
|
|
138
|
+
private openInternetPeers?: SortedContactList<RemoteDhtNode>
|
|
139
|
+
private randomPeers?: RandomContactList<RemoteDhtNode>
|
|
162
140
|
private rpcCommunicator?: RoutingRpcCommunicator
|
|
163
|
-
private
|
|
141
|
+
private transport?: ITransport
|
|
164
142
|
private ownPeerDescriptor?: PeerDescriptor
|
|
165
|
-
private ownPeerId?: PeerID
|
|
166
143
|
public router?: Router
|
|
167
|
-
|
|
144
|
+
private storeRpcLocal?: StoreRpcLocal
|
|
168
145
|
private localDataStore = new LocalDataStore()
|
|
169
146
|
private recursiveFinder?: RecursiveFinder
|
|
170
147
|
private peerDiscovery?: PeerDiscovery
|
|
@@ -174,12 +151,24 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
174
151
|
private stopped = false
|
|
175
152
|
private entryPointDisconnectTimeout?: NodeJS.Timeout
|
|
176
153
|
|
|
177
|
-
|
|
178
|
-
public contactOnAddedCounter = 0
|
|
179
|
-
|
|
180
|
-
constructor(conf: Partial<DhtNodeConfig>) {
|
|
154
|
+
constructor(conf: DhtNodeOptions) {
|
|
181
155
|
super()
|
|
182
|
-
this.config =
|
|
156
|
+
this.config = merge({
|
|
157
|
+
serviceId: 'layer0',
|
|
158
|
+
joinParallelism: 3,
|
|
159
|
+
maxNeighborListSize: 200,
|
|
160
|
+
numberOfNodesPerKBucket: 8,
|
|
161
|
+
joinNoProgressLimit: 4,
|
|
162
|
+
dhtJoinTimeout: 60000,
|
|
163
|
+
peerDiscoveryQueryBatchSize: 5,
|
|
164
|
+
maxConnections: 80,
|
|
165
|
+
storeHighestTtl: 60000,
|
|
166
|
+
storeMaxTtl: 60000,
|
|
167
|
+
networkConnectivityTimeout: 10000,
|
|
168
|
+
storageRedundancyFactor: 5,
|
|
169
|
+
metricsContext: new MetricsContext(),
|
|
170
|
+
peerId: new UUID().toHex()
|
|
171
|
+
}, conf)
|
|
183
172
|
this.send = this.send.bind(this)
|
|
184
173
|
}
|
|
185
174
|
|
|
@@ -190,75 +179,77 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
190
179
|
logger.trace(`Starting new Streamr Network DHT Node with serviceId ${this.config.serviceId}`)
|
|
191
180
|
this.started = true
|
|
192
181
|
|
|
193
|
-
if (
|
|
182
|
+
if (isBrowserEnvironment()) {
|
|
194
183
|
this.config.websocketPortRange = undefined
|
|
195
184
|
if (this.config.peerDescriptor) {
|
|
196
185
|
this.config.peerDescriptor.websocket = undefined
|
|
197
186
|
}
|
|
198
187
|
}
|
|
199
|
-
// If
|
|
200
|
-
if (this.config.
|
|
201
|
-
this.
|
|
202
|
-
this.ownPeerDescriptor = this.
|
|
203
|
-
if (this.config.
|
|
204
|
-
this.connectionManager = this.config.
|
|
188
|
+
// If transport is given, do not create a ConnectionManager
|
|
189
|
+
if (this.config.transport) {
|
|
190
|
+
this.transport = this.config.transport
|
|
191
|
+
this.ownPeerDescriptor = this.transport.getPeerDescriptor()
|
|
192
|
+
if (this.config.transport instanceof ConnectionManager) {
|
|
193
|
+
this.connectionManager = this.config.transport
|
|
205
194
|
}
|
|
206
195
|
} else {
|
|
207
|
-
const
|
|
208
|
-
|
|
196
|
+
const connectorFacadeConfig: DefaultConnectorFacadeConfig = {
|
|
197
|
+
transport: this,
|
|
209
198
|
entryPoints: this.config.entryPoints,
|
|
210
199
|
iceServers: this.config.iceServers,
|
|
211
|
-
metricsContext: this.config.metricsContext,
|
|
212
200
|
webrtcAllowPrivateAddresses: this.config.webrtcAllowPrivateAddresses,
|
|
213
201
|
webrtcDatachannelBufferThresholdLow: this.config.webrtcDatachannelBufferThresholdLow,
|
|
214
202
|
webrtcDatachannelBufferThresholdHigh: this.config.webrtcDatachannelBufferThresholdHigh,
|
|
215
203
|
webrtcNewConnectionTimeout: this.config.webrtcNewConnectionTimeout,
|
|
216
204
|
webrtcPortRange: this.config.webrtcPortRange,
|
|
217
|
-
|
|
205
|
+
maxMessageSize: this.config.maxMessageSize,
|
|
218
206
|
tlsCertificate: this.config.tlsCertificate,
|
|
219
|
-
externalIp: this.config.externalIp
|
|
207
|
+
externalIp: this.config.externalIp,
|
|
208
|
+
createOwnPeerDescriptor: (connectivityResponse: ConnectivityResponse) => this.generatePeerDescriptorCallBack(connectivityResponse),
|
|
220
209
|
}
|
|
221
210
|
// If own PeerDescriptor is given in config, create a ConnectionManager with ws server
|
|
222
211
|
if (this.config.peerDescriptor?.websocket) {
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
connectorFacadeConfig.websocketHost = this.config.peerDescriptor.websocket.host
|
|
213
|
+
connectorFacadeConfig.websocketPortRange = {
|
|
225
214
|
min: this.config.peerDescriptor.websocket.port,
|
|
226
215
|
max: this.config.peerDescriptor.websocket.port
|
|
227
216
|
}
|
|
228
217
|
// If websocketPortRange is given, create ws server using it, websocketHost can be undefined
|
|
229
218
|
} else if (this.config.websocketPortRange) {
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
connectorFacadeConfig.websocketHost = this.config.websocketHost
|
|
220
|
+
connectorFacadeConfig.websocketPortRange = this.config.websocketPortRange
|
|
232
221
|
}
|
|
233
222
|
|
|
234
|
-
const connectionManager = new ConnectionManager(
|
|
235
|
-
|
|
223
|
+
const connectionManager = new ConnectionManager({
|
|
224
|
+
createConnectorFacade: () => new DefaultConnectorFacade(connectorFacadeConfig),
|
|
225
|
+
maxConnections: this.config.maxConnections,
|
|
226
|
+
metricsContext: this.config.metricsContext
|
|
227
|
+
})
|
|
228
|
+
await connectionManager.start()
|
|
236
229
|
this.connectionManager = connectionManager
|
|
237
|
-
this.
|
|
230
|
+
this.transport = connectionManager
|
|
238
231
|
}
|
|
239
232
|
|
|
240
233
|
this.rpcCommunicator = new RoutingRpcCommunicator(
|
|
241
234
|
this.config.serviceId,
|
|
242
|
-
this.
|
|
235
|
+
this.transport.send,
|
|
243
236
|
{ rpcRequestTimeout: this.config.rpcRequestTimeout }
|
|
244
237
|
)
|
|
245
238
|
|
|
246
|
-
this.
|
|
239
|
+
this.transport.on('message', (message: Message) => this.handleMessage(message))
|
|
247
240
|
|
|
248
241
|
this.bindDefaultServerMethods()
|
|
249
|
-
this.
|
|
250
|
-
this.initKBuckets(this.ownPeerId)
|
|
242
|
+
this.initKBuckets(peerIdFromPeerDescriptor(this.ownPeerDescriptor!))
|
|
251
243
|
this.peerDiscovery = new PeerDiscovery({
|
|
252
244
|
rpcCommunicator: this.rpcCommunicator,
|
|
253
245
|
ownPeerDescriptor: this.ownPeerDescriptor!,
|
|
254
|
-
ownPeerId: this.ownPeerId,
|
|
255
246
|
bucket: this.bucket!,
|
|
256
247
|
connections: this.connections,
|
|
257
248
|
neighborList: this.neighborList!,
|
|
258
249
|
randomPeers: this.randomPeers!,
|
|
259
250
|
openInternetPeers: this.openInternetPeers!,
|
|
260
251
|
joinNoProgressLimit: this.config.joinNoProgressLimit,
|
|
261
|
-
|
|
252
|
+
peerDiscoveryQueryBatchSize: this.config.peerDiscoveryQueryBatchSize,
|
|
262
253
|
joinTimeout: this.config.dhtJoinTimeout,
|
|
263
254
|
serviceId: this.config.serviceId,
|
|
264
255
|
parallelism: this.config.joinParallelism,
|
|
@@ -269,7 +260,6 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
269
260
|
rpcCommunicator: this.rpcCommunicator,
|
|
270
261
|
connections: this.connections,
|
|
271
262
|
ownPeerDescriptor: this.ownPeerDescriptor!,
|
|
272
|
-
ownPeerId: this.ownPeerId,
|
|
273
263
|
addContact: this.addNewContact.bind(this),
|
|
274
264
|
serviceId: this.config.serviceId,
|
|
275
265
|
connectionManager: this.connectionManager
|
|
@@ -281,19 +271,18 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
281
271
|
connections: this.connections,
|
|
282
272
|
ownPeerDescriptor: this.ownPeerDescriptor!,
|
|
283
273
|
serviceId: this.config.serviceId,
|
|
284
|
-
ownPeerId: this.ownPeerId,
|
|
285
274
|
addContact: this.addNewContact.bind(this),
|
|
286
275
|
isPeerCloserToIdThanSelf: this.isPeerCloserToIdThanSelf.bind(this),
|
|
287
276
|
localDataStore: this.localDataStore
|
|
288
277
|
})
|
|
289
|
-
this.
|
|
278
|
+
this.storeRpcLocal = new StoreRpcLocal({
|
|
290
279
|
rpcCommunicator: this.rpcCommunicator,
|
|
291
280
|
recursiveFinder: this.recursiveFinder,
|
|
292
281
|
ownPeerDescriptor: this.ownPeerDescriptor!,
|
|
293
282
|
serviceId: this.config.serviceId,
|
|
294
283
|
highestTtl: this.config.storeHighestTtl,
|
|
295
284
|
maxTtl: this.config.storeMaxTtl,
|
|
296
|
-
|
|
285
|
+
redundancyFactor: this.config.storageRedundancyFactor,
|
|
297
286
|
localDataStore: this.localDataStore,
|
|
298
287
|
dhtNodeEmitter: this,
|
|
299
288
|
getNodesClosestToIdFromBucket: (id: Uint8Array, n?: number) => {
|
|
@@ -302,31 +291,31 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
302
291
|
})
|
|
303
292
|
registerExternalApiRpcMethods(this)
|
|
304
293
|
if (this.connectionManager! && this.config.entryPoints && this.config.entryPoints.length > 0
|
|
305
|
-
&& !
|
|
294
|
+
&& !areEqualPeerDescriptors(this.config.entryPoints[0], this.ownPeerDescriptor!)) {
|
|
306
295
|
this.connectToEntryPoint(this.config.entryPoints[0])
|
|
307
296
|
}
|
|
308
297
|
}
|
|
309
298
|
|
|
310
299
|
private initKBuckets = (selfId: PeerID) => {
|
|
311
|
-
this.bucket = new KBucket<
|
|
300
|
+
this.bucket = new KBucket<RemoteDhtNode>({
|
|
312
301
|
localNodeId: selfId.value,
|
|
313
302
|
numberOfNodesPerKBucket: this.config.numberOfNodesPerKBucket,
|
|
314
303
|
numberOfNodesToPing: this.config.numberOfNodesPerKBucket
|
|
315
304
|
})
|
|
316
|
-
this.bucket.on('ping', (oldContacts:
|
|
317
|
-
this.bucket.on('removed', (contact:
|
|
318
|
-
this.bucket.on('added', (contact:
|
|
319
|
-
this.bucket.on('updated', (
|
|
305
|
+
this.bucket.on('ping', (oldContacts: RemoteDhtNode[], newContact: RemoteDhtNode) => this.onKBucketPing(oldContacts, newContact))
|
|
306
|
+
this.bucket.on('removed', (contact: RemoteDhtNode) => this.onKBucketRemoved(contact))
|
|
307
|
+
this.bucket.on('added', (contact: RemoteDhtNode) => this.onKBucketAdded(contact))
|
|
308
|
+
this.bucket.on('updated', () => {
|
|
320
309
|
// TODO: Update contact info to the connection manager and reconnect
|
|
321
310
|
})
|
|
322
311
|
this.neighborList = new SortedContactList(selfId, this.config.maxNeighborListSize)
|
|
323
|
-
this.neighborList.on('contactRemoved', (removedContact:
|
|
312
|
+
this.neighborList.on('contactRemoved', (removedContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) => {
|
|
324
313
|
if (this.stopped) {
|
|
325
314
|
return
|
|
326
315
|
}
|
|
327
316
|
this.emit('contactRemoved', removedContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
328
317
|
this.randomPeers!.addContact(
|
|
329
|
-
new
|
|
318
|
+
new RemoteDhtNode(
|
|
330
319
|
this.ownPeerDescriptor!,
|
|
331
320
|
removedContact.getPeerDescriptor(),
|
|
332
321
|
toProtoRpcClient(new DhtRpcServiceClient(this.rpcCommunicator!.getRpcClientTransport())),
|
|
@@ -334,80 +323,77 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
334
323
|
)
|
|
335
324
|
)
|
|
336
325
|
})
|
|
337
|
-
this.neighborList.on('newContact', (newContact:
|
|
326
|
+
this.neighborList.on('newContact', (newContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) =>
|
|
338
327
|
this.emit('newContact', newContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
339
328
|
)
|
|
340
329
|
this.openInternetPeers = new SortedContactList(selfId, this.config.maxNeighborListSize / 2)
|
|
341
|
-
this.openInternetPeers.on('contactRemoved', (removedContact:
|
|
330
|
+
this.openInternetPeers.on('contactRemoved', (removedContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) =>
|
|
342
331
|
this.emit('openInternetContactRemoved', removedContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
343
332
|
)
|
|
344
|
-
this.openInternetPeers.on('newContact', (newContact:
|
|
333
|
+
this.openInternetPeers.on('newContact', (newContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) =>
|
|
345
334
|
this.emit('newOpenInternetContact', newContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
346
335
|
)
|
|
347
|
-
this.
|
|
336
|
+
this.transport!.on('connected', (peerDescriptor: PeerDescriptor) => this.onTransportConnected(peerDescriptor))
|
|
348
337
|
|
|
349
|
-
this.
|
|
338
|
+
this.transport!.on('disconnected', (peerDescriptor: PeerDescriptor, disonnectionType: DisconnectionType) => {
|
|
350
339
|
this.onTransportDisconnected(peerDescriptor, disonnectionType)
|
|
351
340
|
})
|
|
352
341
|
|
|
353
|
-
this.
|
|
354
|
-
const
|
|
355
|
-
const dhtPeer = new DhtPeer(
|
|
342
|
+
this.transport!.getAllConnectionPeerDescriptors().forEach((peer) => {
|
|
343
|
+
const remoteDhtNode = new RemoteDhtNode(
|
|
356
344
|
this.ownPeerDescriptor!,
|
|
357
345
|
peer,
|
|
358
346
|
toProtoRpcClient(new DhtRpcServiceClient(this.rpcCommunicator!.getRpcClientTransport())),
|
|
359
347
|
this.config.serviceId
|
|
360
348
|
)
|
|
361
|
-
if (
|
|
349
|
+
if (areEqualPeerDescriptors(peer, this.ownPeerDescriptor!)) {
|
|
362
350
|
logger.error('own peerdescriptor added to connections in initKBucket')
|
|
363
351
|
}
|
|
364
|
-
this.connections.set(
|
|
352
|
+
this.connections.set(keyFromPeerDescriptor(peer), remoteDhtNode)
|
|
365
353
|
})
|
|
366
354
|
this.randomPeers = new RandomContactList(selfId, this.config.maxNeighborListSize)
|
|
367
|
-
this.randomPeers.on('contactRemoved', (removedContact:
|
|
355
|
+
this.randomPeers.on('contactRemoved', (removedContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) =>
|
|
368
356
|
this.emit('randomContactRemoved', removedContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
369
357
|
)
|
|
370
|
-
this.randomPeers.on('newContact', (newContact:
|
|
358
|
+
this.randomPeers.on('newContact', (newContact: RemoteDhtNode, activeContacts: RemoteDhtNode[]) =>
|
|
371
359
|
this.emit('newRandomContact', newContact.getPeerDescriptor(), activeContacts.map((c) => c.getPeerDescriptor()))
|
|
372
360
|
)
|
|
373
361
|
}
|
|
374
362
|
|
|
375
363
|
private onTransportConnected(peerDescriptor: PeerDescriptor): void {
|
|
376
364
|
|
|
377
|
-
if (this.
|
|
365
|
+
if (areEqualPeerDescriptors(this.ownPeerDescriptor!, peerDescriptor)) {
|
|
378
366
|
logger.error('onTransportConnected() to self')
|
|
379
367
|
}
|
|
380
368
|
|
|
381
|
-
const
|
|
369
|
+
const remoteDhtNode = new RemoteDhtNode(
|
|
382
370
|
this.ownPeerDescriptor!,
|
|
383
371
|
peerDescriptor,
|
|
384
372
|
toProtoRpcClient(new DhtRpcServiceClient(this.rpcCommunicator!.getRpcClientTransport())),
|
|
385
373
|
this.config.serviceId
|
|
386
374
|
)
|
|
387
|
-
if (!this.connections.has(PeerID.fromValue(
|
|
388
|
-
this.connections.set(PeerID.fromValue(
|
|
389
|
-
logger.trace('
|
|
375
|
+
if (!this.connections.has(PeerID.fromValue(remoteDhtNode.id).toKey())) {
|
|
376
|
+
this.connections.set(PeerID.fromValue(remoteDhtNode.id).toKey(), remoteDhtNode)
|
|
377
|
+
logger.trace('connectionschange add ' + this.connections.size)
|
|
390
378
|
} else {
|
|
391
379
|
logger.trace('new connection not set to connections, there is already a connection with the peer ID')
|
|
392
380
|
}
|
|
393
|
-
|
|
394
|
-
logger.trace('connected: ' + this.ownPeerDescriptor!.nodeName + ', ' + peerDescriptor.nodeName + ' ' + this.connections.size)
|
|
395
|
-
}
|
|
381
|
+
logger.trace('connected: ' + keyFromPeerDescriptor(peerDescriptor) + ' ' + this.connections.size)
|
|
396
382
|
this.emit('connected', peerDescriptor)
|
|
397
383
|
}
|
|
398
384
|
|
|
399
385
|
private onTransportDisconnected(peerDescriptor: PeerDescriptor, dicsonnectionType: DisconnectionType): void {
|
|
400
|
-
logger.trace('disconnected: ' +
|
|
386
|
+
logger.trace('disconnected: ' + keyFromPeerDescriptor(peerDescriptor))
|
|
401
387
|
this.connections.delete(keyFromPeerDescriptor(peerDescriptor))
|
|
402
388
|
// only remove from bucket if we are on layer 0
|
|
403
389
|
if (this.connectionManager) {
|
|
404
390
|
this.bucket!.remove(peerDescriptor.kademliaId)
|
|
405
391
|
|
|
406
392
|
if (dicsonnectionType === 'OUTGOING_GRACEFUL_LEAVE' || dicsonnectionType === 'INCOMING_GRACEFUL_LEAVE') {
|
|
407
|
-
logger.trace(
|
|
393
|
+
logger.trace(keyFromPeerDescriptor(peerDescriptor) + ' ' + 'onTransportDisconnected with type ' + dicsonnectionType)
|
|
408
394
|
this.removeContact(peerDescriptor, true)
|
|
409
395
|
} else {
|
|
410
|
-
logger.trace(
|
|
396
|
+
logger.trace(keyFromPeerDescriptor(peerDescriptor) + ' ' + 'onTransportDisconnected with type ' + dicsonnectionType)
|
|
411
397
|
}
|
|
412
398
|
}
|
|
413
399
|
|
|
@@ -433,14 +419,13 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
433
419
|
return distance1 < distance2
|
|
434
420
|
}
|
|
435
421
|
|
|
436
|
-
|
|
422
|
+
private handleMessage(message: Message): void {
|
|
437
423
|
if (message.serviceId === this.config.serviceId) {
|
|
438
|
-
logger.trace('callig this.handleMessageFromPeer ' +
|
|
439
|
-
|
|
424
|
+
logger.trace('callig this.handleMessageFromPeer ' + keyFromPeerDescriptor(message.sourceDescriptor!)
|
|
425
|
+
+ ' ' + message.serviceId + ' ' + message.messageId)
|
|
440
426
|
this.rpcCommunicator?.handleMessageFromPeer(message)
|
|
441
427
|
} else {
|
|
442
|
-
logger.trace('emit "message" ' +
|
|
443
|
-
' ' + message.serviceId + ' ' + message.messageId)
|
|
428
|
+
logger.trace('emit "message" ' + keyFromPeerDescriptor(message.sourceDescriptor!) + ' ' + message.serviceId + ' ' + message.messageId)
|
|
444
429
|
this.emit('message', message)
|
|
445
430
|
}
|
|
446
431
|
}
|
|
@@ -449,23 +434,21 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
449
434
|
if (this.config.peerDescriptor) {
|
|
450
435
|
this.ownPeerDescriptor = this.config.peerDescriptor
|
|
451
436
|
} else {
|
|
452
|
-
this.ownPeerDescriptor = createPeerDescriptor(connectivityResponse,
|
|
453
|
-
this.config.peerId,
|
|
454
|
-
this.config.nodeName)
|
|
437
|
+
this.ownPeerDescriptor = createPeerDescriptor(connectivityResponse, this.config.peerId)
|
|
455
438
|
}
|
|
456
439
|
return this.ownPeerDescriptor
|
|
457
440
|
}
|
|
458
441
|
|
|
459
442
|
private getClosestPeerDescriptors(kademliaId: Uint8Array, limit: number): PeerDescriptor[] {
|
|
460
443
|
const closestPeers = this.bucket!.closest(kademliaId, limit)
|
|
461
|
-
return closestPeers.map((
|
|
444
|
+
return closestPeers.map((remoteDhtNode: RemoteDhtNode) => remoteDhtNode.getPeerDescriptor())
|
|
462
445
|
}
|
|
463
446
|
|
|
464
|
-
private onKBucketPing(oldContacts:
|
|
447
|
+
private onKBucketPing(oldContacts: RemoteDhtNode[], newContact: RemoteDhtNode): void {
|
|
465
448
|
if (this.stopped) {
|
|
466
449
|
return
|
|
467
450
|
}
|
|
468
|
-
const sortingList: SortedContactList<
|
|
451
|
+
const sortingList: SortedContactList<RemoteDhtNode> = new SortedContactList(this.getNodeId(), 100)
|
|
469
452
|
sortingList.addContacts(oldContacts)
|
|
470
453
|
const sortedContacts = sortingList.getAllContacts()
|
|
471
454
|
this.connectionManager?.weakUnlockConnection(sortedContacts[sortedContacts.length - 1].getPeerDescriptor())
|
|
@@ -473,12 +456,12 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
473
456
|
this.bucket!.add(newContact)
|
|
474
457
|
}
|
|
475
458
|
|
|
476
|
-
private onKBucketRemoved(contact:
|
|
459
|
+
private onKBucketRemoved(contact: RemoteDhtNode): void {
|
|
477
460
|
if (this.stopped) {
|
|
478
461
|
return
|
|
479
462
|
}
|
|
480
463
|
this.connectionManager?.weakUnlockConnection(contact.getPeerDescriptor())
|
|
481
|
-
logger.trace(`Removed contact ${contact.
|
|
464
|
+
logger.trace(`Removed contact ${keyFromPeerDescriptor(contact.getPeerDescriptor())}`)
|
|
482
465
|
this.emit(
|
|
483
466
|
'kbucketContactRemoved',
|
|
484
467
|
contact.getPeerDescriptor()
|
|
@@ -496,33 +479,32 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
496
479
|
}
|
|
497
480
|
}
|
|
498
481
|
|
|
499
|
-
private onKBucketAdded(contact:
|
|
482
|
+
private onKBucketAdded(contact: RemoteDhtNode): void {
|
|
500
483
|
if (this.stopped) {
|
|
501
484
|
return
|
|
502
485
|
}
|
|
503
|
-
this.
|
|
504
|
-
if (!this.stopped && !contact.getPeerId().equals(this.ownPeerId!)) {
|
|
486
|
+
if (!this.stopped && !contact.getPeerId().equals(this.getNodeId())) {
|
|
505
487
|
// Important to lock here, before the ping result is known
|
|
506
488
|
this.connectionManager?.weakLockConnection(contact.getPeerDescriptor())
|
|
507
489
|
if (this.connections.has(contact.getPeerId().toKey())) {
|
|
508
|
-
logger.trace(`Added new contact ${contact.
|
|
490
|
+
logger.trace(`Added new contact ${keyFromPeerDescriptor(contact.getPeerDescriptor())}`)
|
|
509
491
|
this.emit(
|
|
510
492
|
'newKbucketContact',
|
|
511
493
|
contact.getPeerDescriptor(),
|
|
512
|
-
this.neighborList!.getClosestContacts(this.config.
|
|
494
|
+
this.neighborList!.getClosestContacts(this.config.peerDiscoveryQueryBatchSize).map((peer) => peer.getPeerDescriptor())
|
|
513
495
|
)
|
|
514
496
|
} else { // open connection by pinging
|
|
515
|
-
logger.trace('starting ping ' +
|
|
497
|
+
logger.trace('starting ping ' + keyFromPeerDescriptor(contact.getPeerDescriptor()))
|
|
516
498
|
contact.ping().then((result) => {
|
|
517
499
|
if (result) {
|
|
518
|
-
logger.trace(`Added new contact ${contact.
|
|
500
|
+
logger.trace(`Added new contact ${keyFromPeerDescriptor(contact.getPeerDescriptor())}`)
|
|
519
501
|
this.emit(
|
|
520
502
|
'newKbucketContact',
|
|
521
503
|
contact.getPeerDescriptor(),
|
|
522
|
-
this.neighborList!.getClosestContacts(this.config.
|
|
504
|
+
this.neighborList!.getClosestContacts(this.config.peerDiscoveryQueryBatchSize).map((peer) => peer.getPeerDescriptor())
|
|
523
505
|
)
|
|
524
506
|
} else {
|
|
525
|
-
logger.trace('ping failed ' +
|
|
507
|
+
logger.trace('ping failed ' + keyFromPeerDescriptor(contact.getPeerDescriptor()))
|
|
526
508
|
this.connectionManager?.weakUnlockConnection(contact.getPeerDescriptor())
|
|
527
509
|
this.removeContact(contact.getPeerDescriptor())
|
|
528
510
|
this.addClosestContactToBucket()
|
|
@@ -547,7 +529,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
547
529
|
}
|
|
548
530
|
}
|
|
549
531
|
|
|
550
|
-
private getClosestActiveContactNotInBucket():
|
|
532
|
+
private getClosestActiveContactNotInBucket(): RemoteDhtNode | undefined {
|
|
551
533
|
for (const contactId of this.neighborList!.getContactIds()) {
|
|
552
534
|
if (!this.bucket!.get(contactId.value) && this.neighborList!.isActive(contactId)) {
|
|
553
535
|
return this.neighborList!.getContact(contactId).contact
|
|
@@ -561,7 +543,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
561
543
|
}
|
|
562
544
|
|
|
563
545
|
public getNodeId(): PeerID {
|
|
564
|
-
return this.
|
|
546
|
+
return peerIdFromPeerDescriptor(this.ownPeerDescriptor!)
|
|
565
547
|
}
|
|
566
548
|
|
|
567
549
|
public getBucketSize(): number {
|
|
@@ -572,28 +554,27 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
572
554
|
if (!this.started || this.stopped) {
|
|
573
555
|
return
|
|
574
556
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
const dhtPeer = new DhtPeer(
|
|
557
|
+
if (!areEqualPeerDescriptors(contact, this.ownPeerDescriptor!)) {
|
|
558
|
+
logger.trace(`Adding new contact ${keyFromPeerDescriptor(contact)}`)
|
|
559
|
+
const remoteDhtNode = new RemoteDhtNode(
|
|
579
560
|
this.ownPeerDescriptor!,
|
|
580
561
|
contact,
|
|
581
562
|
toProtoRpcClient(new DhtRpcServiceClient(this.rpcCommunicator!.getRpcClientTransport())),
|
|
582
563
|
this.config.serviceId
|
|
583
564
|
)
|
|
584
565
|
if (!this.bucket!.get(contact.kademliaId) && !this.neighborList!.getContact(peerIdFromPeerDescriptor(contact))) {
|
|
585
|
-
this.neighborList!.addContact(
|
|
566
|
+
this.neighborList!.addContact(remoteDhtNode)
|
|
586
567
|
if (contact.openInternet) {
|
|
587
|
-
this.openInternetPeers!.addContact(
|
|
568
|
+
this.openInternetPeers!.addContact(remoteDhtNode)
|
|
588
569
|
}
|
|
589
570
|
if (setActive) {
|
|
571
|
+
const peerId = peerIdFromPeerDescriptor(contact)
|
|
590
572
|
this.neighborList!.setActive(peerId)
|
|
591
573
|
this.openInternetPeers!.setActive(peerId)
|
|
592
574
|
}
|
|
593
|
-
this.
|
|
594
|
-
this.bucket!.add(dhtPeer)
|
|
575
|
+
this.bucket!.add(remoteDhtNode)
|
|
595
576
|
} else {
|
|
596
|
-
this.randomPeers!.addContact(
|
|
577
|
+
this.randomPeers!.addContact(remoteDhtNode)
|
|
597
578
|
}
|
|
598
579
|
}
|
|
599
580
|
}
|
|
@@ -609,7 +590,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
609
590
|
if (!this.started || this.stopped) {
|
|
610
591
|
return
|
|
611
592
|
}
|
|
612
|
-
logger.trace(`Removing contact ${contact
|
|
593
|
+
logger.trace(`Removing contact ${keyFromPeerDescriptor(contact)}`)
|
|
613
594
|
const peerId = peerIdFromPeerDescriptor(contact)
|
|
614
595
|
this.bucket!.remove(peerId.value)
|
|
615
596
|
this.neighborList!.removeContact(peerId)
|
|
@@ -619,7 +600,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
619
600
|
}
|
|
620
601
|
}
|
|
621
602
|
|
|
622
|
-
public async send(msg: Message
|
|
603
|
+
public async send(msg: Message): Promise<void> {
|
|
623
604
|
if (!this.started || this.stopped) {
|
|
624
605
|
return
|
|
625
606
|
}
|
|
@@ -627,54 +608,58 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
627
608
|
await this.router!.send(msg, reachableThrough)
|
|
628
609
|
}
|
|
629
610
|
|
|
630
|
-
public async joinDht(entryPointDescriptors: PeerDescriptor[],
|
|
611
|
+
public async joinDht(entryPointDescriptors: PeerDescriptor[], doAdditionalRandomPeerDiscovery?: boolean, retry?: boolean): Promise<void> {
|
|
631
612
|
if (!this.started) {
|
|
632
613
|
throw new Error('Cannot join DHT before calling start() on DhtNode')
|
|
633
614
|
}
|
|
634
615
|
await Promise.all(entryPointDescriptors.map((entryPoint) =>
|
|
635
|
-
this.peerDiscovery!.joinDht(entryPoint,
|
|
616
|
+
this.peerDiscovery!.joinDht(entryPoint, doAdditionalRandomPeerDiscovery, retry)
|
|
636
617
|
))
|
|
637
618
|
}
|
|
638
619
|
|
|
639
|
-
public async startRecursiveFind(idToFind: Uint8Array,
|
|
640
|
-
return this.recursiveFinder!.startRecursiveFind(idToFind,
|
|
620
|
+
public async startRecursiveFind(idToFind: Uint8Array, fetchData?: boolean, excludedPeer?: PeerDescriptor): Promise<RecursiveFindResult> {
|
|
621
|
+
return this.recursiveFinder!.startRecursiveFind(idToFind, fetchData, excludedPeer)
|
|
641
622
|
}
|
|
642
623
|
|
|
643
624
|
public async storeDataToDht(key: Uint8Array, data: Any): Promise<PeerDescriptor[]> {
|
|
644
|
-
if (this.isJoinOngoing() && this.config.entryPoints && this.config.entryPoints.length > 0) {
|
|
625
|
+
if (this.peerDiscovery!.isJoinOngoing() && this.config.entryPoints && this.config.entryPoints.length > 0) {
|
|
645
626
|
return this.storeDataViaPeer(key, data, sample(this.config.entryPoints)!)
|
|
646
627
|
}
|
|
647
|
-
return this.
|
|
628
|
+
return this.storeRpcLocal!.storeDataToDht(key, data)
|
|
648
629
|
}
|
|
649
630
|
|
|
650
631
|
public async storeDataViaPeer(key: Uint8Array, data: Any, peer: PeerDescriptor): Promise<PeerDescriptor[]> {
|
|
651
|
-
const
|
|
632
|
+
const rpcRemote = new ExternalApiRpcRemote(
|
|
652
633
|
this.ownPeerDescriptor!,
|
|
653
634
|
peer,
|
|
654
635
|
this.config.serviceId,
|
|
655
|
-
toProtoRpcClient(new
|
|
636
|
+
toProtoRpcClient(new ExternalApiRpcClient(this.rpcCommunicator!.getRpcClientTransport()))
|
|
656
637
|
)
|
|
657
|
-
return await
|
|
638
|
+
return await rpcRemote.storeData(key, data)
|
|
658
639
|
}
|
|
659
640
|
|
|
660
|
-
public async getDataFromDht(idToFind: Uint8Array): Promise<
|
|
661
|
-
|
|
641
|
+
public async getDataFromDht(idToFind: Uint8Array): Promise<DataEntry[]> {
|
|
642
|
+
if (this.peerDiscovery!.isJoinOngoing() && this.config.entryPoints && this.config.entryPoints.length > 0) {
|
|
643
|
+
return this.findDataViaPeer(idToFind, sample(this.config.entryPoints)!)
|
|
644
|
+
}
|
|
645
|
+
const result = await this.recursiveFinder!.startRecursiveFind(idToFind, true)
|
|
646
|
+
return result.dataEntries ?? []
|
|
662
647
|
}
|
|
663
648
|
|
|
664
649
|
public async deleteDataFromDht(idToDelete: Uint8Array): Promise<void> {
|
|
665
650
|
if (!this.stopped) {
|
|
666
|
-
return this.
|
|
651
|
+
return this.storeRpcLocal!.deleteDataFromDht(idToDelete)
|
|
667
652
|
}
|
|
668
653
|
}
|
|
669
654
|
|
|
670
655
|
public async findDataViaPeer(idToFind: Uint8Array, peer: PeerDescriptor): Promise<DataEntry[]> {
|
|
671
|
-
const
|
|
656
|
+
const rpcRemote = new ExternalApiRpcRemote(
|
|
672
657
|
this.ownPeerDescriptor!,
|
|
673
658
|
peer,
|
|
674
659
|
this.config.serviceId,
|
|
675
|
-
toProtoRpcClient(new
|
|
660
|
+
toProtoRpcClient(new ExternalApiRpcClient(this.rpcCommunicator!.getRpcClientTransport()))
|
|
676
661
|
)
|
|
677
|
-
return await
|
|
662
|
+
return await rpcRemote.findData(idToFind)
|
|
678
663
|
}
|
|
679
664
|
|
|
680
665
|
public getRpcCommunicator(): RoutingRpcCommunicator {
|
|
@@ -682,7 +667,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
682
667
|
}
|
|
683
668
|
|
|
684
669
|
public getTransport(): ITransport {
|
|
685
|
-
return this.
|
|
670
|
+
return this.transport!
|
|
686
671
|
}
|
|
687
672
|
|
|
688
673
|
public getPeerDescriptor(): PeerDescriptor {
|
|
@@ -693,16 +678,8 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
693
678
|
return Array.from(this.connections.values()).map((peer) => peer.getPeerDescriptor())
|
|
694
679
|
}
|
|
695
680
|
|
|
696
|
-
public getK(): number {
|
|
697
|
-
return this.config.numberOfNodesPerKBucket
|
|
698
|
-
}
|
|
699
|
-
|
|
700
681
|
public getKBucketPeers(): PeerDescriptor[] {
|
|
701
|
-
return this.bucket!.toArray().map((
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
public getOpenInternetPeerDescriptors(): PeerDescriptor[] {
|
|
705
|
-
return this.openInternetPeers!.getAllContacts().map((contact) => contact.getPeerDescriptor())
|
|
682
|
+
return this.bucket!.toArray().map((remoteDhtNode: RemoteDhtNode) => remoteDhtNode.getPeerDescriptor())
|
|
706
683
|
}
|
|
707
684
|
|
|
708
685
|
public getNumberOfConnections(): number {
|
|
@@ -721,18 +698,14 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
721
698
|
return this.connectionManager!.getNumberOfWeakLockedConnections()
|
|
722
699
|
}
|
|
723
700
|
|
|
724
|
-
public
|
|
725
|
-
|
|
701
|
+
public async waitForNetworkConnectivity(): Promise<void> {
|
|
702
|
+
await waitForCondition(() => this.connections.size > 0, this.config.networkConnectivityTimeout)
|
|
726
703
|
}
|
|
727
704
|
|
|
728
705
|
public hasJoined(): boolean {
|
|
729
706
|
return this.peerDiscovery!.isJoinCalled()
|
|
730
707
|
}
|
|
731
708
|
|
|
732
|
-
public getKnownEntryPoints(): PeerDescriptor[] {
|
|
733
|
-
return this.config.entryPoints || []
|
|
734
|
-
}
|
|
735
|
-
|
|
736
709
|
public async stop(): Promise<void> {
|
|
737
710
|
if (this.stopped || !this.started) {
|
|
738
711
|
return
|
|
@@ -743,7 +716,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
743
716
|
if (this.entryPointDisconnectTimeout) {
|
|
744
717
|
clearTimeout(this.entryPointDisconnectTimeout)
|
|
745
718
|
}
|
|
746
|
-
this.bucket!.toArray().
|
|
719
|
+
this.bucket!.toArray().forEach((remoteDhtNode: RemoteDhtNode) => this.bucket!.remove(remoteDhtNode.id))
|
|
747
720
|
this.bucket!.removeAllListeners()
|
|
748
721
|
this.localDataStore.clear()
|
|
749
722
|
this.neighborList!.stop()
|
|
@@ -756,7 +729,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
756
729
|
if (this.connectionManager) {
|
|
757
730
|
await this.connectionManager.stop()
|
|
758
731
|
}
|
|
759
|
-
this.
|
|
732
|
+
this.transport = undefined
|
|
760
733
|
this.connectionManager = undefined
|
|
761
734
|
this.connections.clear()
|
|
762
735
|
this.removeAllListeners()
|
|
@@ -766,7 +739,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
766
739
|
private async getClosestPeers(request: ClosestPeersRequest, context: ServerCallContext): Promise<ClosestPeersResponse> {
|
|
767
740
|
this.addNewContact((context as DhtCallContext).incomingSourceDescriptor!)
|
|
768
741
|
const response = {
|
|
769
|
-
peers: this.getClosestPeerDescriptors(request.kademliaId, this.config.
|
|
742
|
+
peers: this.getClosestPeerDescriptors(request.kademliaId, this.config.peerDiscoveryQueryBatchSize),
|
|
770
743
|
requestId: request.requestId
|
|
771
744
|
}
|
|
772
745
|
return response
|
|
@@ -774,7 +747,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
774
747
|
|
|
775
748
|
// IDHTRpcService implementation
|
|
776
749
|
private async ping(request: PingRequest, context: ServerCallContext): Promise<PingResponse> {
|
|
777
|
-
logger.trace('received ping request: ' +
|
|
750
|
+
logger.trace('received ping request: ' + keyFromPeerDescriptor((context as DhtCallContext).incomingSourceDescriptor!))
|
|
778
751
|
setImmediate(() => {
|
|
779
752
|
this.addNewContact((context as DhtCallContext).incomingSourceDescriptor!)
|
|
780
753
|
})
|
|
@@ -785,7 +758,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
|
|
|
785
758
|
}
|
|
786
759
|
|
|
787
760
|
// IDHTRpcService implementation
|
|
788
|
-
|
|
761
|
+
private async leaveNotice(request: LeaveNotice, context: ServerCallContext): Promise<Empty> {
|
|
789
762
|
// TODO check signature??
|
|
790
763
|
if (request.serviceId === this.config.serviceId) {
|
|
791
764
|
this.removeContact((context as DhtCallContext).incomingSourceDescriptor!)
|