@streamr/trackerless-network 0.0.1-tatum.6 → 0.0.1-tatum.7
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 +10 -8
- package/dist/src/NetworkNode.js +1 -1
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +1 -3
- package/dist/src/NetworkStack.js +18 -47
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/identifiers.js +2 -2
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/logic/{StreamNodeServer.d.ts → DeliveryRpcLocal.d.ts} +6 -5
- package/dist/src/logic/{StreamNodeServer.js → DeliveryRpcLocal.js} +5 -5
- package/dist/src/logic/{StreamNodeServer.js.map → DeliveryRpcLocal.js.map} +1 -1
- package/dist/src/logic/{RemoteRandomGraphNode.d.ts → DeliveryRpcRemote.d.ts} +2 -2
- package/dist/src/logic/{RemoteRandomGraphNode.js → DeliveryRpcRemote.js} +5 -5
- package/dist/src/logic/DeliveryRpcRemote.js.map +1 -0
- package/dist/src/logic/{StreamPartEntryPointDiscovery.d.ts → EntryPointDiscovery.d.ts} +8 -10
- package/dist/src/logic/{StreamPartEntryPointDiscovery.js → EntryPointDiscovery.js} +14 -36
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -0
- package/dist/src/logic/ILayer0.d.ts +3 -6
- package/dist/src/logic/NodeList.d.ts +10 -10
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/RandomGraphNode.d.ts +8 -12
- package/dist/src/logic/RandomGraphNode.js +41 -40
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/StreamrNode.d.ts +9 -12
- package/dist/src/logic/StreamrNode.js +53 -63
- package/dist/src/logic/StreamrNode.js.map +1 -1
- package/dist/src/logic/createRandomGraphNode.d.ts +6 -1
- package/dist/src/logic/createRandomGraphNode.js +17 -23
- package/dist/src/logic/createRandomGraphNode.js.map +1 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +2 -0
- package/dist/src/logic/formStreamPartDeliveryServiceId.js +8 -0
- package/dist/src/logic/formStreamPartDeliveryServiceId.js.map +1 -0
- package/dist/src/logic/inspect/Inspector.d.ts +3 -2
- package/dist/src/logic/inspect/Inspector.js +5 -5
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/{HandshakerServer.d.ts → HandshakeRpcLocal.d.ts} +10 -10
- package/dist/src/logic/neighbor-discovery/{HandshakerServer.js → HandshakeRpcLocal.js} +13 -13
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/{RemoteHandshaker.d.ts → HandshakeRpcRemote.d.ts} +1 -1
- package/dist/src/logic/neighbor-discovery/{RemoteHandshaker.js → HandshakeRpcRemote.js} +8 -7
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +8 -7
- package/dist/src/logic/neighbor-discovery/Handshaker.js +23 -24
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +3 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +5 -5
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.d.ts → NeighborUpdateRpcLocal.d.ts} +6 -6
- package/dist/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.js → NeighborUpdateRpcLocal.js} +9 -9
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -0
- package/dist/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.d.ts → NeighborUpdateRpcRemote.d.ts} +1 -1
- package/dist/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.js → NeighborUpdateRpcRemote.js} +5 -5
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -0
- package/dist/src/logic/propagation/Propagation.js +2 -2
- package/dist/src/logic/propagation/Propagation.js.map +1 -1
- package/dist/src/logic/proxy/{ProxyStreamConnectionClient.d.ts → ProxyClient.d.ts} +6 -9
- package/dist/src/logic/proxy/{ProxyStreamConnectionClient.js → ProxyClient.js} +23 -21
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -0
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.d.ts → ProxyConnectionRpcLocal.d.ts} +5 -5
- package/dist/src/logic/proxy/{ProxyStreamConnectionServer.js → ProxyConnectionRpcLocal.js} +6 -6
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -0
- package/dist/src/logic/proxy/{RemoteProxyServer.d.ts → ProxyConnectionRpcRemote.d.ts} +1 -1
- package/dist/src/logic/proxy/{RemoteProxyServer.js → ProxyConnectionRpcRemote.js} +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -0
- package/dist/src/logic/temporary-connection/{TemporaryConnectionRpcServer.d.ts → TemporaryConnectionRpcLocal.d.ts} +5 -4
- package/dist/src/logic/temporary-connection/{TemporaryConnectionRpcServer.js → TemporaryConnectionRpcLocal.js} +6 -6
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -0
- package/dist/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.d.ts → TemporaryConnectionRpcRemote.d.ts} +1 -1
- package/dist/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.js → TemporaryConnectionRpcRemote.js} +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +0 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +1 -2
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +7 -7
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.d.ts +10 -10
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +7 -7
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.d.ts +2 -2
- package/dist/test/benchmark/first-message.js +10 -13
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +5 -5
- package/dist/test/utils/utils.js +14 -13
- package/dist/test/utils/utils.js.map +1 -1
- package/package.json +10 -8
- package/protos/NetworkRpc.proto +5 -5
- package/src/NetworkNode.ts +1 -1
- package/src/NetworkStack.ts +20 -62
- package/src/identifiers.ts +3 -3
- package/src/logic/{StreamNodeServer.ts → DeliveryRpcLocal.ts} +8 -7
- package/src/logic/{RemoteRandomGraphNode.ts → DeliveryRpcRemote.ts} +3 -3
- package/src/logic/{StreamPartEntryPointDiscovery.ts → EntryPointDiscovery.ts} +18 -42
- package/src/logic/ILayer0.ts +3 -6
- package/src/logic/NodeList.ts +12 -12
- package/src/logic/RandomGraphNode.ts +61 -62
- package/src/logic/StreamrNode.ts +59 -73
- package/src/logic/createRandomGraphNode.ts +28 -26
- package/src/logic/formStreamPartDeliveryServiceId.ts +5 -0
- package/src/logic/inspect/Inspector.ts +8 -7
- package/src/logic/neighbor-discovery/{HandshakerServer.ts → HandshakeRpcLocal.ts} +20 -20
- package/src/logic/neighbor-discovery/{RemoteHandshaker.ts → HandshakeRpcRemote.ts} +6 -5
- package/src/logic/neighbor-discovery/Handshaker.ts +38 -38
- package/src/logic/neighbor-discovery/NeighborFinder.ts +2 -2
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +13 -10
- package/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.ts → NeighborUpdateRpcLocal.ts} +15 -15
- package/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.ts → NeighborUpdateRpcRemote.ts} +2 -2
- package/src/logic/propagation/Propagation.ts +2 -2
- package/src/logic/proxy/{ProxyStreamConnectionClient.ts → ProxyClient.ts} +27 -27
- package/src/logic/proxy/{ProxyStreamConnectionServer.ts → ProxyConnectionRpcLocal.ts} +10 -11
- package/src/logic/proxy/{RemoteProxyServer.ts → ProxyConnectionRpcRemote.ts} +1 -1
- package/src/logic/temporary-connection/{TemporaryConnectionRpcServer.ts → TemporaryConnectionRpcLocal.ts} +11 -10
- package/src/logic/temporary-connection/{RemoteTemporaryConnectionRpcServer.ts → TemporaryConnectionRpcRemote.ts} +1 -1
- package/src/proto/packages/dht/protos/DhtRpc.ts +1 -6
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +8 -8
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +2 -2
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +14 -14
- package/test/benchmark/first-message.ts +10 -13
- package/test/end-to-end/inspect.test.ts +12 -12
- package/test/end-to-end/proxy-and-full-node.test.ts +13 -14
- package/test/end-to-end/proxy-connections.test.ts +9 -11
- package/test/end-to-end/proxy-key-exchange.test.ts +12 -13
- package/test/end-to-end/random-graph-with-real-connections.test.ts +7 -7
- package/test/end-to-end/webrtc-full-node-network.test.ts +8 -8
- package/test/end-to-end/websocket-full-node-network.test.ts +8 -10
- package/test/integration/{RemoteRandomGraphNode.test.ts → DeliveryRpcRemote.test.ts} +17 -14
- package/test/integration/{RemoteHandshaker.test.ts → HandshakeRpcRemote.test.ts} +10 -9
- package/test/integration/Handshakes.test.ts +23 -20
- package/test/integration/Inspect.test.ts +3 -2
- package/test/integration/{RemoteNeighborUpdateManager.test.ts → NeighborUpdateRpcRemote.test.ts} +12 -10
- package/test/integration/NetworkNode.test.ts +9 -8
- package/test/integration/NetworkRpc.test.ts +5 -7
- package/test/integration/NetworkStack.test.ts +13 -15
- package/test/integration/Propagation.test.ts +2 -2
- package/test/integration/RandomGraphNode-Layer1Node-Latencies.test.ts +10 -8
- package/test/integration/RandomGraphNode-Layer1Node.test.ts +17 -17
- package/test/integration/StreamrNode.test.ts +5 -3
- package/test/integration/joining-streams-on-offline-peers.test.ts +16 -18
- package/test/integration/stream-without-default-entrypoints.test.ts +11 -13
- package/test/unit/{StreamNodeServer.test.ts → DeliveryRpcLocal.test.ts} +8 -8
- package/test/unit/{StreamPartEntrypointDiscovery.test.ts → EntrypointDiscovery.test.ts} +23 -40
- package/test/unit/{HandshakerServer.test.ts → HandshakeRpcLocal.test.ts} +26 -24
- package/test/unit/Handshaker.test.ts +10 -8
- package/test/unit/Inspector.test.ts +4 -3
- package/test/unit/NeighborFinder.test.ts +5 -5
- package/test/unit/NodeList.test.ts +22 -13
- package/test/unit/{RemoteProxyServer.test.ts → ProxyConnectionRpcRemote.test.ts} +4 -4
- package/test/unit/RandomGraphNode.test.ts +6 -5
- package/test/unit/StreamMessageTranslator.test.ts +10 -9
- package/test/unit/StreamrNode.test.ts +8 -8
- package/test/utils/mock/MockLayer0.ts +7 -26
- package/test/utils/mock/MockLayer1.ts +3 -8
- package/test/utils/mock/MockNeighborFinder.ts +1 -2
- package/test/utils/mock/MockNeighborUpdateManager.ts +1 -2
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +13 -12
- package/dist/src/logic/RemoteRandomGraphNode.js.map +0 -1
- package/dist/src/logic/StreamPartEntryPointDiscovery.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/HandshakerServer.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManagerServer.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/RemoteHandshaker.js.map +0 -1
- package/dist/src/logic/neighbor-discovery/RemoteNeighborUpdateManager.js.map +0 -1
- package/dist/src/logic/proxy/ProxyStreamConnectionClient.js.map +0 -1
- package/dist/src/logic/proxy/ProxyStreamConnectionServer.js.map +0 -1
- package/dist/src/logic/proxy/RemoteProxyServer.js.map +0 -1
- package/dist/src/logic/temporary-connection/RemoteTemporaryConnectionRpcServer.js.map +0 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcServer.js.map +0 -1
package/src/logic/neighbor-discovery/{NeighborUpdateManagerServer.ts → NeighborUpdateRpcLocal.ts}
RENAMED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
|
-
import { DhtCallContext, ListeningRpcCommunicator } from '@streamr/dht'
|
|
3
|
-
import { PeerDescriptor } from '@streamr/dht/src/exports'
|
|
2
|
+
import { DhtCallContext, ListeningRpcCommunicator, PeerDescriptor } from '@streamr/dht'
|
|
4
3
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
5
4
|
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
6
5
|
import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
|
-
import {
|
|
6
|
+
import { DeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
8
7
|
import { INeighborUpdateRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
9
8
|
import { NodeList } from '../NodeList'
|
|
10
|
-
import {
|
|
9
|
+
import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
|
|
11
10
|
import { INeighborFinder } from './NeighborFinder'
|
|
11
|
+
import { StreamPartID } from '@streamr/protocol'
|
|
12
12
|
|
|
13
|
-
interface
|
|
13
|
+
interface NeighborUpdateRpcLocalConfig {
|
|
14
14
|
ownPeerDescriptor: PeerDescriptor
|
|
15
|
-
|
|
15
|
+
streamPartId: StreamPartID
|
|
16
16
|
targetNeighbors: NodeList
|
|
17
17
|
nearbyNodeView: NodeList
|
|
18
18
|
neighborFinder: INeighborFinder
|
|
19
19
|
rpcCommunicator: ListeningRpcCommunicator
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export class
|
|
22
|
+
export class NeighborUpdateRpcLocal implements INeighborUpdateRpc {
|
|
23
23
|
|
|
24
|
-
private readonly config:
|
|
24
|
+
private readonly config: NeighborUpdateRpcLocalConfig
|
|
25
25
|
|
|
26
|
-
constructor(config:
|
|
26
|
+
constructor(config: NeighborUpdateRpcLocalConfig) {
|
|
27
27
|
this.config = config
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
//
|
|
30
|
+
// INeighborUpdateRpc server method
|
|
31
31
|
async neighborUpdate(message: NeighborUpdate, context: ServerCallContext): Promise<NeighborUpdate> {
|
|
32
32
|
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
33
33
|
const senderId = getNodeIdFromPeerDescriptor(senderPeerDescriptor)
|
|
@@ -39,23 +39,23 @@ export class NeighborUpdateManagerServer implements INeighborUpdateRpc {
|
|
|
39
39
|
return nodeId !== ownNodeId && !this.config.targetNeighbors.getIds().includes(nodeId)
|
|
40
40
|
})
|
|
41
41
|
newPeerDescriptors.forEach((peerDescriptor) => this.config.nearbyNodeView.add(
|
|
42
|
-
new
|
|
42
|
+
new DeliveryRpcRemote(
|
|
43
43
|
this.config.ownPeerDescriptor,
|
|
44
44
|
peerDescriptor,
|
|
45
|
-
this.config.
|
|
46
|
-
toProtoRpcClient(new
|
|
45
|
+
this.config.streamPartId,
|
|
46
|
+
toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport()))
|
|
47
47
|
))
|
|
48
48
|
)
|
|
49
49
|
this.config.neighborFinder.start()
|
|
50
50
|
const response: NeighborUpdate = {
|
|
51
|
-
|
|
51
|
+
streamPartId: this.config.streamPartId,
|
|
52
52
|
neighborDescriptors: this.config.targetNeighbors.getAll().map((neighbor) => neighbor.getPeerDescriptor()),
|
|
53
53
|
removeMe: false
|
|
54
54
|
}
|
|
55
55
|
return response
|
|
56
56
|
} else {
|
|
57
57
|
const response: NeighborUpdate = {
|
|
58
|
-
|
|
58
|
+
streamPartId: this.config.streamPartId,
|
|
59
59
|
neighborDescriptors: this.config.targetNeighbors.getAll().map((neighbor) => neighbor.getPeerDescriptor()),
|
|
60
60
|
removeMe: true
|
|
61
61
|
}
|
package/src/logic/neighbor-discovery/{RemoteNeighborUpdateManager.ts → NeighborUpdateRpcRemote.ts}
RENAMED
|
@@ -11,11 +11,11 @@ interface UpdateNeighborsResponse {
|
|
|
11
11
|
removeMe: boolean
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class
|
|
14
|
+
export class NeighborUpdateRpcRemote extends Remote<INeighborUpdateRpcClient> {
|
|
15
15
|
|
|
16
16
|
async updateNeighbors(neighbors: PeerDescriptor[]): Promise<UpdateNeighborsResponse> {
|
|
17
17
|
const request: NeighborUpdate = {
|
|
18
|
-
|
|
18
|
+
streamPartId: this.getServiceId(),
|
|
19
19
|
neighborDescriptors: neighbors,
|
|
20
20
|
removeMe: false
|
|
21
21
|
}
|
|
@@ -57,8 +57,8 @@ export class Propagation {
|
|
|
57
57
|
* Node should invoke this when it learns about a new node stream assignment
|
|
58
58
|
*/
|
|
59
59
|
onNeighborJoined(neighborId: NodeID): void {
|
|
60
|
-
const
|
|
61
|
-
for (const task of
|
|
60
|
+
const tasks = this.activeTaskStore.get()
|
|
61
|
+
for (const task of tasks) {
|
|
62
62
|
this.sendAndAwaitThenMark(task, neighborId)
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ConnectionLocker,
|
|
2
3
|
ITransport,
|
|
3
4
|
ListeningRpcCommunicator,
|
|
4
5
|
PeerDescriptor
|
|
5
6
|
} from '@streamr/dht'
|
|
6
|
-
import { ConnectionLocker } from '@streamr/dht/src/exports'
|
|
7
7
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
8
8
|
import { StreamPartID } from '@streamr/protocol'
|
|
9
9
|
import { EthereumAddress, Logger, addManagedEventListener, wait } from '@streamr/utils'
|
|
@@ -17,14 +17,15 @@ import {
|
|
|
17
17
|
ProxyDirection,
|
|
18
18
|
StreamMessage
|
|
19
19
|
} from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
20
|
-
import {
|
|
20
|
+
import { DeliveryRpcClient, ProxyConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
21
21
|
import { DuplicateMessageDetector } from '../DuplicateMessageDetector'
|
|
22
22
|
import { NodeList } from '../NodeList'
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
23
|
+
import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
|
|
24
|
+
import { DeliveryRpcLocal } from '../DeliveryRpcLocal'
|
|
25
25
|
import { Propagation } from '../propagation/Propagation'
|
|
26
26
|
import { markAndCheckDuplicate } from '../utils'
|
|
27
|
-
import {
|
|
27
|
+
import { ProxyConnectionRpcRemote } from './ProxyConnectionRpcRemote'
|
|
28
|
+
import { formStreamPartDeliveryServiceId } from '../formStreamPartDeliveryServiceId'
|
|
28
29
|
|
|
29
30
|
export const retry = async <T>(task: () => Promise<T>, description: string, abortSignal: AbortSignal, delay = 10000): Promise<T> => {
|
|
30
31
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -41,13 +42,11 @@ export const retry = async <T>(task: () => Promise<T>, description: string, abor
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
interface
|
|
45
|
+
interface ProxyClientConfig {
|
|
45
46
|
P2PTransport: ITransport
|
|
46
47
|
ownPeerDescriptor: PeerDescriptor
|
|
47
48
|
streamPartId: StreamPartID
|
|
48
49
|
connectionLocker: ConnectionLocker
|
|
49
|
-
userId: EthereumAddress
|
|
50
|
-
nodeName?: string
|
|
51
50
|
minPropagationTargets?: number // TODO could be required option if we apply all defaults somewhere at higher level
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -60,11 +59,13 @@ interface ProxyDefinition {
|
|
|
60
59
|
|
|
61
60
|
const logger = new Logger(module)
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
const SERVICE_ID = 'system/proxy-client'
|
|
63
|
+
|
|
64
|
+
export class ProxyClient extends EventEmitter {
|
|
64
65
|
|
|
65
66
|
private readonly rpcCommunicator: ListeningRpcCommunicator
|
|
66
|
-
private readonly
|
|
67
|
-
private readonly config:
|
|
67
|
+
private readonly deliveryRpcLocal: DeliveryRpcLocal
|
|
68
|
+
private readonly config: ProxyClientConfig
|
|
68
69
|
private readonly duplicateDetectors: Map<string, DuplicateMessageDetector> = new Map()
|
|
69
70
|
private definition?: ProxyDefinition
|
|
70
71
|
private readonly connections: Map<NodeID, ProxyDirection> = new Map()
|
|
@@ -72,14 +73,14 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
72
73
|
private readonly targetNeighbors: NodeList
|
|
73
74
|
private readonly abortController: AbortController
|
|
74
75
|
|
|
75
|
-
constructor(config:
|
|
76
|
+
constructor(config: ProxyClientConfig) {
|
|
76
77
|
super()
|
|
77
78
|
this.config = config
|
|
78
|
-
this.rpcCommunicator = new ListeningRpcCommunicator(
|
|
79
|
+
this.rpcCommunicator = new ListeningRpcCommunicator(formStreamPartDeliveryServiceId(config.streamPartId), config.P2PTransport)
|
|
79
80
|
this.targetNeighbors = new NodeList(getNodeIdFromPeerDescriptor(this.config.ownPeerDescriptor), 1000)
|
|
80
|
-
this.
|
|
81
|
+
this.deliveryRpcLocal = new DeliveryRpcLocal({
|
|
81
82
|
ownPeerDescriptor: this.config.ownPeerDescriptor,
|
|
82
|
-
|
|
83
|
+
streamPartId: this.config.streamPartId,
|
|
83
84
|
markAndCheckDuplicate: (msg: MessageID, prev?: MessageRef) => markAndCheckDuplicate(this.duplicateDetectors, msg, prev),
|
|
84
85
|
broadcast: (message: StreamMessage, previousNode?: NodeID) => this.broadcast(message, previousNode),
|
|
85
86
|
onLeaveNotice: (senderId: NodeID) => {
|
|
@@ -89,7 +90,7 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
89
90
|
}
|
|
90
91
|
},
|
|
91
92
|
rpcCommunicator: this.rpcCommunicator,
|
|
92
|
-
markForInspection: (
|
|
93
|
+
markForInspection: () => {}
|
|
93
94
|
})
|
|
94
95
|
this.propagation = new Propagation({
|
|
95
96
|
minPropagationTargets: config.minPropagationTargets ?? 2,
|
|
@@ -107,19 +108,18 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
107
108
|
|
|
108
109
|
private registerDefaultServerMethods(): void {
|
|
109
110
|
this.rpcCommunicator.registerRpcNotification(StreamMessage, 'sendStreamMessage',
|
|
110
|
-
(msg: StreamMessage, context) => this.
|
|
111
|
+
(msg: StreamMessage, context) => this.deliveryRpcLocal.sendStreamMessage(msg, context))
|
|
111
112
|
this.rpcCommunicator.registerRpcNotification(LeaveStreamPartNotice, 'leaveStreamPartNotice',
|
|
112
|
-
(req: LeaveStreamPartNotice, context) => this.
|
|
113
|
+
(req: LeaveStreamPartNotice, context) => this.deliveryRpcLocal.leaveStreamPartNotice(req, context))
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
async setProxies(
|
|
116
|
-
streamPartId: StreamPartID,
|
|
117
117
|
nodes: PeerDescriptor[],
|
|
118
118
|
direction: ProxyDirection,
|
|
119
119
|
userId: EthereumAddress,
|
|
120
120
|
connectionCount?: number
|
|
121
121
|
): Promise<void> {
|
|
122
|
-
logger.trace('Setting proxies', { streamPartId, peerDescriptors: nodes, direction, userId, connectionCount })
|
|
122
|
+
logger.trace('Setting proxies', { streamPartId: this.config.streamPartId, peerDescriptors: nodes, direction, userId, connectionCount })
|
|
123
123
|
if (connectionCount !== undefined && connectionCount > nodes.length) {
|
|
124
124
|
throw Error('Cannot set connectionCount above the size of the configured array of nodes')
|
|
125
125
|
}
|
|
@@ -167,16 +167,16 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
167
167
|
private async attemptConnection(nodeId: NodeID, direction: ProxyDirection, userId: EthereumAddress): Promise<void> {
|
|
168
168
|
const peerDescriptor = this.definition!.nodes.get(nodeId)!
|
|
169
169
|
const client = toProtoRpcClient(new ProxyConnectionRpcClient(this.rpcCommunicator.getRpcClientTransport()))
|
|
170
|
-
const
|
|
171
|
-
const accepted = await
|
|
170
|
+
const rpcRemote = new ProxyConnectionRpcRemote(this.config.ownPeerDescriptor, peerDescriptor, this.config.streamPartId, client)
|
|
171
|
+
const accepted = await rpcRemote.requestConnection(direction, userId)
|
|
172
172
|
if (accepted) {
|
|
173
|
-
this.config.connectionLocker.lockConnection(peerDescriptor,
|
|
173
|
+
this.config.connectionLocker.lockConnection(peerDescriptor, SERVICE_ID)
|
|
174
174
|
this.connections.set(nodeId, direction)
|
|
175
|
-
const remote = new
|
|
175
|
+
const remote = new DeliveryRpcRemote(
|
|
176
176
|
this.config.ownPeerDescriptor,
|
|
177
177
|
peerDescriptor,
|
|
178
178
|
this.config.streamPartId,
|
|
179
|
-
toProtoRpcClient(new
|
|
179
|
+
toProtoRpcClient(new DeliveryRpcClient(this.rpcCommunicator.getRpcClientTransport()))
|
|
180
180
|
)
|
|
181
181
|
this.targetNeighbors.add(remote)
|
|
182
182
|
this.propagation.onNeighborJoined(nodeId)
|
|
@@ -232,7 +232,7 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
232
232
|
private async onNodeDisconnected(peerDescriptor: PeerDescriptor): Promise<void> {
|
|
233
233
|
const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
|
|
234
234
|
if (this.connections.has(nodeId)) {
|
|
235
|
-
this.config.connectionLocker.unlockConnection(peerDescriptor,
|
|
235
|
+
this.config.connectionLocker.unlockConnection(peerDescriptor, SERVICE_ID)
|
|
236
236
|
this.removeConnection(nodeId)
|
|
237
237
|
await retry(() => this.updateConnections(), 'updating proxy connections', this.abortController.signal)
|
|
238
238
|
}
|
|
@@ -250,7 +250,7 @@ export class ProxyStreamConnectionClient extends EventEmitter {
|
|
|
250
250
|
|
|
251
251
|
stop(): void {
|
|
252
252
|
this.targetNeighbors.getAll().map((remote) => {
|
|
253
|
-
this.config.connectionLocker.unlockConnection(remote.getPeerDescriptor(),
|
|
253
|
+
this.config.connectionLocker.unlockConnection(remote.getPeerDescriptor(), SERVICE_ID)
|
|
254
254
|
remote.leaveStreamPartNotice()
|
|
255
255
|
})
|
|
256
256
|
this.targetNeighbors.stop()
|
|
@@ -8,25 +8,24 @@ import {
|
|
|
8
8
|
StreamMessageType
|
|
9
9
|
} from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
10
10
|
import { IProxyConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
11
|
-
import {
|
|
12
|
-
import { ListeningRpcCommunicator, PeerDescriptor } from '@streamr/dht'
|
|
11
|
+
import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
|
|
12
|
+
import { DhtCallContext, ListeningRpcCommunicator, PeerDescriptor } from '@streamr/dht'
|
|
13
13
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
14
|
-
import {
|
|
14
|
+
import { DeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
15
15
|
import { EventEmitter } from 'eventemitter3'
|
|
16
16
|
import { EthereumAddress, Logger, binaryToHex, toEthereumAddress } from '@streamr/utils'
|
|
17
17
|
import { StreamPartID } from '@streamr/protocol'
|
|
18
18
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
19
|
-
import { DhtCallContext } from '@streamr/dht/src/exports'
|
|
20
19
|
|
|
21
20
|
const logger = new Logger(module)
|
|
22
21
|
|
|
23
22
|
interface ProxyConnection {
|
|
24
23
|
direction: ProxyDirection // Direction is from the client's point of view
|
|
25
24
|
userId: EthereumAddress
|
|
26
|
-
remote:
|
|
25
|
+
remote: DeliveryRpcRemote
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
interface
|
|
28
|
+
interface ProxyConnectionRpcLocalConfig {
|
|
30
29
|
ownPeerDescriptor: PeerDescriptor
|
|
31
30
|
streamPartId: StreamPartID
|
|
32
31
|
rpcCommunicator: ListeningRpcCommunicator
|
|
@@ -36,12 +35,12 @@ export interface Events {
|
|
|
36
35
|
newConnection: (nodeId: NodeID) => void
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
export class
|
|
38
|
+
export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IProxyConnectionRpc {
|
|
40
39
|
|
|
41
|
-
private readonly config:
|
|
40
|
+
private readonly config: ProxyConnectionRpcLocalConfig
|
|
42
41
|
private readonly connections: Map<NodeID, ProxyConnection> = new Map()
|
|
43
42
|
|
|
44
|
-
constructor(config:
|
|
43
|
+
constructor(config: ProxyConnectionRpcLocalConfig) {
|
|
45
44
|
super()
|
|
46
45
|
this.config = config
|
|
47
46
|
this.config.rpcCommunicator.registerRpcMethod(ProxyConnectionRequest, ProxyConnectionResponse, 'requestConnection',
|
|
@@ -95,11 +94,11 @@ export class ProxyStreamConnectionServer extends EventEmitter<Events> implements
|
|
|
95
94
|
this.connections.set(senderId, {
|
|
96
95
|
direction: request.direction,
|
|
97
96
|
userId: toEthereumAddress(binaryToHex(request.userId, true)),
|
|
98
|
-
remote: new
|
|
97
|
+
remote: new DeliveryRpcRemote(
|
|
99
98
|
this.config.ownPeerDescriptor,
|
|
100
99
|
senderPeerDescriptor,
|
|
101
100
|
this.config.streamPartId,
|
|
102
|
-
toProtoRpcClient(new
|
|
101
|
+
toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport()))
|
|
103
102
|
)
|
|
104
103
|
})
|
|
105
104
|
const response: ProxyConnectionResponse = {
|
|
@@ -5,7 +5,7 @@ import { IProxyConnectionRpcClient } from '../../proto/packages/trackerless-netw
|
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
8
|
-
export class
|
|
8
|
+
export class ProxyConnectionRpcRemote extends Remote<IProxyConnectionRpcClient> {
|
|
9
9
|
|
|
10
10
|
async requestConnection(direction: ProxyDirection, userId: EthereumAddress): Promise<boolean> {
|
|
11
11
|
const request: ProxyConnectionRequest = {
|
|
@@ -2,25 +2,26 @@ import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
|
2
2
|
import { TemporaryConnectionRequest, TemporaryConnectionResponse } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
3
3
|
import { ITemporaryConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
4
4
|
import { DhtCallContext, ListeningRpcCommunicator } from '@streamr/dht'
|
|
5
|
-
import {
|
|
5
|
+
import { DeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
6
6
|
import { NodeList } from '../NodeList'
|
|
7
7
|
import { toProtoRpcClient } from '@streamr/proto-rpc'
|
|
8
|
-
import {
|
|
8
|
+
import { DeliveryRpcRemote } from '../DeliveryRpcRemote'
|
|
9
9
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
|
|
10
10
|
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
11
|
+
import { StreamPartID } from '@streamr/protocol'
|
|
11
12
|
|
|
12
|
-
interface
|
|
13
|
-
|
|
13
|
+
interface TemporaryConnectionRpcLocalConfig {
|
|
14
|
+
streamPartId: StreamPartID
|
|
14
15
|
rpcCommunicator: ListeningRpcCommunicator
|
|
15
16
|
ownPeerDescriptor: PeerDescriptor
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export class
|
|
19
|
+
export class TemporaryConnectionRpcLocal implements ITemporaryConnectionRpc {
|
|
19
20
|
|
|
20
|
-
private readonly config:
|
|
21
|
+
private readonly config: TemporaryConnectionRpcLocalConfig
|
|
21
22
|
private readonly temporaryNodes: NodeList
|
|
22
23
|
|
|
23
|
-
constructor(config:
|
|
24
|
+
constructor(config: TemporaryConnectionRpcLocalConfig) {
|
|
24
25
|
this.config = config
|
|
25
26
|
this.temporaryNodes = new NodeList(getNodeIdFromPeerDescriptor(config.ownPeerDescriptor), 10)
|
|
26
27
|
}
|
|
@@ -38,11 +39,11 @@ export class TemporaryConnectionRpcServer implements ITemporaryConnectionRpc {
|
|
|
38
39
|
context: ServerCallContext
|
|
39
40
|
): Promise<TemporaryConnectionResponse> {
|
|
40
41
|
const sender = (context as DhtCallContext).incomingSourceDescriptor!
|
|
41
|
-
const remote = new
|
|
42
|
+
const remote = new DeliveryRpcRemote(
|
|
42
43
|
this.config.ownPeerDescriptor,
|
|
43
44
|
sender,
|
|
44
|
-
this.config.
|
|
45
|
-
toProtoRpcClient(new
|
|
45
|
+
this.config.streamPartId,
|
|
46
|
+
toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport()))
|
|
46
47
|
)
|
|
47
48
|
this.temporaryNodes.add(remote)
|
|
48
49
|
return {
|
|
@@ -5,7 +5,7 @@ import { ITemporaryConnectionRpcClient } from '../../proto/packages/trackerless-
|
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
8
|
-
export class
|
|
8
|
+
export class TemporaryConnectionRpcRemote extends Remote<ITemporaryConnectionRpcClient> {
|
|
9
9
|
|
|
10
10
|
async openConnection(): Promise<boolean> {
|
|
11
11
|
try {
|
|
@@ -231,10 +231,6 @@ export interface PeerDescriptor {
|
|
|
231
231
|
* @generated from protobuf field: optional uint32 region = 7;
|
|
232
232
|
*/
|
|
233
233
|
region?: number;
|
|
234
|
-
/**
|
|
235
|
-
* @generated from protobuf field: optional string nodeName = 8;
|
|
236
|
-
*/
|
|
237
|
-
nodeName?: string;
|
|
238
234
|
}
|
|
239
235
|
/**
|
|
240
236
|
* @generated from protobuf message dht.ConnectivityMethod
|
|
@@ -972,8 +968,7 @@ class PeerDescriptor$Type extends MessageType$<PeerDescriptor> {
|
|
|
972
968
|
{ no: 4, name: "tcp", kind: "message", T: () => ConnectivityMethod },
|
|
973
969
|
{ no: 5, name: "websocket", kind: "message", T: () => ConnectivityMethod },
|
|
974
970
|
{ no: 6, name: "openInternet", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ },
|
|
975
|
-
{ no: 7, name: "region", kind: "scalar", opt: true, T: 13 /*ScalarType.UINT32*/ }
|
|
976
|
-
{ no: 8, name: "nodeName", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ }
|
|
971
|
+
{ no: 7, name: "region", kind: "scalar", opt: true, T: 13 /*ScalarType.UINT32*/ }
|
|
977
972
|
]);
|
|
978
973
|
}
|
|
979
974
|
}
|
|
@@ -15,7 +15,7 @@ import type { ProxyConnectionResponse } from "./NetworkRpc";
|
|
|
15
15
|
import type { ProxyConnectionRequest } from "./NetworkRpc";
|
|
16
16
|
import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
|
|
17
17
|
import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
18
|
-
import {
|
|
18
|
+
import { DeliveryRpc } from "./NetworkRpc";
|
|
19
19
|
import type { LeaveStreamPartNotice } from "./NetworkRpc";
|
|
20
20
|
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
|
|
21
21
|
import type { Empty } from "../../../google/protobuf/empty";
|
|
@@ -23,9 +23,9 @@ import type { StreamMessage } from "./NetworkRpc";
|
|
|
23
23
|
import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
24
24
|
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
|
|
25
25
|
/**
|
|
26
|
-
* @generated from protobuf service
|
|
26
|
+
* @generated from protobuf service DeliveryRpc
|
|
27
27
|
*/
|
|
28
|
-
export interface
|
|
28
|
+
export interface IDeliveryRpcClient {
|
|
29
29
|
/**
|
|
30
30
|
* @generated from protobuf rpc: sendStreamMessage(StreamMessage) returns (google.protobuf.Empty);
|
|
31
31
|
*/
|
|
@@ -36,12 +36,12 @@ export interface INetworkRpcClient {
|
|
|
36
36
|
leaveStreamPartNotice(input: LeaveStreamPartNotice, options?: RpcOptions): UnaryCall<LeaveStreamPartNotice, Empty>;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* @generated from protobuf service
|
|
39
|
+
* @generated from protobuf service DeliveryRpc
|
|
40
40
|
*/
|
|
41
|
-
export class
|
|
42
|
-
typeName =
|
|
43
|
-
methods =
|
|
44
|
-
options =
|
|
41
|
+
export class DeliveryRpcClient implements IDeliveryRpcClient, ServiceInfo {
|
|
42
|
+
typeName = DeliveryRpc.typeName;
|
|
43
|
+
methods = DeliveryRpc.methods;
|
|
44
|
+
options = DeliveryRpc.options;
|
|
45
45
|
constructor(private readonly _transport: RpcTransport) {
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -14,9 +14,9 @@ import { Empty } from "../../../google/protobuf/empty";
|
|
|
14
14
|
import { StreamMessage } from "./NetworkRpc";
|
|
15
15
|
import { ServerCallContext } from "@protobuf-ts/runtime-rpc";
|
|
16
16
|
/**
|
|
17
|
-
* @generated from protobuf service
|
|
17
|
+
* @generated from protobuf service DeliveryRpc
|
|
18
18
|
*/
|
|
19
|
-
export interface
|
|
19
|
+
export interface IDeliveryRpc<T = ServerCallContext> {
|
|
20
20
|
/**
|
|
21
21
|
* @generated from protobuf rpc: sendStreamMessage(StreamMessage) returns (google.protobuf.Empty);
|
|
22
22
|
*/
|
|
@@ -146,9 +146,9 @@ export interface GroupKey {
|
|
|
146
146
|
*/
|
|
147
147
|
export interface StreamPartHandshakeRequest {
|
|
148
148
|
/**
|
|
149
|
-
* @generated from protobuf field: string
|
|
149
|
+
* @generated from protobuf field: string streamPartId = 1;
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
streamPartId: string;
|
|
152
152
|
/**
|
|
153
153
|
* @generated from protobuf field: string requestId = 2;
|
|
154
154
|
*/
|
|
@@ -188,9 +188,9 @@ export interface StreamPartHandshakeResponse {
|
|
|
188
188
|
*/
|
|
189
189
|
export interface InterleaveNotice {
|
|
190
190
|
/**
|
|
191
|
-
* @generated from protobuf field: string
|
|
191
|
+
* @generated from protobuf field: string streamPartId = 1;
|
|
192
192
|
*/
|
|
193
|
-
|
|
193
|
+
streamPartId: string;
|
|
194
194
|
/**
|
|
195
195
|
* this is a required field but in generated NetworkRpc.ts it is incorrectly annotated as optional (NET-1082)
|
|
196
196
|
*
|
|
@@ -203,18 +203,18 @@ export interface InterleaveNotice {
|
|
|
203
203
|
*/
|
|
204
204
|
export interface LeaveStreamPartNotice {
|
|
205
205
|
/**
|
|
206
|
-
* @generated from protobuf field: string
|
|
206
|
+
* @generated from protobuf field: string streamPartId = 1;
|
|
207
207
|
*/
|
|
208
|
-
|
|
208
|
+
streamPartId: string;
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
211
211
|
* @generated from protobuf message NeighborUpdate
|
|
212
212
|
*/
|
|
213
213
|
export interface NeighborUpdate {
|
|
214
214
|
/**
|
|
215
|
-
* @generated from protobuf field: string
|
|
215
|
+
* @generated from protobuf field: string streamPartId = 1;
|
|
216
216
|
*/
|
|
217
|
-
|
|
217
|
+
streamPartId: string;
|
|
218
218
|
/**
|
|
219
219
|
* @generated from protobuf field: bool removeMe = 2;
|
|
220
220
|
*/
|
|
@@ -412,7 +412,7 @@ export const GroupKey = new GroupKey$Type();
|
|
|
412
412
|
class StreamPartHandshakeRequest$Type extends MessageType<StreamPartHandshakeRequest> {
|
|
413
413
|
constructor() {
|
|
414
414
|
super("StreamPartHandshakeRequest", [
|
|
415
|
-
{ no: 1, name: "
|
|
415
|
+
{ no: 1, name: "streamPartId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
416
416
|
{ no: 2, name: "requestId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
417
417
|
{ no: 3, name: "concurrentHandshakeTargetId", kind: "scalar", opt: true, T: 12 /*ScalarType.BYTES*/ },
|
|
418
418
|
{ no: 4, name: "neighborIds", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
|
|
@@ -442,7 +442,7 @@ export const StreamPartHandshakeResponse = new StreamPartHandshakeResponse$Type(
|
|
|
442
442
|
class InterleaveNotice$Type extends MessageType<InterleaveNotice> {
|
|
443
443
|
constructor() {
|
|
444
444
|
super("InterleaveNotice", [
|
|
445
|
-
{ no: 1, name: "
|
|
445
|
+
{ no: 1, name: "streamPartId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
446
446
|
{ no: 2, name: "interleaveTargetDescriptor", kind: "message", T: () => PeerDescriptor }
|
|
447
447
|
]);
|
|
448
448
|
}
|
|
@@ -455,7 +455,7 @@ export const InterleaveNotice = new InterleaveNotice$Type();
|
|
|
455
455
|
class LeaveStreamPartNotice$Type extends MessageType<LeaveStreamPartNotice> {
|
|
456
456
|
constructor() {
|
|
457
457
|
super("LeaveStreamPartNotice", [
|
|
458
|
-
{ no: 1, name: "
|
|
458
|
+
{ no: 1, name: "streamPartId", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
|
459
459
|
]);
|
|
460
460
|
}
|
|
461
461
|
}
|
|
@@ -467,7 +467,7 @@ export const LeaveStreamPartNotice = new LeaveStreamPartNotice$Type();
|
|
|
467
467
|
class NeighborUpdate$Type extends MessageType<NeighborUpdate> {
|
|
468
468
|
constructor() {
|
|
469
469
|
super("NeighborUpdate", [
|
|
470
|
-
{ no: 1, name: "
|
|
470
|
+
{ no: 1, name: "streamPartId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
|
471
471
|
{ no: 2, name: "removeMe", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
|
|
472
472
|
{ no: 3, name: "neighborDescriptors", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => PeerDescriptor }
|
|
473
473
|
]);
|
|
@@ -525,9 +525,9 @@ class TemporaryConnectionResponse$Type extends MessageType<TemporaryConnectionRe
|
|
|
525
525
|
*/
|
|
526
526
|
export const TemporaryConnectionResponse = new TemporaryConnectionResponse$Type();
|
|
527
527
|
/**
|
|
528
|
-
* @generated ServiceType for protobuf service
|
|
528
|
+
* @generated ServiceType for protobuf service DeliveryRpc
|
|
529
529
|
*/
|
|
530
|
-
export const
|
|
530
|
+
export const DeliveryRpc = new ServiceType("DeliveryRpc", [
|
|
531
531
|
{ name: "sendStreamMessage", options: {}, I: StreamMessage, O: Empty },
|
|
532
532
|
{ name: "leaveStreamPartNotice", options: {}, I: LeaveStreamPartNotice, O: Empty }
|
|
533
533
|
]);
|
|
@@ -4,10 +4,10 @@ import { LatencyType, Simulator, getRandomRegion } from '@streamr/dht'
|
|
|
4
4
|
import { MessageID, StreamMessage, StreamMessageType, StreamPartID, StreamPartIDUtils, toStreamID, toStreamPartID } from '@streamr/protocol'
|
|
5
5
|
import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
|
|
6
6
|
import fs from 'fs'
|
|
7
|
-
import { PeerDescriptor } from '
|
|
7
|
+
import { PeerDescriptor } from '@streamr/dht'
|
|
8
8
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
9
9
|
import { getNodeIdFromPeerDescriptor } from '../../src/identifiers'
|
|
10
|
-
import { streamPartIdToDataKey } from '../../src/logic/
|
|
10
|
+
import { streamPartIdToDataKey } from '../../src/logic/EntryPointDiscovery'
|
|
11
11
|
import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
|
|
12
12
|
import { ILayer1 } from '../../src/logic/ILayer1'
|
|
13
13
|
import { RandomGraphNode } from '../../src/logic/RandomGraphNode'
|
|
@@ -28,8 +28,7 @@ const prepareLayer0 = async () => {
|
|
|
28
28
|
nodes = []
|
|
29
29
|
simulator = new Simulator(LatencyType.REAL)
|
|
30
30
|
const peerDescriptor = createMockPeerDescriptor({
|
|
31
|
-
region: getRandomRegion()
|
|
32
|
-
nodeName: 'entrypoint'
|
|
31
|
+
region: getRandomRegion()
|
|
33
32
|
})
|
|
34
33
|
layer0Ep = peerDescriptor
|
|
35
34
|
const entryPoint = createNetworkNodeWithSimulator(peerDescriptor, simulator, [peerDescriptor])
|
|
@@ -42,8 +41,7 @@ const prepareLayer0 = async () => {
|
|
|
42
41
|
const prepareStream = async (streamId: string) => {
|
|
43
42
|
console.log('Preparing stream ')
|
|
44
43
|
const peerDescriptor = createMockPeerDescriptor({
|
|
45
|
-
region: getRandomRegion()
|
|
46
|
-
nodeName: streamId
|
|
44
|
+
region: getRandomRegion()
|
|
47
45
|
})
|
|
48
46
|
const streamPartId = toStreamPartID(toStreamID(streamId), 0)
|
|
49
47
|
const streamPublisher = createNetworkNodeWithSimulator(peerDescriptor, simulator, [layer0Ep])
|
|
@@ -61,10 +59,9 @@ const shutdownNetwork = async () => {
|
|
|
61
59
|
simulator.stop()
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
const measureJoiningTime = async (
|
|
62
|
+
const measureJoiningTime = async () => {
|
|
65
63
|
const peerDescriptor = createMockPeerDescriptor({
|
|
66
|
-
region: getRandomRegion()
|
|
67
|
-
nodeName: `${count}`
|
|
64
|
+
region: getRandomRegion()
|
|
68
65
|
})
|
|
69
66
|
console.log('starting node with id ', getNodeIdFromPeerDescriptor(peerDescriptor))
|
|
70
67
|
|
|
@@ -121,7 +118,7 @@ const run = async () => {
|
|
|
121
118
|
|
|
122
119
|
fs.writeSync(logFile, 'Network size' + '\t' + 'Time to receive first message time (ms)' + '\n')
|
|
123
120
|
for (let i = 0; i < numNodes; i++) {
|
|
124
|
-
const time = await measureJoiningTime(
|
|
121
|
+
const time = await measureJoiningTime()
|
|
125
122
|
console.log(`Time to receive first message for ${i + 1} nodes network: ${time}ms`)
|
|
126
123
|
fs.writeSync(logFile, `${i + 1}` + '\t' + `${Math.round(time)}\n`)
|
|
127
124
|
}
|
|
@@ -140,9 +137,9 @@ run().then(() => {
|
|
|
140
137
|
console.log(foundData)
|
|
141
138
|
console.log(currentNode.stack.getLayer0DhtNode().getKBucketPeers().length)
|
|
142
139
|
console.log(currentNode.stack.getLayer0DhtNode().getNumberOfConnections())
|
|
143
|
-
const
|
|
144
|
-
console.log(
|
|
145
|
-
console.log(
|
|
140
|
+
const streamPartDelivery = currentNode.stack.getStreamrNode().getStreamPartDelivery(streamParts[0])! as { layer1: ILayer1, node: RandomGraphNode }
|
|
141
|
+
console.log(streamPartDelivery.layer1.getKBucketPeers())
|
|
142
|
+
console.log(streamPartDelivery.node.getTargetNeighborIds())
|
|
146
143
|
console.log(nodes[nodes.length - 1])
|
|
147
144
|
if (publishInterval) {
|
|
148
145
|
clearInterval(publishInterval)
|