@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.1
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 +8 -8
- 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 +8 -8
- 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
|
@@ -6,7 +6,7 @@ import { RoutingMode } from './RoutingSession'
|
|
|
6
6
|
import { areEqualPeerDescriptors, getDhtAddressFromRaw, getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
7
7
|
import { v4 } from 'uuid'
|
|
8
8
|
|
|
9
|
-
interface
|
|
9
|
+
interface RouterRpcLocalOptions {
|
|
10
10
|
doRouteMessage: (routedMessage: RouteMessageWrapper, mode?: RoutingMode) => RouteMessageAck
|
|
11
11
|
setForwardingEntries: (routedMessage: RouteMessageWrapper) => void
|
|
12
12
|
handleMessage: (message: Message) => void
|
|
@@ -26,53 +26,53 @@ export const createRouteMessageAck = (routedMessage: RouteMessageWrapper, error?
|
|
|
26
26
|
|
|
27
27
|
export class RouterRpcLocal implements IRouterRpc {
|
|
28
28
|
|
|
29
|
-
private readonly
|
|
29
|
+
private readonly options: RouterRpcLocalOptions
|
|
30
30
|
|
|
31
|
-
constructor(
|
|
32
|
-
this.
|
|
31
|
+
constructor(options: RouterRpcLocalOptions) {
|
|
32
|
+
this.options = options
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async routeMessage(routedMessage: RouteMessageWrapper): Promise<RouteMessageAck> {
|
|
36
|
-
if (this.
|
|
36
|
+
if (this.options.duplicateRequestDetector.isMostLikelyDuplicate(routedMessage.requestId)) {
|
|
37
37
|
logger.trace(`Routing message ${routedMessage.requestId} from ${getNodeIdFromPeerDescriptor(routedMessage.sourcePeer!)} `
|
|
38
38
|
+ `to ${getDhtAddressFromRaw(routedMessage.target)} is likely a duplicate`)
|
|
39
39
|
return createRouteMessageAck(routedMessage, RouteMessageError.DUPLICATE)
|
|
40
40
|
}
|
|
41
41
|
logger.trace(`Processing received routeMessage ${routedMessage.requestId}`)
|
|
42
|
-
this.
|
|
43
|
-
if (areEqualBinaries(this.
|
|
42
|
+
this.options.duplicateRequestDetector.add(routedMessage.requestId)
|
|
43
|
+
if (areEqualBinaries(this.options.localPeerDescriptor.nodeId, routedMessage.target)) {
|
|
44
44
|
logger.trace(`routing message targeted to self ${routedMessage.requestId}`)
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
45
|
+
this.options.setForwardingEntries(routedMessage)
|
|
46
|
+
this.options.handleMessage(routedMessage.message!)
|
|
47
47
|
return createRouteMessageAck(routedMessage)
|
|
48
48
|
} else {
|
|
49
|
-
return this.
|
|
49
|
+
return this.options.doRouteMessage(routedMessage)
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async forwardMessage(forwardMessage: RouteMessageWrapper): Promise<RouteMessageAck> {
|
|
54
|
-
if (this.
|
|
54
|
+
if (this.options.duplicateRequestDetector.isMostLikelyDuplicate(forwardMessage.requestId)) {
|
|
55
55
|
logger.trace(`Forwarding message ${forwardMessage.requestId} from ${getNodeIdFromPeerDescriptor(forwardMessage.sourcePeer!)} `
|
|
56
56
|
+ `to ${getDhtAddressFromRaw(forwardMessage.target)} is likely a duplicate`)
|
|
57
57
|
return createRouteMessageAck(forwardMessage, RouteMessageError.DUPLICATE)
|
|
58
58
|
}
|
|
59
59
|
logger.trace(`Processing received forward routeMessage ${forwardMessage.requestId}`)
|
|
60
|
-
this.
|
|
61
|
-
if (areEqualBinaries(this.
|
|
60
|
+
this.options.duplicateRequestDetector.add(forwardMessage.requestId)
|
|
61
|
+
if (areEqualBinaries(this.options.localPeerDescriptor.nodeId, forwardMessage.target)) {
|
|
62
62
|
return this.forwardToDestination(forwardMessage)
|
|
63
63
|
} else {
|
|
64
|
-
return this.
|
|
64
|
+
return this.options.doRouteMessage(forwardMessage, RoutingMode.FORWARD)
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
private forwardToDestination(routedMessage: RouteMessageWrapper): RouteMessageAck {
|
|
69
69
|
logger.trace(`Forwarding found message targeted to self ${routedMessage.requestId}`)
|
|
70
70
|
const forwardedMessage = routedMessage.message!
|
|
71
|
-
if (areEqualPeerDescriptors(this.
|
|
72
|
-
this.
|
|
71
|
+
if (areEqualPeerDescriptors(this.options.localPeerDescriptor, forwardedMessage.targetDescriptor!)) {
|
|
72
|
+
this.options.handleMessage(forwardedMessage)
|
|
73
73
|
return createRouteMessageAck(routedMessage)
|
|
74
74
|
}
|
|
75
|
-
return this.
|
|
75
|
+
return this.options.doRouteMessage({ ...routedMessage, requestId: v4(), target: forwardedMessage.targetDescriptor!.nodeId })
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
}
|
|
@@ -64,7 +64,7 @@ export interface RoutingSessionEvents {
|
|
|
64
64
|
|
|
65
65
|
export enum RoutingMode { ROUTE, FORWARD, RECURSIVE }
|
|
66
66
|
|
|
67
|
-
interface
|
|
67
|
+
interface RoutingSessionOptions {
|
|
68
68
|
rpcCommunicator: RoutingRpcCommunicator
|
|
69
69
|
localPeerDescriptor: PeerDescriptor
|
|
70
70
|
routedMessage: RouteMessageWrapper
|
|
@@ -83,11 +83,11 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
83
83
|
private failedHopCounter = 0
|
|
84
84
|
private successfulHopCounter = 0
|
|
85
85
|
private stopped = false
|
|
86
|
-
private readonly
|
|
86
|
+
private readonly options: RoutingSessionOptions
|
|
87
87
|
|
|
88
|
-
constructor(
|
|
88
|
+
constructor(options: RoutingSessionOptions) {
|
|
89
89
|
super()
|
|
90
|
-
this.
|
|
90
|
+
this.options = options
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
private onRequestFailed(nodeId: DhtAddress) {
|
|
@@ -129,7 +129,7 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
129
129
|
return
|
|
130
130
|
}
|
|
131
131
|
this.successfulHopCounter += 1
|
|
132
|
-
if (this.successfulHopCounter >= this.
|
|
132
|
+
if (this.successfulHopCounter >= this.options.parallelism) {
|
|
133
133
|
this.emit('routingSucceeded')
|
|
134
134
|
return
|
|
135
135
|
}
|
|
@@ -146,12 +146,12 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
146
146
|
return false
|
|
147
147
|
}
|
|
148
148
|
const msg = {
|
|
149
|
-
...this.
|
|
150
|
-
routingPath: this.
|
|
149
|
+
...this.options.routedMessage,
|
|
150
|
+
routingPath: this.options.routedMessage.routingPath.concat([this.options.localPeerDescriptor])
|
|
151
151
|
}
|
|
152
|
-
if (this.
|
|
152
|
+
if (this.options.mode === RoutingMode.FORWARD) {
|
|
153
153
|
return contact.getRouterRpcRemote().forwardMessage(msg)
|
|
154
|
-
} else if (this.
|
|
154
|
+
} else if (this.options.mode === RoutingMode.RECURSIVE) {
|
|
155
155
|
return contact.getRecursiveOperationRpcRemote().routeRequest(msg)
|
|
156
156
|
} else {
|
|
157
157
|
return contact.getRouterRpcRemote().routeMessage(msg)
|
|
@@ -160,30 +160,30 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
160
160
|
|
|
161
161
|
updateAndGetRoutablePeers(): RoutingRemoteContact[] {
|
|
162
162
|
logger.trace('getRoutablePeers() sessionId: ' + this.sessionId)
|
|
163
|
-
const previousPeer = getPreviousPeer(this.
|
|
163
|
+
const previousPeer = getPreviousPeer(this.options.routedMessage)
|
|
164
164
|
const previousId = previousPeer ? getNodeIdFromPeerDescriptor(previousPeer) : undefined
|
|
165
|
-
const targetId = getDhtAddressFromRaw(this.
|
|
165
|
+
const targetId = getDhtAddressFromRaw(this.options.routedMessage.target)
|
|
166
166
|
let routingTable: RoutingTable
|
|
167
|
-
if (this.
|
|
168
|
-
routingTable = this.
|
|
167
|
+
if (this.options.routingTablesCache.has(targetId, previousId)) {
|
|
168
|
+
routingTable = this.options.routingTablesCache.get(targetId, previousId)!
|
|
169
169
|
} else {
|
|
170
170
|
routingTable = new SortedContactList<RoutingRemoteContact>({
|
|
171
|
-
referenceId: getDhtAddressFromRaw(this.
|
|
171
|
+
referenceId: getDhtAddressFromRaw(this.options.routedMessage.target),
|
|
172
172
|
maxSize: ROUTING_TABLE_MAX_SIZE,
|
|
173
173
|
allowToContainReferenceId: true,
|
|
174
174
|
nodeIdDistanceLimit: previousId
|
|
175
175
|
})
|
|
176
|
-
const contacts = this.
|
|
176
|
+
const contacts = this.options.getConnections()
|
|
177
177
|
.map((peer) => new RoutingRemoteContact(
|
|
178
178
|
peer,
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
179
|
+
this.options.localPeerDescriptor,
|
|
180
|
+
this.options.rpcCommunicator
|
|
181
181
|
))
|
|
182
182
|
routingTable.addContacts(contacts)
|
|
183
|
-
this.
|
|
183
|
+
this.options.routingTablesCache.set(targetId, routingTable, previousId)
|
|
184
184
|
}
|
|
185
185
|
return routingTable.getClosestContacts()
|
|
186
|
-
.filter((contact) => !this.contactedPeers.has(contact.getNodeId()) && !this.
|
|
186
|
+
.filter((contact) => !this.contactedPeers.has(contact.getNodeId()) && !this.options.excludedNodeIds.has(contact.getNodeId()))
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
sendMoreRequests(uncontacted: RoutingRemoteContact[]): void {
|
|
@@ -195,7 +195,7 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
195
195
|
this.emitFailure()
|
|
196
196
|
return
|
|
197
197
|
}
|
|
198
|
-
while ((this.ongoingRequests.size < this.
|
|
198
|
+
while ((this.ongoingRequests.size < this.options.parallelism) && (uncontacted.length > 0) && !this.stopped) {
|
|
199
199
|
const nextPeer = uncontacted.shift()
|
|
200
200
|
// eslint-disable-next-line max-len
|
|
201
201
|
logger.trace(`Sending routeMessage request to contact: ${getNodeIdFromPeerDescriptor(nextPeer!.getPeerDescriptor())} (sessionId=${this.sessionId})`)
|
|
@@ -221,19 +221,19 @@ export class RoutingSession extends EventEmitter<RoutingSessionEvents> {
|
|
|
221
221
|
|
|
222
222
|
private addParallelRootIfSource(nodeId: DhtAddress) {
|
|
223
223
|
if (
|
|
224
|
-
this.
|
|
225
|
-
&& areEqualPeerDescriptors(this.
|
|
224
|
+
this.options.mode === RoutingMode.RECURSIVE
|
|
225
|
+
&& areEqualPeerDescriptors(this.options.localPeerDescriptor, this.options.routedMessage.sourcePeer!)
|
|
226
226
|
) {
|
|
227
|
-
this.
|
|
227
|
+
this.options.routedMessage.parallelRootNodeIds.push(nodeId)
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
private deleteParallelRootIfSource(nodeId: DhtAddress) {
|
|
232
232
|
if (
|
|
233
|
-
this.
|
|
234
|
-
&& areEqualPeerDescriptors(this.
|
|
233
|
+
this.options.mode === RoutingMode.RECURSIVE
|
|
234
|
+
&& areEqualPeerDescriptors(this.options.localPeerDescriptor, this.options.routedMessage.sourcePeer!)
|
|
235
235
|
) {
|
|
236
|
-
pull(this.
|
|
236
|
+
pull(this.options.routedMessage.parallelRootNodeIds, nodeId)
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
@@ -24,7 +24,7 @@ import { LocalDataStore } from './LocalDataStore'
|
|
|
24
24
|
import { StoreRpcLocal } from './StoreRpcLocal'
|
|
25
25
|
import { StoreRpcRemote } from './StoreRpcRemote'
|
|
26
26
|
|
|
27
|
-
interface
|
|
27
|
+
interface StoreManagerOptions {
|
|
28
28
|
rpcCommunicator: RoutingRpcCommunicator
|
|
29
29
|
recursiveOperationManager: RecursiveOperationManager
|
|
30
30
|
localPeerDescriptor: PeerDescriptor
|
|
@@ -40,28 +40,28 @@ const logger = new Logger(module)
|
|
|
40
40
|
|
|
41
41
|
export class StoreManager {
|
|
42
42
|
|
|
43
|
-
private readonly
|
|
43
|
+
private readonly options: StoreManagerOptions
|
|
44
44
|
|
|
45
|
-
constructor(
|
|
46
|
-
this.
|
|
45
|
+
constructor(options: StoreManagerOptions) {
|
|
46
|
+
this.options = options
|
|
47
47
|
this.registerLocalRpcMethods()
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
private registerLocalRpcMethods() {
|
|
51
51
|
const rpcLocal = new StoreRpcLocal({
|
|
52
|
-
localPeerDescriptor: this.
|
|
53
|
-
localDataStore: this.
|
|
52
|
+
localPeerDescriptor: this.options.localPeerDescriptor,
|
|
53
|
+
localDataStore: this.options.localDataStore,
|
|
54
54
|
replicateDataToContact: (dataEntry: DataEntry, contact: PeerDescriptor) => this.replicateDataToContact(dataEntry, contact),
|
|
55
55
|
getStorers: (dataKey: DhtAddress) => this.getStorers(dataKey)
|
|
56
56
|
})
|
|
57
|
-
this.
|
|
57
|
+
this.options.rpcCommunicator.registerRpcMethod(StoreDataRequest, StoreDataResponse, 'storeData',
|
|
58
58
|
(request: StoreDataRequest) => rpcLocal.storeData(request))
|
|
59
|
-
this.
|
|
59
|
+
this.options.rpcCommunicator.registerRpcNotification(ReplicateDataRequest, 'replicateData',
|
|
60
60
|
(request: ReplicateDataRequest, context: ServerCallContext) => rpcLocal.replicateData(request, context))
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
onContactAdded(peerDescriptor: PeerDescriptor): void {
|
|
64
|
-
for (const key of this.
|
|
64
|
+
for (const key of this.options.localDataStore.keys()) {
|
|
65
65
|
this.replicateAndUpdateStaleState(key, peerDescriptor)
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -69,21 +69,21 @@ export class StoreManager {
|
|
|
69
69
|
private replicateAndUpdateStaleState(dataKey: DhtAddress, newNode: PeerDescriptor): void {
|
|
70
70
|
const storers = this.getStorers(dataKey)
|
|
71
71
|
const storersBeforeContactAdded = storers.filter((p) => !areEqualPeerDescriptors(p, newNode))
|
|
72
|
-
const selfWasPrimaryStorer = areEqualPeerDescriptors(storersBeforeContactAdded[0], this.
|
|
72
|
+
const selfWasPrimaryStorer = areEqualPeerDescriptors(storersBeforeContactAdded[0], this.options.localPeerDescriptor)
|
|
73
73
|
if (selfWasPrimaryStorer) {
|
|
74
74
|
if (storers.some((p) => areEqualPeerDescriptors(p, newNode))) {
|
|
75
75
|
setImmediate(async () => {
|
|
76
|
-
const dataEntries = Array.from(this.
|
|
76
|
+
const dataEntries = Array.from(this.options.localDataStore.values(dataKey))
|
|
77
77
|
await Promise.all(dataEntries.map(async (dataEntry) => this.replicateDataToContact(dataEntry, newNode)))
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
|
-
} else if (!storers.some((p) => areEqualPeerDescriptors(p, this.
|
|
81
|
-
this.
|
|
80
|
+
} else if (!storers.some((p) => areEqualPeerDescriptors(p, this.options.localPeerDescriptor))) {
|
|
81
|
+
this.options.localDataStore.setAllEntriesAsStale(dataKey)
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
private async replicateDataToContact(dataEntry: DataEntry, contact: PeerDescriptor): Promise<void> {
|
|
86
|
-
const rpcRemote = this.
|
|
86
|
+
const rpcRemote = this.options.createRpcRemote(contact)
|
|
87
87
|
try {
|
|
88
88
|
await rpcRemote.replicateData({ entry: dataEntry })
|
|
89
89
|
} catch (e) {
|
|
@@ -92,17 +92,17 @@ export class StoreManager {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
public async storeDataToDht(key: DhtAddress, data: Any, creator: DhtAddress): Promise<PeerDescriptor[]> {
|
|
95
|
-
logger.debug(`Storing data to DHT ${this.
|
|
96
|
-
const result = await this.
|
|
95
|
+
logger.debug(`Storing data to DHT ${this.options.serviceId}`)
|
|
96
|
+
const result = await this.options.recursiveOperationManager.execute(key, RecursiveOperation.FIND_CLOSEST_NODES)
|
|
97
97
|
const closestNodes = result.closestNodes
|
|
98
98
|
const successfulNodes: PeerDescriptor[] = []
|
|
99
|
-
const ttl = this.
|
|
99
|
+
const ttl = this.options.highestTtl // ToDo: make TTL decrease according to some nice curve
|
|
100
100
|
const createdAt = Timestamp.now()
|
|
101
|
-
for (let i = 0; i < closestNodes.length && successfulNodes.length < this.
|
|
101
|
+
for (let i = 0; i < closestNodes.length && successfulNodes.length < this.options.redundancyFactor; i++) {
|
|
102
102
|
const keyRaw = getRawFromDhtAddress(key)
|
|
103
103
|
const creatorRaw = getRawFromDhtAddress(creator)
|
|
104
|
-
if (areEqualPeerDescriptors(this.
|
|
105
|
-
this.
|
|
104
|
+
if (areEqualPeerDescriptors(this.options.localPeerDescriptor, closestNodes[i])) {
|
|
105
|
+
this.options.localDataStore.storeEntry({
|
|
106
106
|
key: keyRaw,
|
|
107
107
|
data,
|
|
108
108
|
creator: creatorRaw,
|
|
@@ -115,7 +115,7 @@ export class StoreManager {
|
|
|
115
115
|
successfulNodes.push(closestNodes[i])
|
|
116
116
|
continue
|
|
117
117
|
}
|
|
118
|
-
const rpcRemote = this.
|
|
118
|
+
const rpcRemote = this.options.createRpcRemote(closestNodes[i])
|
|
119
119
|
try {
|
|
120
120
|
await rpcRemote.storeData({
|
|
121
121
|
key: keyRaw,
|
|
@@ -134,16 +134,16 @@ export class StoreManager {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
private async replicateDataToClosestNodes(): Promise<void> {
|
|
137
|
-
const dataEntries = Array.from(this.
|
|
137
|
+
const dataEntries = Array.from(this.options.localDataStore.values())
|
|
138
138
|
await Promise.all(dataEntries.map(async (dataEntry) => {
|
|
139
139
|
const dataKey = getDhtAddressFromRaw(dataEntry.key)
|
|
140
140
|
const neighbors = getClosestNodes(
|
|
141
141
|
dataKey,
|
|
142
|
-
this.
|
|
143
|
-
{ maxCount: this.
|
|
142
|
+
this.options.getNeighbors(),
|
|
143
|
+
{ maxCount: this.options.redundancyFactor }
|
|
144
144
|
)
|
|
145
145
|
await Promise.all(neighbors.map(async (neighbor) => {
|
|
146
|
-
const rpcRemote = this.
|
|
146
|
+
const rpcRemote = this.options.createRpcRemote(neighbor)
|
|
147
147
|
try {
|
|
148
148
|
await rpcRemote.replicateData({ entry: dataEntry })
|
|
149
149
|
} catch (err) {
|
|
@@ -156,9 +156,9 @@ export class StoreManager {
|
|
|
156
156
|
private getStorers(dataKey: DhtAddress, excludedNode?: PeerDescriptor): PeerDescriptor[] {
|
|
157
157
|
return getClosestNodes(
|
|
158
158
|
dataKey,
|
|
159
|
-
[...this.
|
|
159
|
+
[...this.options.getNeighbors(), this.options.localPeerDescriptor],
|
|
160
160
|
{
|
|
161
|
-
maxCount: this.
|
|
161
|
+
maxCount: this.options.redundancyFactor,
|
|
162
162
|
excludedNodeIds: excludedNode !== undefined ? new Set([getNodeIdFromPeerDescriptor(excludedNode)]) : undefined
|
|
163
163
|
}
|
|
164
164
|
)
|
|
@@ -13,7 +13,7 @@ import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
|
13
13
|
import { LocalDataStore } from './LocalDataStore'
|
|
14
14
|
import { areEqualPeerDescriptors, DhtAddress, getDhtAddressFromRaw } from '../../identifiers'
|
|
15
15
|
|
|
16
|
-
interface
|
|
16
|
+
interface StoreRpcLocalOptions {
|
|
17
17
|
localDataStore: LocalDataStore
|
|
18
18
|
localPeerDescriptor: PeerDescriptor
|
|
19
19
|
replicateDataToContact: (dataEntry: DataEntry, contact: PeerDescriptor) => Promise<void>
|
|
@@ -24,17 +24,17 @@ const logger = new Logger(module)
|
|
|
24
24
|
|
|
25
25
|
export class StoreRpcLocal implements IStoreRpc {
|
|
26
26
|
|
|
27
|
-
private readonly
|
|
27
|
+
private readonly options: StoreRpcLocalOptions
|
|
28
28
|
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
29
|
+
constructor(options: StoreRpcLocalOptions) {
|
|
30
|
+
this.options = options
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async storeData(request: StoreDataRequest): Promise<StoreDataResponse> {
|
|
34
34
|
logger.trace('storeData()')
|
|
35
35
|
const key = getDhtAddressFromRaw(request.key)
|
|
36
36
|
const isLocalNodeStorer = this.isLocalNodeStorer(key)
|
|
37
|
-
this.
|
|
37
|
+
this.options.localDataStore.storeEntry({
|
|
38
38
|
key: request.key,
|
|
39
39
|
data: request.data,
|
|
40
40
|
creator: request.creator,
|
|
@@ -45,7 +45,7 @@ export class StoreRpcLocal implements IStoreRpc {
|
|
|
45
45
|
deleted: false
|
|
46
46
|
})
|
|
47
47
|
if (!isLocalNodeStorer) {
|
|
48
|
-
this.
|
|
48
|
+
this.options.localDataStore.setAllEntriesAsStale(key)
|
|
49
49
|
}
|
|
50
50
|
return {}
|
|
51
51
|
}
|
|
@@ -53,35 +53,35 @@ export class StoreRpcLocal implements IStoreRpc {
|
|
|
53
53
|
public async replicateData(request: ReplicateDataRequest, context: ServerCallContext): Promise<Empty> {
|
|
54
54
|
logger.trace('server-side replicateData()')
|
|
55
55
|
const dataEntry = request.entry!
|
|
56
|
-
const wasStored = this.
|
|
56
|
+
const wasStored = this.options.localDataStore.storeEntry(dataEntry)
|
|
57
57
|
if (wasStored) {
|
|
58
58
|
this.replicateDataToNeighbors((context as DhtCallContext).incomingSourceDescriptor!, request.entry!)
|
|
59
59
|
}
|
|
60
60
|
const key = getDhtAddressFromRaw(dataEntry.key)
|
|
61
61
|
if (!this.isLocalNodeStorer(key)) {
|
|
62
|
-
this.
|
|
62
|
+
this.options.localDataStore.setAllEntriesAsStale(key)
|
|
63
63
|
}
|
|
64
64
|
logger.trace('server-side replicateData() at end')
|
|
65
65
|
return {}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
private isLocalNodeStorer(dataKey: DhtAddress): boolean {
|
|
69
|
-
return this.
|
|
69
|
+
return this.options.getStorers(dataKey).some((p) => areEqualPeerDescriptors(p, this.options.localPeerDescriptor))
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
private replicateDataToNeighbors(requestor: PeerDescriptor, dataEntry: DataEntry): void {
|
|
73
73
|
const dataKey = getDhtAddressFromRaw(dataEntry.key)
|
|
74
|
-
const storers = this.
|
|
75
|
-
const isLocalNodePrimaryStorer = areEqualPeerDescriptors(storers[0], this.
|
|
74
|
+
const storers = this.options.getStorers(dataKey)
|
|
75
|
+
const isLocalNodePrimaryStorer = areEqualPeerDescriptors(storers[0], this.options.localPeerDescriptor)
|
|
76
76
|
// If we are the closest to the data, get storageRedundancyFactor - 1 nearest node to the data, and
|
|
77
77
|
// replicate to all those node. Otherwise replicate only to the one closest one. And never replicate
|
|
78
78
|
// to the requestor nor to itself.
|
|
79
79
|
const targets = (isLocalNodePrimaryStorer ? storers : [storers[0]]).filter(
|
|
80
|
-
(p) => !areEqualPeerDescriptors(p, requestor) && !areEqualPeerDescriptors(p, this.
|
|
80
|
+
(p) => !areEqualPeerDescriptors(p, requestor) && !areEqualPeerDescriptors(p, this.options.localPeerDescriptor)
|
|
81
81
|
)
|
|
82
82
|
targets.forEach((target) => {
|
|
83
83
|
setImmediate(() => {
|
|
84
|
-
executeSafePromise(() => this.
|
|
84
|
+
executeSafePromise(() => this.options.replicateDataToContact(dataEntry, target))
|
|
85
85
|
})
|
|
86
86
|
})
|
|
87
87
|
}
|
package/src/exports.ts
CHANGED
|
@@ -16,9 +16,12 @@ export { IceServer } from './connection/webrtc/WebrtcConnector'
|
|
|
16
16
|
export { DhtCallContext } from './rpc-protocol/DhtCallContext'
|
|
17
17
|
export { WebsocketClientConnection } from './connection/websocket/NodeWebsocketClientConnection'
|
|
18
18
|
export { ManagedConnection } from './connection/ManagedConnection'
|
|
19
|
+
export { PendingConnection } from './connection/PendingConnection'
|
|
20
|
+
export { IConnection } from './connection/IConnection'
|
|
19
21
|
export { ConnectionType } from './connection/IConnection'
|
|
20
22
|
export { ServiceID } from './types/ServiceID'
|
|
21
23
|
export { RingContacts } from './dht/contact/RingContactList'
|
|
24
|
+
export { createOutgoingHandshaker } from './connection/Handshaker'
|
|
22
25
|
export {
|
|
23
26
|
DhtAddress,
|
|
24
27
|
DhtAddressRaw,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "google/protobuf/any.proto" (package "google.protobuf", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
//
|
|
@@ -74,7 +74,7 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
74
74
|
* foo = any.unpack(Foo.class);
|
|
75
75
|
* }
|
|
76
76
|
*
|
|
77
|
-
*
|
|
77
|
+
* Example 3: Pack and unpack a message in Python.
|
|
78
78
|
*
|
|
79
79
|
* foo = Foo(...)
|
|
80
80
|
* any = Any()
|
|
@@ -84,16 +84,13 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
84
84
|
* any.Unpack(foo)
|
|
85
85
|
* ...
|
|
86
86
|
*
|
|
87
|
-
*
|
|
87
|
+
* Example 4: Pack and unpack a message in Go
|
|
88
88
|
*
|
|
89
89
|
* foo := &pb.Foo{...}
|
|
90
|
-
* any, err :=
|
|
91
|
-
* if err != nil {
|
|
92
|
-
* ...
|
|
93
|
-
* }
|
|
90
|
+
* any, err := ptypes.MarshalAny(foo)
|
|
94
91
|
* ...
|
|
95
92
|
* foo := &pb.Foo{}
|
|
96
|
-
* if err :=
|
|
93
|
+
* if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
|
97
94
|
* ...
|
|
98
95
|
* }
|
|
99
96
|
*
|
|
@@ -105,7 +102,7 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
105
102
|
*
|
|
106
103
|
*
|
|
107
104
|
* JSON
|
|
108
|
-
*
|
|
105
|
+
* ====
|
|
109
106
|
* The JSON representation of an `Any` value uses the regular
|
|
110
107
|
* representation of the deserialized, embedded message, with an
|
|
111
108
|
* additional field `@type` which contains the type URL. Example:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "google/protobuf/empty.proto" (package "google.protobuf", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
//
|
|
@@ -49,6 +49,7 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
49
49
|
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
50
50
|
* }
|
|
51
51
|
*
|
|
52
|
+
* The JSON representation for `Empty` is empty JSON object `{}`.
|
|
52
53
|
*
|
|
53
54
|
* @generated from protobuf message google.protobuf.Empty
|
|
54
55
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "google/protobuf/timestamp.proto" (package "google.protobuf", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
//
|
|
@@ -98,16 +98,7 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
98
98
|
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
99
99
|
*
|
|
100
100
|
*
|
|
101
|
-
* Example 5: Compute Timestamp from
|
|
102
|
-
*
|
|
103
|
-
* Instant now = Instant.now();
|
|
104
|
-
*
|
|
105
|
-
* Timestamp timestamp =
|
|
106
|
-
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
107
|
-
* .setNanos(now.getNano()).build();
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* Example 6: Compute Timestamp from current time in Python.
|
|
101
|
+
* Example 5: Compute Timestamp from current time in Python.
|
|
111
102
|
*
|
|
112
103
|
* timestamp = Timestamp()
|
|
113
104
|
* timestamp.GetCurrentTime()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "packages/dht/protos/DhtRpc.proto" (package "dht", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
import { ExternalApiRpc } from "./DhtRpc";
|
|
@@ -16,7 +16,7 @@ import type { IceCandidate } from "./DhtRpc";
|
|
|
16
16
|
import type { RtcAnswer } from "./DhtRpc";
|
|
17
17
|
import type { RtcOffer } from "./DhtRpc";
|
|
18
18
|
import type { WebrtcConnectionRequest } from "./DhtRpc";
|
|
19
|
-
import {
|
|
19
|
+
import { WebsocketClientConnectorRpc } from "./DhtRpc";
|
|
20
20
|
import type { WebsocketConnectionRequest } from "./DhtRpc";
|
|
21
21
|
import { RecursiveOperationSessionRpc } from "./DhtRpc";
|
|
22
22
|
import type { RecursiveOperationResponse } from "./DhtRpc";
|
|
@@ -236,21 +236,21 @@ export class RecursiveOperationSessionRpcClient implements IRecursiveOperationSe
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
239
|
-
* @generated from protobuf service dht.
|
|
239
|
+
* @generated from protobuf service dht.WebsocketClientConnectorRpc
|
|
240
240
|
*/
|
|
241
|
-
export interface
|
|
241
|
+
export interface IWebsocketClientConnectorRpcClient {
|
|
242
242
|
/**
|
|
243
243
|
* @generated from protobuf rpc: requestConnection(dht.WebsocketConnectionRequest) returns (google.protobuf.Empty);
|
|
244
244
|
*/
|
|
245
245
|
requestConnection(input: WebsocketConnectionRequest, options?: RpcOptions): UnaryCall<WebsocketConnectionRequest, Empty>;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
* @generated from protobuf service dht.
|
|
248
|
+
* @generated from protobuf service dht.WebsocketClientConnectorRpc
|
|
249
249
|
*/
|
|
250
|
-
export class
|
|
251
|
-
typeName =
|
|
252
|
-
methods =
|
|
253
|
-
options =
|
|
250
|
+
export class WebsocketClientConnectorRpcClient implements IWebsocketClientConnectorRpcClient, ServiceInfo {
|
|
251
|
+
typeName = WebsocketClientConnectorRpc.typeName;
|
|
252
|
+
methods = WebsocketClientConnectorRpc.methods;
|
|
253
|
+
options = WebsocketClientConnectorRpc.options;
|
|
254
254
|
constructor(private readonly _transport: RpcTransport) {
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "packages/dht/protos/DhtRpc.proto" (package "dht", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
import { ExternalStoreDataResponse } from "./DhtRpc";
|
|
@@ -99,9 +99,9 @@ export interface IRecursiveOperationSessionRpc<T = ServerCallContext> {
|
|
|
99
99
|
sendResponse(request: RecursiveOperationResponse, context: T): Promise<Empty>;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
* @generated from protobuf service dht.
|
|
102
|
+
* @generated from protobuf service dht.WebsocketClientConnectorRpc
|
|
103
103
|
*/
|
|
104
|
-
export interface
|
|
104
|
+
export interface IWebsocketClientConnectorRpc<T = ServerCallContext> {
|
|
105
105
|
/**
|
|
106
106
|
* @generated from protobuf rpc: requestConnection(dht.WebsocketConnectionRequest) returns (google.protobuf.Empty);
|
|
107
107
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "packages/dht/protos/DhtRpc.proto" (package "dht", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
import { Empty } from "../../../google/protobuf/empty";
|
|
@@ -123,7 +123,7 @@ export interface ClosestPeersRequest {
|
|
|
123
123
|
requestId: string;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* TODO rename to
|
|
126
|
+
* TODO rename to ClosestNeighborsResponse
|
|
127
127
|
*
|
|
128
128
|
* @generated from protobuf message dht.ClosestPeersResponse
|
|
129
129
|
*/
|
|
@@ -1213,9 +1213,9 @@ export const RecursiveOperationSessionRpc = new ServiceType("dht.RecursiveOperat
|
|
|
1213
1213
|
{ name: "sendResponse", options: {}, I: RecursiveOperationResponse, O: Empty }
|
|
1214
1214
|
]);
|
|
1215
1215
|
/**
|
|
1216
|
-
* @generated ServiceType for protobuf service dht.
|
|
1216
|
+
* @generated ServiceType for protobuf service dht.WebsocketClientConnectorRpc
|
|
1217
1217
|
*/
|
|
1218
|
-
export const
|
|
1218
|
+
export const WebsocketClientConnectorRpc = new ServiceType("dht.WebsocketClientConnectorRpc", [
|
|
1219
1219
|
{ name: "requestConnection", options: {}, I: WebsocketConnectionRequest, O: Empty }
|
|
1220
1220
|
]);
|
|
1221
1221
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protobuf-ts 2.9.
|
|
1
|
+
// @generated by protobuf-ts 2.9.4 with parameter server_generic,generate_dependencies,long_type_number
|
|
2
2
|
// @generated from protobuf file "packages/proto-rpc/protos/ProtoRpc.proto" (package "protorpc", syntax proto3)
|
|
3
3
|
// tslint:disable
|
|
4
4
|
import { MessageType } from "@protobuf-ts/runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ITransport } from './ITransport'
|
|
2
2
|
import { RoutingRpcCommunicator } from './RoutingRpcCommunicator'
|
|
3
|
-
import {
|
|
3
|
+
import { RpcCommunicatorOptions } from '@streamr/proto-rpc'
|
|
4
4
|
import { Message } from '../proto/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { ServiceID } from '../types/ServiceID'
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ export class ListeningRpcCommunicator extends RoutingRpcCommunicator {
|
|
|
8
8
|
private readonly transport: ITransport
|
|
9
9
|
private readonly listener: (msg: Message) => void
|
|
10
10
|
|
|
11
|
-
constructor(ownServiceId: ServiceID, transport: ITransport,
|
|
12
|
-
super(ownServiceId, (msg, opts) => transport.send(msg, opts),
|
|
11
|
+
constructor(ownServiceId: ServiceID, transport: ITransport, options?: RpcCommunicatorOptions) {
|
|
12
|
+
super(ownServiceId, (msg, opts) => transport.send(msg, opts), options)
|
|
13
13
|
this.listener = (msg: Message) => {
|
|
14
14
|
this.handleMessageFromPeer(msg)
|
|
15
15
|
}
|