@streamr/trackerless-network 102.0.0-beta.0 → 102.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/generated/google/protobuf/any.js.map +1 -0
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +32 -8
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +23 -7
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.d.ts +3 -3
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.js +1 -1
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.js.map +1 -0
- package/dist/generated/packages/trackerless-network/protos/NetworkRpc.server.js.map +1 -0
- package/dist/package.json +9 -10
- package/dist/src/NetworkNode.d.ts +4 -3
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +2 -2
- package/dist/src/NetworkStack.js +4 -4
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/exports.d.ts +3 -2
- package/dist/src/exports.js +3 -2
- package/dist/src/exports.js.map +1 -1
- package/dist/src/logic/ContentDeliveryLayerNode.d.ts +2 -1
- package/dist/src/logic/ContentDeliveryLayerNode.js +5 -5
- package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/ContentDeliveryManager.d.ts +2 -1
- package/dist/src/logic/ContentDeliveryManager.js +2 -1
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +2 -2
- package/dist/src/logic/ControlLayerNode.d.ts +1 -1
- package/dist/src/logic/DiscoveryLayerNode.d.ts +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js +1 -1
- package/dist/src/logic/DuplicateMessageDetector.js.map +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.d.ts +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.js +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.js.map +1 -1
- package/dist/src/logic/inspect/InspectSession.d.ts +2 -2
- package/dist/src/logic/inspect/InspectSession.js +2 -2
- package/dist/src/logic/inspect/InspectSession.js.map +1 -1
- package/dist/src/logic/inspect/Inspector.d.ts +1 -1
- package/dist/src/logic/inspect/Inspector.js +1 -1
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/Handshaker.js +2 -2
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.d.ts +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.js +1 -1
- package/dist/src/logic/node-info/NodeInfoClient.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcLocal.d.ts +2 -2
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcLocal.js.map +1 -1
- package/dist/src/logic/node-info/NodeInfoRpcRemote.d.ts +2 -2
- package/dist/src/logic/propagation/Propagation.d.ts +1 -1
- package/dist/src/logic/propagation/PropagationTaskStore.d.ts +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +1 -2
- package/dist/src/logic/proxy/ProxyClient.js +2 -3
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +2 -2
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.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/temporary-connection/TemporaryConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.d.ts +1 -1
- package/dist/src/logic/utils.d.ts +1 -1
- package/dist/src/logic/utils.js +2 -2
- package/dist/src/logic/utils.js.map +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- 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 +2 -2
- package/dist/test/utils/utils.js +5 -4
- package/dist/test/utils/utils.js.map +1 -1
- package/jest.config.ts +13 -0
- package/package.json +9 -10
- package/proto.sh +2 -2
- package/protos/NetworkRpc.proto +2 -3
- package/src/NetworkNode.ts +4 -3
- package/src/NetworkStack.ts +6 -7
- package/src/exports.ts +5 -3
- package/src/logic/ContentDeliveryLayerNode.ts +6 -6
- package/src/logic/ContentDeliveryManager.ts +4 -2
- package/src/logic/ContentDeliveryRpcLocal.ts +3 -3
- package/src/logic/ContentDeliveryRpcRemote.ts +2 -2
- package/src/logic/ControlLayerNode.ts +1 -1
- package/src/logic/DiscoveryLayerNode.ts +3 -3
- package/src/logic/DuplicateMessageDetector.ts +2 -2
- package/src/logic/PeerDescriptorStoreManager.ts +1 -1
- package/src/logic/createContentDeliveryLayerNode.ts +1 -1
- package/src/logic/inspect/InspectSession.ts +5 -4
- package/src/logic/inspect/Inspector.ts +2 -2
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +2 -2
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +2 -2
- package/src/logic/neighbor-discovery/Handshaker.ts +2 -2
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +2 -2
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +3 -3
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +2 -2
- package/src/logic/node-info/NodeInfoClient.ts +2 -2
- package/src/logic/node-info/NodeInfoRpcLocal.ts +2 -2
- package/src/logic/node-info/NodeInfoRpcRemote.ts +2 -2
- package/src/logic/propagation/Propagation.ts +1 -1
- package/src/logic/propagation/PropagationTaskStore.ts +1 -1
- package/src/logic/proxy/ProxyClient.ts +2 -3
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +6 -6
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +4 -4
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +5 -5
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +1 -1
- package/src/logic/utils.ts +4 -4
- package/src/types.ts +13 -0
- package/test/benchmark/first-message.ts +4 -2
- package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +9 -4
- package/test/end-to-end/external-network-rpc.test.ts +2 -2
- package/test/end-to-end/inspect.test.ts +4 -4
- package/test/end-to-end/proxy-and-full-node.test.ts +3 -3
- package/test/end-to-end/proxy-connections.test.ts +10 -12
- package/test/end-to-end/proxy-key-exchange.test.ts +6 -6
- package/test/end-to-end/webrtc-full-node-network.test.ts +3 -5
- package/test/end-to-end/websocket-full-node-network.test.ts +4 -6
- package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +7 -7
- package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +6 -6
- package/test/integration/ContentDeliveryManager.test.ts +17 -14
- package/test/integration/ContentDeliveryRpcRemote.test.ts +6 -6
- package/test/integration/HandshakeRpcRemote.test.ts +2 -2
- package/test/integration/Handshakes.test.ts +15 -50
- package/test/integration/NeighborUpdateRpcRemote.test.ts +2 -2
- package/test/integration/NetworkNode.test.ts +5 -5
- package/test/integration/NetworkRpc.test.ts +6 -6
- package/test/integration/NetworkStack.test.ts +2 -2
- package/test/integration/NodeInfoRpc.test.ts +3 -3
- package/test/integration/Propagation.test.ts +4 -4
- package/test/integration/joining-streams-on-offline-peers.test.ts +3 -3
- package/test/integration/stream-without-default-entrypoints.test.ts +8 -8
- package/test/integration/streamEntryPointReplacing.test.ts +3 -3
- package/test/types/global.d.ts +0 -1
- package/test/unit/ContentDeliveryLayerNode.test.ts +4 -4
- package/test/unit/ContentDeliveryManager.test.ts +5 -4
- package/test/unit/ContentDeliveryRpcLocal.test.ts +1 -1
- package/test/unit/DuplicateMessageDetector.test.ts +10 -10
- package/test/unit/ExternalNetworkRpc.test.ts +3 -3
- package/test/unit/HandshakeRpcLocal.test.ts +1 -14
- package/test/unit/InspectSession.test.ts +4 -1
- package/test/unit/Inspector.test.ts +1 -1
- package/test/unit/NeighborFinder.test.ts +2 -2
- package/test/unit/NeighborUpdateRpcLocal.test.ts +1 -1
- package/test/unit/NetworkNode.test.ts +3 -3
- package/test/unit/NodeList.test.ts +1 -1
- package/test/unit/PeerDescriptorStoreManager.test.ts +2 -2
- package/test/unit/Propagation.test.ts +4 -4
- package/test/unit/ProxyConnectionRpcRemote.test.ts +2 -2
- package/test/unit/StreamPartReconnect.test.ts +2 -2
- package/test/utils/mock/MockNeighborUpdateManager.ts +1 -1
- package/test/utils/utils.ts +6 -5
- package/tsconfig.browser.json +1 -0
- package/tsconfig.jest.json +1 -0
- package/tsconfig.node.json +1 -0
- package/.eslintignore +0 -7
- package/.eslintrc +0 -3
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +0 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.js.map +0 -1
- package/jest.config.js +0 -8
- package/src/proto/google/protobuf/any.ts +0 -326
- package/src/proto/google/protobuf/empty.ts +0 -81
- package/src/proto/google/protobuf/timestamp.ts +0 -287
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +0 -407
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +0 -160
- package/src/proto/packages/dht/protos/DhtRpc.ts +0 -1244
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +0 -108
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +0 -218
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +0 -85
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +0 -783
- /package/dist/{src/proto → generated}/google/protobuf/any.d.ts +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.client.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.client.js +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.server.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.server.js +0 -0
package/src/exports.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { NetworkNode, createNetworkNode } from './NetworkNode'
|
|
2
|
-
export { NetworkOptions, NetworkStack
|
|
2
|
+
export { NetworkOptions, NetworkStack } from './NetworkStack'
|
|
3
3
|
export { ContentDeliveryManagerOptions, streamPartIdToDataKey } from './logic/ContentDeliveryManager'
|
|
4
4
|
export {
|
|
5
5
|
ContentType,
|
|
@@ -11,6 +11,8 @@ export {
|
|
|
11
11
|
MessageRef,
|
|
12
12
|
ProxyDirection,
|
|
13
13
|
SignatureType,
|
|
14
|
-
StreamMessage
|
|
15
|
-
|
|
14
|
+
StreamMessage,
|
|
15
|
+
ControlLayerInfo
|
|
16
|
+
} from '../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
16
17
|
export { ExternalRpcClient, ExternalRpcClientClass } from './logic/ExternalNetworkRpc'
|
|
18
|
+
export { NodeInfo, StreamPartitionInfo, ContentDeliveryLayerNeighborInfo } from './types'
|
|
@@ -10,15 +10,14 @@ import { Logger, StreamPartID, addManagedEventListener } from '@streamr/utils'
|
|
|
10
10
|
import { EventEmitter } from 'eventemitter3'
|
|
11
11
|
import {
|
|
12
12
|
CloseTemporaryConnection,
|
|
13
|
-
ContentDeliveryLayerNeighborInfo,
|
|
14
13
|
LeaveStreamPartNotice,
|
|
15
14
|
MessageID,
|
|
16
15
|
MessageRef,
|
|
17
16
|
StreamMessage,
|
|
18
17
|
TemporaryConnectionRequest,
|
|
19
18
|
TemporaryConnectionResponse,
|
|
20
|
-
} from '
|
|
21
|
-
import { ContentDeliveryRpcClient } from '
|
|
19
|
+
} from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
20
|
+
import { ContentDeliveryRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
22
21
|
import { ContentDeliveryRpcLocal } from './ContentDeliveryRpcLocal'
|
|
23
22
|
import { ContentDeliveryRpcRemote } from './ContentDeliveryRpcRemote'
|
|
24
23
|
import { DiscoveryLayerNode } from './DiscoveryLayerNode'
|
|
@@ -32,6 +31,7 @@ import { Propagation } from './propagation/Propagation'
|
|
|
32
31
|
import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
|
|
33
32
|
import { TemporaryConnectionRpcLocal } from './temporary-connection/TemporaryConnectionRpcLocal'
|
|
34
33
|
import { markAndCheckDuplicate } from './utils'
|
|
34
|
+
import { ContentDeliveryLayerNeighborInfo } from '../types'
|
|
35
35
|
|
|
36
36
|
export interface Events {
|
|
37
37
|
message: (message: StreamMessage) => void
|
|
@@ -93,9 +93,9 @@ export class ContentDeliveryLayerNode extends EventEmitter<Events> {
|
|
|
93
93
|
return
|
|
94
94
|
}
|
|
95
95
|
const contact = this.options.nearbyNodeView.get(remoteNodeId)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
?? this.options.randomNodeView.get(remoteNodeId)
|
|
97
|
+
?? this.options.neighbors.get(remoteNodeId)
|
|
98
|
+
?? this.options.proxyConnectionRpcLocal?.getConnection(remoteNodeId)?.remote
|
|
99
99
|
// TODO: check integrity of notifier?
|
|
100
100
|
if (contact) {
|
|
101
101
|
this.options.discoveryLayerNode.removeContact(remoteNodeId)
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { createHash } from 'crypto'
|
|
21
21
|
import { EventEmitter } from 'eventemitter3'
|
|
22
22
|
import { sampleSize } from 'lodash'
|
|
23
|
-
import { ProxyDirection, StreamMessage
|
|
23
|
+
import { ProxyDirection, StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
24
24
|
import { ContentDeliveryLayerNode } from './ContentDeliveryLayerNode'
|
|
25
25
|
import { ControlLayerNode } from './ControlLayerNode'
|
|
26
26
|
import { DiscoveryLayerNode } from './DiscoveryLayerNode'
|
|
@@ -30,6 +30,7 @@ import { StreamPartReconnect } from './StreamPartReconnect'
|
|
|
30
30
|
import { createContentDeliveryLayerNode } from './createContentDeliveryLayerNode'
|
|
31
31
|
import { ProxyClient } from './proxy/ProxyClient'
|
|
32
32
|
import { ConnectionManager } from '@streamr/dht/src/exports'
|
|
33
|
+
import { StreamPartitionInfo } from '../types'
|
|
33
34
|
|
|
34
35
|
export type StreamPartDelivery = {
|
|
35
36
|
broadcast: (msg: StreamMessage) => void
|
|
@@ -250,7 +251,8 @@ export class ContentDeliveryManager extends EventEmitter<Events> {
|
|
|
250
251
|
rpcRequestTimeout: EXISTING_CONNECTION_TIMEOUT,
|
|
251
252
|
dhtJoinTimeout: 20000, // TODO use options option or named constant?
|
|
252
253
|
periodicallyPingNeighbors: true,
|
|
253
|
-
periodicallyPingRingContacts: true
|
|
254
|
+
periodicallyPingRingContacts: true,
|
|
255
|
+
neighborPingLimit: 16
|
|
254
256
|
})
|
|
255
257
|
}
|
|
256
258
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, toNodeId } from '@streamr/dht'
|
|
3
3
|
import { StreamPartID } from '@streamr/utils'
|
|
4
|
-
import { Empty } from '
|
|
4
|
+
import { Empty } from '../../generated/google/protobuf/empty'
|
|
5
5
|
import {
|
|
6
6
|
LeaveStreamPartNotice,
|
|
7
7
|
MessageID,
|
|
8
8
|
MessageRef,
|
|
9
9
|
StreamMessage
|
|
10
|
-
} from '
|
|
11
|
-
import { IContentDeliveryRpc } from '
|
|
10
|
+
} from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
11
|
+
import { IContentDeliveryRpc } from '../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
12
12
|
|
|
13
13
|
export interface ContentDeliveryRpcLocalOptions {
|
|
14
14
|
localPeerDescriptor: PeerDescriptor
|
|
@@ -3,8 +3,8 @@ import { Logger, StreamPartID } from '@streamr/utils'
|
|
|
3
3
|
import {
|
|
4
4
|
LeaveStreamPartNotice,
|
|
5
5
|
StreamMessage
|
|
6
|
-
} from '
|
|
7
|
-
import { ContentDeliveryRpcClient } from '
|
|
6
|
+
} from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
7
|
+
import { ContentDeliveryRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
8
8
|
|
|
9
9
|
const logger = new Logger(module)
|
|
10
10
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionsView, DataEntry, DhtAddress, ITransport, PeerDescriptor } from '@streamr/dht'
|
|
2
|
-
import { Any } from '
|
|
2
|
+
import { Any } from '../../generated/google/protobuf/any'
|
|
3
3
|
|
|
4
4
|
export interface ControlLayerNode extends ITransport {
|
|
5
5
|
joinDht(entryPointDescriptors: PeerDescriptor[]): Promise<void>
|
|
@@ -12,11 +12,11 @@ export interface DiscoveryLayerNodeEvents {
|
|
|
12
12
|
|
|
13
13
|
export interface DiscoveryLayerNode {
|
|
14
14
|
on<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: (peerDescriptor: PeerDescriptor) => void): void
|
|
15
|
-
once<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: (peerDescriptor: PeerDescriptor) => void): void
|
|
16
|
-
off<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: (peerDescriptor: PeerDescriptor) => void): void
|
|
17
15
|
on<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: () => void): void
|
|
18
|
-
|
|
16
|
+
off<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: (peerDescriptor: PeerDescriptor) => void): void
|
|
19
17
|
off<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: () => void): void
|
|
18
|
+
once<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: (peerDescriptor: PeerDescriptor) => void): void
|
|
19
|
+
once<T extends keyof DiscoveryLayerNodeEvents>(eventName: T, listener: () => void): void
|
|
20
20
|
removeContact: (nodeId: DhtAddress) => void
|
|
21
21
|
getClosestContacts: (maxCount?: number) => PeerDescriptor[]
|
|
22
22
|
getRandomContacts: (maxCount?: number) => PeerDescriptor[]
|
|
@@ -83,7 +83,7 @@ export class GapMisMatchError extends Error {
|
|
|
83
83
|
*/
|
|
84
84
|
export class DuplicateMessageDetector {
|
|
85
85
|
private readonly maxGapCount: number
|
|
86
|
-
private readonly gaps:
|
|
86
|
+
private readonly gaps: [NumberPair, NumberPair][]
|
|
87
87
|
|
|
88
88
|
constructor(maxGapCount = 10000) {
|
|
89
89
|
this.maxGapCount = maxGapCount
|
|
@@ -94,7 +94,7 @@ export class DuplicateMessageDetector {
|
|
|
94
94
|
* returns true if number has not yet been seen (i.e. is not a duplicate)
|
|
95
95
|
*/
|
|
96
96
|
markAndCheck(previousNumber: NumberPair | null, number: NumberPair): boolean | never {
|
|
97
|
-
if (previousNumber
|
|
97
|
+
if (previousNumber?.greaterThanOrEqual(number)) {
|
|
98
98
|
throw new InvalidNumberingError()
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
areEqualPeerDescriptors
|
|
6
6
|
} from '@streamr/dht'
|
|
7
7
|
import { Logger, scheduleAtInterval } from '@streamr/utils'
|
|
8
|
-
import { Any } from '
|
|
8
|
+
import { Any } from '../../generated/google/protobuf/any'
|
|
9
9
|
|
|
10
10
|
const parsePeerDescriptor = (dataEntries: DataEntry[]): PeerDescriptor[] => {
|
|
11
11
|
return dataEntries.filter((entry) => !entry.deleted).map((entry) => Any.unpack(entry.data!, PeerDescriptor))
|
|
@@ -5,7 +5,7 @@ import { NeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManage
|
|
|
5
5
|
import { StrictContentDeliveryLayerNodeOptions, ContentDeliveryLayerNode } from './ContentDeliveryLayerNode'
|
|
6
6
|
import { NodeList } from './NodeList'
|
|
7
7
|
import { Propagation } from './propagation/Propagation'
|
|
8
|
-
import { StreamMessage } from '
|
|
8
|
+
import { StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
9
9
|
import type { MarkOptional } from 'ts-essentials'
|
|
10
10
|
import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
|
|
11
11
|
import { Inspector } from './inspect/Inspector'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EventEmitter } from 'eventemitter3'
|
|
2
|
-
import { MessageID } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
3
|
-
import { binaryToHex } from '@streamr/utils'
|
|
4
1
|
import { DhtAddress } from '@streamr/dht'
|
|
2
|
+
import { toUserId } from '@streamr/utils'
|
|
3
|
+
import { EventEmitter } from 'eventemitter3'
|
|
4
|
+
import { MessageID } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
5
5
|
|
|
6
6
|
export interface Events {
|
|
7
7
|
done: () => void
|
|
@@ -12,8 +12,9 @@ interface InspectSessionOptions {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const createMessageKey = (messageId: MessageID): string => {
|
|
15
|
-
return `${
|
|
15
|
+
return `${toUserId(messageId.publisherId)}:${messageId.messageChainId}:${messageId.timestamp}:${messageId.sequenceNumber}`
|
|
16
16
|
}
|
|
17
|
+
|
|
17
18
|
export class InspectSession extends EventEmitter<Events> {
|
|
18
19
|
|
|
19
20
|
// Boolean indicates if the message has been received by the inspected node
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectionLocker, DhtAddress, ListeningRpcCommunicator, LockID, PeerDescriptor, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { Logger, StreamPartID, waitForEvent3 } from '@streamr/utils'
|
|
3
|
-
import { MessageID } from '
|
|
4
|
-
import { TemporaryConnectionRpcClient } from '
|
|
3
|
+
import { MessageID } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { TemporaryConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
import { TemporaryConnectionRpcRemote } from '../temporary-connection/TemporaryConnectionRpcRemote'
|
|
6
6
|
import { InspectSession, Events as InspectSessionEvents } from './InspectSession'
|
|
7
7
|
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
InterleaveResponse,
|
|
14
14
|
StreamPartHandshakeRequest,
|
|
15
15
|
StreamPartHandshakeResponse
|
|
16
|
-
} from '
|
|
17
|
-
import { IHandshakeRpc } from '
|
|
16
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
17
|
+
import { IHandshakeRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
18
18
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
19
19
|
import { NodeList } from '../NodeList'
|
|
20
20
|
import { HandshakeRpcRemote } from './HandshakeRpcRemote'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DhtAddress, PeerDescriptor, RpcRemote, toNodeId, toDhtAddressRaw } from '@streamr/dht'
|
|
2
2
|
import { Logger, StreamPartID } from '@streamr/utils'
|
|
3
3
|
import { v4 } from 'uuid'
|
|
4
|
-
import { InterleaveRequest, InterleaveResponse, StreamPartHandshakeRequest } from '
|
|
5
|
-
import { HandshakeRpcClient } from '
|
|
4
|
+
import { InterleaveRequest, InterleaveResponse, StreamPartHandshakeRequest } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
5
|
+
import { HandshakeRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
6
6
|
|
|
7
7
|
const logger = new Logger(module)
|
|
8
8
|
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
InterleaveResponse,
|
|
6
6
|
StreamPartHandshakeRequest,
|
|
7
7
|
StreamPartHandshakeResponse
|
|
8
|
-
} from '
|
|
8
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
9
9
|
import {
|
|
10
10
|
ContentDeliveryRpcClient, HandshakeRpcClient
|
|
11
|
-
} from '
|
|
11
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
12
12
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
13
13
|
import { NodeList } from '../NodeList'
|
|
14
14
|
import { HandshakeRpcLocal } from './HandshakeRpcLocal'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DhtAddress, ListeningRpcCommunicator, PeerDescriptor, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { Logger, StreamPartID, scheduleAtInterval } from '@streamr/utils'
|
|
3
|
-
import { NeighborUpdate } from '
|
|
4
|
-
import { NeighborUpdateRpcClient } from '
|
|
3
|
+
import { NeighborUpdate } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { NeighborUpdateRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
import { NodeList } from '../NodeList'
|
|
6
6
|
import { NeighborFinder } from './NeighborFinder'
|
|
7
7
|
import { NeighborUpdateRpcLocal } from './NeighborUpdateRpcLocal'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, toNodeId } from '@streamr/dht'
|
|
3
3
|
import { StreamPartID } from '@streamr/utils'
|
|
4
|
-
import { NeighborUpdate } from '
|
|
5
|
-
import { ContentDeliveryRpcClient } from '
|
|
6
|
-
import { INeighborUpdateRpc } from '
|
|
4
|
+
import { NeighborUpdate } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
5
|
+
import { ContentDeliveryRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
6
|
+
import { INeighborUpdateRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
7
7
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
8
8
|
import { NodeList } from '../NodeList'
|
|
9
9
|
import { NeighborFinder } from './NeighborFinder'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PeerDescriptor, RpcRemote, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { Logger, StreamPartID } from '@streamr/utils'
|
|
3
|
-
import { NeighborUpdate } from '
|
|
4
|
-
import { NeighborUpdateRpcClient } from '
|
|
3
|
+
import { NeighborUpdate } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { NeighborUpdateRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DhtCallContext, PeerDescriptor } from '@streamr/dht'
|
|
2
2
|
import { RpcCommunicator } from '@streamr/proto-rpc'
|
|
3
|
-
import { NodeInfo } from '../../
|
|
4
|
-
import { NodeInfoRpcClient } from '
|
|
3
|
+
import { NodeInfo } from '../../types'
|
|
4
|
+
import { NodeInfoRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
import { NodeInfoRpcRemote } from './NodeInfoRpcRemote'
|
|
6
6
|
|
|
7
7
|
export class NodeInfoClient {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeInfoRequest, NodeInfoResponse } from '
|
|
2
|
-
import { INodeInfoRpc } from '
|
|
1
|
+
import { NodeInfoRequest, NodeInfoResponse } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
2
|
+
import { INodeInfoRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
3
3
|
import { NetworkStack } from '../../NetworkStack'
|
|
4
4
|
import { ListeningRpcCommunicator } from '@streamr/dht'
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeInfoResponse } from '
|
|
2
|
-
import { NodeInfoRpcClient } from '
|
|
1
|
+
import { NodeInfoResponse } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
2
|
+
import { NodeInfoRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
3
3
|
import { RpcRemote } from '@streamr/dht'
|
|
4
4
|
|
|
5
5
|
export class NodeInfoRpcRemote extends RpcRemote<NodeInfoRpcClient> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtAddress } from '@streamr/dht'
|
|
2
|
-
import { StreamMessage } from '
|
|
2
|
+
import { StreamMessage } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
3
3
|
import { PropagationTask, PropagationTaskStore } from './PropagationTaskStore'
|
|
4
4
|
|
|
5
5
|
type SendToNeighborFn = (neighborId: DhtAddress, msg: StreamMessage) => Promise<void>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtAddress } from '@streamr/dht'
|
|
2
|
-
import { MessageRef, StreamMessage } from '
|
|
2
|
+
import { MessageRef, StreamMessage } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
3
3
|
import { FifoMapWithTTL } from './FifoMapWithTTL'
|
|
4
4
|
|
|
5
5
|
export interface PropagationTask {
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
MessageRef,
|
|
16
16
|
ProxyDirection,
|
|
17
17
|
StreamMessage
|
|
18
|
-
} from '
|
|
19
|
-
import { ContentDeliveryRpcClient, ProxyConnectionRpcClient } from '
|
|
18
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
19
|
+
import { ContentDeliveryRpcClient, ProxyConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
20
20
|
import { ContentDeliveryRpcLocal } from '../ContentDeliveryRpcLocal'
|
|
21
21
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
22
22
|
import { DuplicateMessageDetector } from '../DuplicateMessageDetector'
|
|
@@ -28,7 +28,6 @@ import { ProxyConnectionRpcRemote } from './ProxyConnectionRpcRemote'
|
|
|
28
28
|
|
|
29
29
|
// TODO use options option or named constant?
|
|
30
30
|
export const retry = async <T>(task: () => Promise<T>, description: string, abortSignal: AbortSignal, delay = 10000): Promise<T> => {
|
|
31
|
-
// eslint-disable-next-line no-constant-condition
|
|
32
31
|
while (true) {
|
|
33
32
|
try {
|
|
34
33
|
const result = await task()
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, toNodeId } from '@streamr/dht'
|
|
3
|
-
import { Logger, StreamPartID,
|
|
3
|
+
import { Logger, StreamPartID, toUserId, UserID } from '@streamr/utils'
|
|
4
4
|
import { EventEmitter } from 'eventemitter3'
|
|
5
5
|
import {
|
|
6
6
|
ProxyConnectionRequest,
|
|
7
7
|
ProxyConnectionResponse,
|
|
8
8
|
ProxyDirection,
|
|
9
9
|
StreamMessage
|
|
10
|
-
} from '
|
|
11
|
-
import { ContentDeliveryRpcClient } from '
|
|
12
|
-
import { IProxyConnectionRpc } from '
|
|
10
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
11
|
+
import { ContentDeliveryRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
12
|
+
import { IProxyConnectionRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
13
13
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
14
14
|
|
|
15
15
|
const logger = new Logger(module)
|
|
@@ -64,7 +64,7 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
|
|
|
64
64
|
if (msg.body.oneofKind === 'groupKeyRequest') {
|
|
65
65
|
try {
|
|
66
66
|
const recipientId = msg.body.groupKeyRequest.recipientId
|
|
67
|
-
return this.getNodeIdsForUserId(
|
|
67
|
+
return this.getNodeIdsForUserId(toUserId(recipientId))
|
|
68
68
|
} catch (err) {
|
|
69
69
|
logger.trace(`Could not parse GroupKeyRequest`, { err })
|
|
70
70
|
return []
|
|
@@ -88,7 +88,7 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
|
|
|
88
88
|
const remoteNodeId = toNodeId(senderPeerDescriptor)
|
|
89
89
|
this.connections.set(remoteNodeId, {
|
|
90
90
|
direction: request.direction,
|
|
91
|
-
userId:
|
|
91
|
+
userId: toUserId(request.userId),
|
|
92
92
|
remote: new ContentDeliveryRpcRemote(
|
|
93
93
|
this.options.localPeerDescriptor,
|
|
94
94
|
senderPeerDescriptor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EXISTING_CONNECTION_TIMEOUT, RpcRemote } from '@streamr/dht'
|
|
2
|
-
import { Logger, UserID,
|
|
3
|
-
import { ProxyConnectionRequest, ProxyDirection } from '
|
|
4
|
-
import { ProxyConnectionRpcClient } from '
|
|
2
|
+
import { Logger, UserID, toUserIdRaw } from '@streamr/utils'
|
|
3
|
+
import { ProxyConnectionRequest, ProxyDirection } from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { ProxyConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
|
|
6
6
|
const logger = new Logger(module)
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ export class ProxyConnectionRpcRemote extends RpcRemote<ProxyConnectionRpcClient
|
|
|
10
10
|
async requestConnection(direction: ProxyDirection, userId: UserID): Promise<boolean> {
|
|
11
11
|
const request: ProxyConnectionRequest = {
|
|
12
12
|
direction,
|
|
13
|
-
userId:
|
|
13
|
+
userId: toUserIdRaw(userId)
|
|
14
14
|
}
|
|
15
15
|
const options = this.formDhtRpcOptions({
|
|
16
16
|
timeout: EXISTING_CONNECTION_TIMEOUT
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { ConnectionLocker, DhtAddress, DhtCallContext, ListeningRpcCommunicator, toNodeId } from '@streamr/dht'
|
|
3
3
|
import { StreamPartID } from '@streamr/utils'
|
|
4
|
-
import { Empty } from '
|
|
5
|
-
import { PeerDescriptor } from '
|
|
4
|
+
import { Empty } from '../../../generated/google/protobuf/empty'
|
|
5
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
6
6
|
import {
|
|
7
7
|
CloseTemporaryConnection,
|
|
8
8
|
TemporaryConnectionRequest,
|
|
9
9
|
TemporaryConnectionResponse
|
|
10
|
-
} from '
|
|
11
|
-
import { ContentDeliveryRpcClient } from '
|
|
12
|
-
import { ITemporaryConnectionRpc } from '
|
|
10
|
+
} from '../../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
11
|
+
import { ContentDeliveryRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
12
|
+
import { ITemporaryConnectionRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server'
|
|
13
13
|
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
14
14
|
import { NodeList } from '../NodeList'
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RpcRemote, toNodeId } from '@streamr/dht'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
|
-
import { TemporaryConnectionRpcClient } from '
|
|
3
|
+
import { TemporaryConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
4
4
|
|
|
5
5
|
const logger = new Logger(module)
|
|
6
6
|
|
package/src/logic/utils.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MessageID, MessageRef } from '
|
|
3
|
-
import {
|
|
1
|
+
import { toUserId } from '@streamr/utils'
|
|
2
|
+
import { MessageID, MessageRef } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
3
|
+
import { DuplicateMessageDetector, NumberPair } from './DuplicateMessageDetector'
|
|
4
4
|
|
|
5
5
|
export const markAndCheckDuplicate = (
|
|
6
6
|
duplicateDetectors: Map<string, DuplicateMessageDetector>,
|
|
7
7
|
currentMessage: MessageID,
|
|
8
8
|
previousMessageRef?: MessageRef
|
|
9
9
|
): boolean => {
|
|
10
|
-
const detectorKey = `${
|
|
10
|
+
const detectorKey = `${toUserId(currentMessage.publisherId)}-${currentMessage.messageChainId}`
|
|
11
11
|
const previousNumberPair = previousMessageRef ?
|
|
12
12
|
new NumberPair(Number(previousMessageRef.timestamp), previousMessageRef.sequenceNumber) : null
|
|
13
13
|
const currentNumberPair = new NumberPair(Number(currentMessage.timestamp), currentMessage.sequenceNumber)
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChangeFieldType } from '@streamr/utils'
|
|
2
|
+
import { MarkRequired } from 'ts-essentials'
|
|
3
|
+
import {
|
|
4
|
+
ContentDeliveryLayerNeighborInfo as ContentDeliveryLayerNeighborInfo_,
|
|
5
|
+
NodeInfoResponse,
|
|
6
|
+
StreamPartitionInfo as StreamPartitionInfo_
|
|
7
|
+
} from '../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
8
|
+
|
|
9
|
+
// These types are part of trackerless-network's public API. Therefore removing optionality from fields which are
|
|
10
|
+
// actually required. TODO: could do the same thing for other generated interfaces which are part of the public API.
|
|
11
|
+
export type ContentDeliveryLayerNeighborInfo = MarkRequired<ContentDeliveryLayerNeighborInfo_, 'peerDescriptor'>
|
|
12
|
+
export type StreamPartitionInfo = ChangeFieldType<Required<StreamPartitionInfo_>, 'contentDeliveryLayerNeighbors', ContentDeliveryLayerNeighborInfo[]>
|
|
13
|
+
export type NodeInfo = ChangeFieldType<Required<NodeInfoResponse>, 'streamPartitions', StreamPartitionInfo[]>
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
StreamPartIDUtils,
|
|
15
15
|
toStreamID,
|
|
16
16
|
toStreamPartID,
|
|
17
|
+
toUserId,
|
|
18
|
+
toUserIdRaw,
|
|
17
19
|
utf8ToBinary, waitForEvent3
|
|
18
20
|
} from '@streamr/utils'
|
|
19
21
|
import fs from 'fs'
|
|
@@ -21,7 +23,7 @@ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNo
|
|
|
21
23
|
import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
|
|
22
24
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
23
25
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
24
|
-
import { ContentType, EncryptionType, SignatureType } from '../../
|
|
26
|
+
import { ContentType, EncryptionType, SignatureType } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
25
27
|
import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
|
|
26
28
|
|
|
27
29
|
const numNodes = 10000
|
|
@@ -88,7 +90,7 @@ const measureJoiningTime = async () => {
|
|
|
88
90
|
streamPartition: 0,
|
|
89
91
|
timestamp: i,
|
|
90
92
|
sequenceNumber: Math.floor(Math.random() * 20000),
|
|
91
|
-
publisherId:
|
|
93
|
+
publisherId: toUserIdRaw(toUserId('0x2222')),
|
|
92
94
|
messageChainId: 'msgChainId'
|
|
93
95
|
},
|
|
94
96
|
body: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionManager, DhtNode, PeerDescriptor } from '@streamr/dht'
|
|
2
|
-
import { StreamPartIDUtils,
|
|
2
|
+
import { StreamPartIDUtils, until } from '@streamr/utils'
|
|
3
3
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
|
|
4
4
|
import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
|
|
5
5
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
|
|
@@ -106,10 +106,15 @@ describe('content delivery layer node with real connections', () => {
|
|
|
106
106
|
dhtNode2.stop(),
|
|
107
107
|
dhtNode3.stop(),
|
|
108
108
|
dhtNode4.stop(),
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
109
110
|
contentDeliveryLayerNode1.stop(),
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
110
112
|
contentDeliveryLayerNode2.stop(),
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
111
114
|
contentDeliveryLayerNode3.stop(),
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
112
116
|
contentDeliveryLayerNode4.stop(),
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
113
118
|
contentDeliveryLayerNode5.stop(),
|
|
114
119
|
(epDhtNode.getTransport() as ConnectionManager).stop(),
|
|
115
120
|
(dhtNode1.getTransport() as ConnectionManager).stop(),
|
|
@@ -120,7 +125,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
120
125
|
})
|
|
121
126
|
|
|
122
127
|
it('can fully connected topologies ', async () => {
|
|
123
|
-
await
|
|
128
|
+
await until(() => {
|
|
124
129
|
return contentDeliveryLayerNode1.getNeighbors().length >= 3
|
|
125
130
|
&& contentDeliveryLayerNode2.getNeighbors().length >= 3
|
|
126
131
|
&& contentDeliveryLayerNode3.getNeighbors().length >= 3
|
|
@@ -141,7 +146,7 @@ describe('content delivery layer node with real connections', () => {
|
|
|
141
146
|
contentDeliveryLayerNode4.on('message', () => receivedMessageCount += 1)
|
|
142
147
|
contentDeliveryLayerNode5.on('message', () => receivedMessageCount += 1)
|
|
143
148
|
|
|
144
|
-
await
|
|
149
|
+
await until(() => {
|
|
145
150
|
return contentDeliveryLayerNode1.getNeighbors().length >= 3
|
|
146
151
|
&& contentDeliveryLayerNode2.getNeighbors().length >= 3
|
|
147
152
|
&& contentDeliveryLayerNode3.getNeighbors().length >= 3
|
|
@@ -155,6 +160,6 @@ describe('content delivery layer node with real connections', () => {
|
|
|
155
160
|
randomUserId()
|
|
156
161
|
)
|
|
157
162
|
contentDeliveryLayerNode1.broadcast(msg)
|
|
158
|
-
await
|
|
163
|
+
await until(() => receivedMessageCount >= 4)
|
|
159
164
|
})
|
|
160
165
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NetworkNode } from '../../src/NetworkNode'
|
|
2
2
|
import { NetworkStack } from '../../src/NetworkStack'
|
|
3
|
-
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../
|
|
4
|
-
import { HandshakeRpcClient } from '../../
|
|
3
|
+
import { StreamPartHandshakeRequest, StreamPartHandshakeResponse } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
4
|
+
import { HandshakeRpcClient } from '../../generated/packages/trackerless-network/protos/NetworkRpc.client'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
|
|
7
7
|
describe('ExternalNetworkRpc', () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUserId } from '@streamr/test-utils'
|
|
2
|
-
import { StreamPartIDUtils, hexToBinary, utf8ToBinary,
|
|
2
|
+
import { StreamPartIDUtils, hexToBinary, toUserIdRaw, utf8ToBinary, until } from '@streamr/utils'
|
|
3
3
|
import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
|
|
4
|
-
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../
|
|
4
|
+
import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
5
5
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
6
|
|
|
7
7
|
const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
|
|
@@ -44,7 +44,7 @@ describe('inspect', () => {
|
|
|
44
44
|
streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
|
|
45
45
|
timestamp: 666,
|
|
46
46
|
sequenceNumber: 0,
|
|
47
|
-
publisherId:
|
|
47
|
+
publisherId: toUserIdRaw(randomUserId()),
|
|
48
48
|
messageChainId: 'msgChainId'
|
|
49
49
|
},
|
|
50
50
|
previousMessageRef: {
|
|
@@ -98,7 +98,7 @@ describe('inspect', () => {
|
|
|
98
98
|
inspectedNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
99
99
|
inspectorNode.stack.getContentDeliveryManager().joinStreamPart(STREAM_PART_ID)
|
|
100
100
|
|
|
101
|
-
await
|
|
101
|
+
await until(() =>
|
|
102
102
|
publisherNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|
|
103
103
|
&& inspectedNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|
|
104
104
|
&& inspectorNode.stack.getContentDeliveryManager().getNeighbors(STREAM_PART_ID).length === 2
|