@streamr/trackerless-network 100.0.0-pretestnet.6 → 100.0.0-testnet-one.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 +7 -7
- package/dist/src/NetworkNode.d.ts +1 -0
- package/dist/src/NetworkNode.js +3 -0
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +1 -0
- package/dist/src/NetworkStack.js +3 -0
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/identifiers.js +1 -1
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/logic/DeliveryRpcRemote.d.ts +2 -2
- package/dist/src/logic/DeliveryRpcRemote.js +1 -1
- package/dist/src/logic/DeliveryRpcRemote.js.map +1 -1
- package/dist/src/logic/EntryPointDiscovery.js +6 -5
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -1
- package/dist/src/logic/Layer0Node.d.ts +1 -1
- package/dist/src/logic/Layer1Node.d.ts +2 -2
- package/dist/src/logic/RandomGraphNode.js +2 -2
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/StreamrNode.js +3 -6
- package/dist/src/logic/StreamrNode.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.js +1 -0
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +2 -0
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
- package/dist/src/logic/propagation/Propagation.js +1 -0
- package/dist/src/logic/propagation/Propagation.js.map +1 -1
- package/dist/src/logic/proxy/ProxyClient.js +5 -2
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +2 -2
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.d.ts +2 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +5 -16
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +2 -9
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +80 -95
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +67 -66
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +3 -10
- package/dist/test/benchmark/first-message.js +2 -2
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +1 -1
- package/dist/test/utils/utils.js +1 -1
- package/dist/test/utils/utils.js.map +1 -1
- package/package.json +7 -7
- package/src/NetworkNode.ts +4 -0
- package/src/NetworkStack.ts +4 -0
- package/src/identifiers.ts +1 -1
- package/src/logic/DeliveryRpcRemote.ts +2 -2
- package/src/logic/EntryPointDiscovery.ts +6 -5
- package/src/logic/Layer0Node.ts +1 -1
- package/src/logic/Layer1Node.ts +2 -2
- package/src/logic/RandomGraphNode.ts +3 -3
- package/src/logic/StreamrNode.ts +3 -6
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +2 -2
- package/src/logic/neighbor-discovery/Handshaker.ts +1 -0
- package/src/logic/neighbor-discovery/NeighborFinder.ts +2 -0
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +2 -2
- package/src/logic/propagation/Propagation.ts +1 -0
- package/src/logic/proxy/ProxyClient.ts +4 -2
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +2 -2
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +2 -2
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +6 -20
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -10
- package/src/proto/packages/dht/protos/DhtRpc.ts +103 -135
- package/test/benchmark/first-message.ts +2 -2
- package/test/end-to-end/random-graph-with-real-connections.test.ts +1 -1
- package/test/integration/DeliveryRpcRemote.test.ts +2 -2
- package/test/integration/HandshakeRpcRemote.test.ts +2 -2
- package/test/integration/Handshakes.test.ts +3 -3
- package/test/integration/NeighborUpdateRpcRemote.test.ts +3 -3
- package/test/integration/NetworkNode.test.ts +2 -2
- package/test/integration/Propagation.test.ts +1 -1
- package/test/integration/StreamrNode.test.ts +2 -2
- package/test/integration/joining-streams-on-offline-peers.test.ts +5 -5
- package/test/integration/stream-without-default-entrypoints.test.ts +1 -1
- package/test/unit/EntrypointDiscovery.test.ts +4 -4
- package/test/unit/HandshakeRpcLocal.test.ts +2 -2
- package/test/unit/NodeList.test.ts +3 -3
- package/test/unit/RandomGraphNode.test.ts +4 -2
- package/test/utils/mock/MockLayer1Node.ts +2 -2
- package/test/utils/utils.ts +2 -2
package/src/logic/StreamrNode.ts
CHANGED
|
@@ -140,12 +140,7 @@ export class StreamrNode extends EventEmitter<Events> {
|
|
|
140
140
|
layer1Node,
|
|
141
141
|
getEntryPointData: (key) => this.layer0Node!.getDataFromDht(key),
|
|
142
142
|
storeEntryPointData: (key, data) => this.layer0Node!.storeDataToDht(key, data),
|
|
143
|
-
deleteEntryPointData: async (key) =>
|
|
144
|
-
if (this.destroyed) {
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
return this.layer0Node!.deleteDataFromDht(key)
|
|
148
|
-
}
|
|
143
|
+
deleteEntryPointData: async (key: Uint8Array) => this.layer0Node!.deleteDataFromDht(key, false)
|
|
149
144
|
})
|
|
150
145
|
streamPart = {
|
|
151
146
|
proxied: false,
|
|
@@ -225,6 +220,7 @@ export class StreamrNode extends EventEmitter<Events> {
|
|
|
225
220
|
userId: EthereumAddress,
|
|
226
221
|
connectionCount?: number
|
|
227
222
|
): Promise<void> {
|
|
223
|
+
// TODO explicit default value for "acceptProxyConnections" or make it required
|
|
228
224
|
if (this.config.acceptProxyConnections) {
|
|
229
225
|
throw new Error('cannot set proxies when acceptProxyConnections=true')
|
|
230
226
|
}
|
|
@@ -313,6 +309,7 @@ export class StreamrNode extends EventEmitter<Events> {
|
|
|
313
309
|
|
|
314
310
|
[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `uncaughtException`, `unhandledRejection`, `SIGTERM`].forEach((term) => {
|
|
315
311
|
process.on(term, async () => {
|
|
312
|
+
// TODO should we catch possible promise rejection?
|
|
316
313
|
await cleanUp()
|
|
317
314
|
process.exit()
|
|
318
315
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PeerDescriptor,
|
|
1
|
+
import { PeerDescriptor, RpcRemote } from '@streamr/dht'
|
|
2
2
|
import { Logger, hexToBinary } from '@streamr/utils'
|
|
3
3
|
import { v4 } from 'uuid'
|
|
4
4
|
import { NodeID, getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
@@ -12,7 +12,7 @@ interface HandshakeResponse {
|
|
|
12
12
|
interleaveTargetDescriptor?: PeerDescriptor
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export class HandshakeRpcRemote extends
|
|
15
|
+
export class HandshakeRpcRemote extends RpcRemote<IHandshakeRpcClient> {
|
|
16
16
|
|
|
17
17
|
async handshake(
|
|
18
18
|
neighborIds: NodeID[],
|
|
@@ -98,6 +98,7 @@ export class Handshaker implements IHandshaker {
|
|
|
98
98
|
const results = await Promise.allSettled(
|
|
99
99
|
Array.from(targets.values()).map(async (target: HandshakeRpcRemote, i) => {
|
|
100
100
|
const otherNode = i === 0 ? targets[1] : targets[0]
|
|
101
|
+
// TODO better check (currently this condition is always true)
|
|
101
102
|
const otherNodeId = otherNode ? getNodeIdFromPeerDescriptor(otherNode.getPeerDescriptor()) : undefined
|
|
102
103
|
return this.handshakeWithTarget(target, otherNodeId)
|
|
103
104
|
})
|
|
@@ -34,6 +34,7 @@ export class NeighborFinder implements INeighborFinder {
|
|
|
34
34
|
}
|
|
35
35
|
const newExcludes = await this.config.doFindNeighbors(excluded)
|
|
36
36
|
if (this.config.targetNeighbors.size() < this.config.minCount && newExcludes.length < this.config.nearbyNodeView.size()) {
|
|
37
|
+
// TODO should we catch possible promise rejection?
|
|
37
38
|
setAbortableTimeout(() => this.findNeighbors(newExcludes), INTERVAL, this.abortController.signal)
|
|
38
39
|
} else {
|
|
39
40
|
this.running = false
|
|
@@ -49,6 +50,7 @@ export class NeighborFinder implements INeighborFinder {
|
|
|
49
50
|
return
|
|
50
51
|
}
|
|
51
52
|
this.running = true
|
|
53
|
+
// TODO should we catch possible promise rejection?
|
|
52
54
|
setAbortableTimeout(() => this.findNeighbors(excluded), INITIAL_WAIT, this.abortController.signal)
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PeerDescriptor,
|
|
1
|
+
import { PeerDescriptor, RpcRemote } from '@streamr/dht'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
3
|
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
4
4
|
import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
@@ -11,7 +11,7 @@ interface UpdateNeighborsResponse {
|
|
|
11
11
|
removeMe: boolean
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export class NeighborUpdateRpcRemote extends
|
|
14
|
+
export class NeighborUpdateRpcRemote extends RpcRemote<INeighborUpdateRpcClient> {
|
|
15
15
|
|
|
16
16
|
async updateNeighbors(neighbors: PeerDescriptor[]): Promise<UpdateNeighborsResponse> {
|
|
17
17
|
const request: NeighborUpdate = {
|
|
@@ -65,6 +65,7 @@ export class Propagation {
|
|
|
65
65
|
|
|
66
66
|
private sendAndAwaitThenMark({ message, source, handledNeighbors }: PropagationTask, neighborId: NodeID): void {
|
|
67
67
|
if (!handledNeighbors.has(neighborId) && neighborId !== source) {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
68
69
|
(async () => {
|
|
69
70
|
try {
|
|
70
71
|
await this.sendToNeighbor(neighborId, message)
|
|
@@ -86,6 +86,7 @@ export class ProxyClient extends EventEmitter {
|
|
|
86
86
|
onLeaveNotice: (senderId: NodeID) => {
|
|
87
87
|
const contact = this.targetNeighbors.get(senderId)
|
|
88
88
|
if (contact) {
|
|
89
|
+
// TODO should we catch possible promise rejection?
|
|
89
90
|
setImmediate(() => this.onNodeDisconnected(contact.getPeerDescriptor()))
|
|
90
91
|
}
|
|
91
92
|
},
|
|
@@ -121,9 +122,9 @@ export class ProxyClient extends EventEmitter {
|
|
|
121
122
|
): Promise<void> {
|
|
122
123
|
logger.trace('Setting proxies', { streamPartId: this.config.streamPartId, peerDescriptors: nodes, direction, userId, connectionCount })
|
|
123
124
|
if (connectionCount !== undefined && connectionCount > nodes.length) {
|
|
124
|
-
throw Error('Cannot set connectionCount above the size of the configured array of nodes')
|
|
125
|
+
throw new Error('Cannot set connectionCount above the size of the configured array of nodes')
|
|
125
126
|
}
|
|
126
|
-
const nodesIds = new Map()
|
|
127
|
+
const nodesIds = new Map<NodeID, PeerDescriptor>()
|
|
127
128
|
nodes.forEach((peerDescriptor) => {
|
|
128
129
|
nodesIds.set(getNodeIdFromPeerDescriptor(peerDescriptor), peerDescriptor)
|
|
129
130
|
})
|
|
@@ -243,6 +244,7 @@ export class ProxyClient extends EventEmitter {
|
|
|
243
244
|
addManagedEventListener<any, any>(
|
|
244
245
|
this.config.transport as any,
|
|
245
246
|
'disconnected',
|
|
247
|
+
// TODO should we catch possible promise rejection?
|
|
246
248
|
(peerDescriptor: PeerDescriptor) => this.onNodeDisconnected(peerDescriptor),
|
|
247
249
|
this.abortController.signal
|
|
248
250
|
)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcRemote, EXISTING_CONNECTION_TIMEOUT } from '@streamr/dht'
|
|
2
2
|
import { EthereumAddress, Logger, hexToBinary } from '@streamr/utils'
|
|
3
3
|
import { ProxyConnectionRequest, ProxyDirection } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
4
4
|
import { IProxyConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
8
|
-
export class ProxyConnectionRpcRemote extends
|
|
8
|
+
export class ProxyConnectionRpcRemote extends RpcRemote<IProxyConnectionRpcClient> {
|
|
9
9
|
|
|
10
10
|
async requestConnection(direction: ProxyDirection, userId: EthereumAddress): Promise<boolean> {
|
|
11
11
|
const request: ProxyConnectionRequest = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcRemote } from '@streamr/dht'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
3
|
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
4
4
|
import { ITemporaryConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
8
|
-
export class TemporaryConnectionRpcRemote extends
|
|
8
|
+
export class TemporaryConnectionRpcRemote extends RpcRemote<ITemporaryConnectionRpcClient> {
|
|
9
9
|
|
|
10
10
|
async openConnection(): Promise<boolean> {
|
|
11
11
|
try {
|
|
@@ -23,10 +23,7 @@ import type { WebsocketConnectionRequest } from "./DhtRpc";
|
|
|
23
23
|
import { FindSessionRpc } from "./DhtRpc";
|
|
24
24
|
import type { FindResponse } from "./DhtRpc";
|
|
25
25
|
import { StoreRpc } from "./DhtRpc";
|
|
26
|
-
import type {
|
|
27
|
-
import type { DeleteDataRequest } from "./DhtRpc";
|
|
28
|
-
import type { MigrateDataResponse } from "./DhtRpc";
|
|
29
|
-
import type { MigrateDataRequest } from "./DhtRpc";
|
|
26
|
+
import type { ReplicateDataRequest } from "./DhtRpc";
|
|
30
27
|
import type { StoreDataResponse } from "./DhtRpc";
|
|
31
28
|
import type { StoreDataRequest } from "./DhtRpc";
|
|
32
29
|
import { FindRpc } from "./DhtRpc";
|
|
@@ -165,13 +162,9 @@ export interface IStoreRpcClient {
|
|
|
165
162
|
*/
|
|
166
163
|
storeData(input: StoreDataRequest, options?: RpcOptions): UnaryCall<StoreDataRequest, StoreDataResponse>;
|
|
167
164
|
/**
|
|
168
|
-
* @generated from protobuf rpc:
|
|
165
|
+
* @generated from protobuf rpc: replicateData(dht.ReplicateDataRequest) returns (google.protobuf.Empty);
|
|
169
166
|
*/
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @generated from protobuf rpc: deleteData(dht.DeleteDataRequest) returns (dht.DeleteDataResponse);
|
|
173
|
-
*/
|
|
174
|
-
deleteData(input: DeleteDataRequest, options?: RpcOptions): UnaryCall<DeleteDataRequest, DeleteDataResponse>;
|
|
167
|
+
replicateData(input: ReplicateDataRequest, options?: RpcOptions): UnaryCall<ReplicateDataRequest, Empty>;
|
|
175
168
|
}
|
|
176
169
|
/**
|
|
177
170
|
* @generated from protobuf service dht.StoreRpc
|
|
@@ -190,18 +183,11 @@ export class StoreRpcClient implements IStoreRpcClient, ServiceInfo {
|
|
|
190
183
|
return stackIntercept<StoreDataRequest, StoreDataResponse>("unary", this._transport, method, opt, input);
|
|
191
184
|
}
|
|
192
185
|
/**
|
|
193
|
-
* @generated from protobuf rpc:
|
|
186
|
+
* @generated from protobuf rpc: replicateData(dht.ReplicateDataRequest) returns (google.protobuf.Empty);
|
|
194
187
|
*/
|
|
195
|
-
|
|
188
|
+
replicateData(input: ReplicateDataRequest, options?: RpcOptions): UnaryCall<ReplicateDataRequest, Empty> {
|
|
196
189
|
const method = this.methods[1], opt = this._transport.mergeOptions(options);
|
|
197
|
-
return stackIntercept<
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* @generated from protobuf rpc: deleteData(dht.DeleteDataRequest) returns (dht.DeleteDataResponse);
|
|
201
|
-
*/
|
|
202
|
-
deleteData(input: DeleteDataRequest, options?: RpcOptions): UnaryCall<DeleteDataRequest, DeleteDataResponse> {
|
|
203
|
-
const method = this.methods[2], opt = this._transport.mergeOptions(options);
|
|
204
|
-
return stackIntercept<DeleteDataRequest, DeleteDataResponse>("unary", this._transport, method, opt, input);
|
|
190
|
+
return stackIntercept<ReplicateDataRequest, Empty>("unary", this._transport, method, opt, input);
|
|
205
191
|
}
|
|
206
192
|
}
|
|
207
193
|
/**
|
|
@@ -17,10 +17,7 @@ import { WebrtcConnectionRequest } from "./DhtRpc";
|
|
|
17
17
|
import { WebsocketConnectionResponse } from "./DhtRpc";
|
|
18
18
|
import { WebsocketConnectionRequest } from "./DhtRpc";
|
|
19
19
|
import { FindResponse } from "./DhtRpc";
|
|
20
|
-
import {
|
|
21
|
-
import { DeleteDataRequest } from "./DhtRpc";
|
|
22
|
-
import { MigrateDataResponse } from "./DhtRpc";
|
|
23
|
-
import { MigrateDataRequest } from "./DhtRpc";
|
|
20
|
+
import { ReplicateDataRequest } from "./DhtRpc";
|
|
24
21
|
import { StoreDataResponse } from "./DhtRpc";
|
|
25
22
|
import { StoreDataRequest } from "./DhtRpc";
|
|
26
23
|
import { RouteMessageAck } from "./DhtRpc";
|
|
@@ -80,13 +77,9 @@ export interface IStoreRpc<T = ServerCallContext> {
|
|
|
80
77
|
*/
|
|
81
78
|
storeData(request: StoreDataRequest, context: T): Promise<StoreDataResponse>;
|
|
82
79
|
/**
|
|
83
|
-
* @generated from protobuf rpc:
|
|
80
|
+
* @generated from protobuf rpc: replicateData(dht.ReplicateDataRequest) returns (google.protobuf.Empty);
|
|
84
81
|
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @generated from protobuf rpc: deleteData(dht.DeleteDataRequest) returns (dht.DeleteDataResponse);
|
|
88
|
-
*/
|
|
89
|
-
deleteData(request: DeleteDataRequest, context: T): Promise<DeleteDataResponse>;
|
|
82
|
+
replicateData(request: ReplicateDataRequest, context: T): Promise<Empty>;
|
|
90
83
|
}
|
|
91
84
|
/**
|
|
92
85
|
* @generated from protobuf service dht.FindSessionRpc
|