@streamr/trackerless-network 101.1.2 → 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/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- 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 +29 -5
- package/dist/{src/proto → generated}/packages/trackerless-network/protos/NetworkRpc.js +17 -3
- 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 +10 -11
- package/dist/src/NetworkNode.d.ts +8 -7
- package/dist/src/NetworkNode.js +5 -3
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +2 -2
- package/dist/src/NetworkStack.js +7 -6
- 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 +5 -1
- package/dist/src/logic/ContentDeliveryLayerNode.js +30 -10
- package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
- package/dist/src/logic/ContentDeliveryManager.d.ts +8 -3
- package/dist/src/logic/ContentDeliveryManager.js +28 -7
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js +3 -3
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
- package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +5 -2
- package/dist/src/logic/ContentDeliveryRpcRemote.js +7 -0
- package/dist/src/logic/ContentDeliveryRpcRemote.js.map +1 -1
- package/dist/src/logic/ControlLayerNode.d.ts +1 -1
- package/dist/src/logic/DiscoveryLayerNode.d.ts +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js +3 -3
- package/dist/src/logic/DuplicateMessageDetector.js.map +1 -1
- package/dist/src/logic/ExternalNetworkRpc.js.map +1 -1
- package/dist/src/logic/NodeList.js +2 -2
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.d.ts +1 -1
- package/dist/src/logic/PeerDescriptorStoreManager.js +1 -2
- package/dist/src/logic/PeerDescriptorStoreManager.js.map +1 -1
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js +4 -3
- package/dist/src/logic/StreamPartNetworkSplitAvoidance.js.map +1 -1
- package/dist/src/logic/createContentDeliveryLayerNode.js +1 -1
- package/dist/src/logic/createContentDeliveryLayerNode.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 +4 -4
- 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/HandshakeRpcLocal.js +9 -9
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +5 -5
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.js +14 -14
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +5 -0
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +5 -3
- 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 +4 -4
- 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/neighbor-discovery/NeighborUpdateRpcRemote.js +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +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/Propagation.js +0 -1
- package/dist/src/logic/propagation/Propagation.js.map +1 -1
- package/dist/src/logic/propagation/PropagationTaskStore.d.ts +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +4 -4
- package/dist/src/logic/proxy/ProxyClient.js +11 -7
- package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +5 -5
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +4 -4
- 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/TemporaryConnectionRpcLocal.d.ts +4 -4
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +4 -4
- 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/temporary-connection/TemporaryConnectionRpcRemote.js +2 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +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 +3 -4
- package/dist/test/benchmark/first-message.js.map +1 -1
- package/dist/test/utils/utils.d.ts +4 -4
- package/dist/test/utils/utils.js +6 -5
- package/dist/test/utils/utils.js.map +1 -1
- package/jest.config.ts +13 -0
- package/karma-setup.js +7 -0
- package/karma.config.js +1 -1
- package/package.json +10 -11
- package/proto.sh +2 -2
- package/protos/NetworkRpc.proto +9 -4
- package/src/NetworkNode.ts +12 -9
- package/src/NetworkStack.ts +10 -10
- package/src/exports.ts +5 -3
- package/src/logic/ContentDeliveryLayerNode.ts +35 -11
- package/src/logic/ContentDeliveryManager.ts +41 -13
- package/src/logic/ContentDeliveryRpcLocal.ts +6 -6
- package/src/logic/ContentDeliveryRpcRemote.ts +12 -2
- package/src/logic/ControlLayerNode.ts +1 -1
- package/src/logic/DiscoveryLayerNode.ts +3 -3
- package/src/logic/DuplicateMessageDetector.ts +4 -4
- package/src/logic/ExternalNetworkRpc.ts +0 -1
- package/src/logic/NodeList.ts +4 -3
- package/src/logic/PeerDescriptorStoreManager.ts +1 -2
- package/src/logic/StreamPartNetworkSplitAvoidance.ts +5 -4
- package/src/logic/createContentDeliveryLayerNode.ts +3 -3
- package/src/logic/inspect/InspectSession.ts +5 -4
- package/src/logic/inspect/Inspector.ts +6 -6
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +13 -13
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +8 -8
- package/src/logic/neighbor-discovery/Handshaker.ts +15 -15
- package/src/logic/neighbor-discovery/NeighborFinder.ts +6 -1
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +6 -4
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +7 -7
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +4 -4
- 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 -2
- package/src/logic/propagation/PropagationTaskStore.ts +1 -1
- package/src/logic/proxy/ProxyClient.ts +17 -12
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +10 -10
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +5 -5
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +9 -9
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +4 -4
- package/src/logic/utils.ts +4 -4
- package/src/types.ts +13 -0
- package/test/benchmark/first-message.ts +6 -5
- package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +11 -6
- package/test/end-to-end/external-network-rpc.test.ts +2 -2
- package/test/end-to-end/inspect.test.ts +5 -5
- package/test/end-to-end/proxy-and-full-node.test.ts +6 -6
- package/test/end-to-end/proxy-connections.test.ts +12 -14
- package/test/end-to-end/proxy-key-exchange.test.ts +11 -9
- package/test/end-to-end/webrtc-full-node-network.test.ts +7 -9
- package/test/end-to-end/websocket-full-node-network.test.ts +8 -10
- package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +11 -11
- package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +10 -10
- package/test/integration/ContentDeliveryManager.test.ts +49 -25
- package/test/integration/ContentDeliveryRpcRemote.test.ts +8 -8
- package/test/integration/HandshakeRpcRemote.test.ts +2 -2
- package/test/integration/Handshakes.test.ts +21 -56
- package/test/integration/Inspect.test.ts +2 -2
- package/test/integration/NeighborUpdateRpcRemote.test.ts +2 -2
- package/test/integration/NetworkNode.test.ts +5 -4
- package/test/integration/NetworkRpc.test.ts +10 -10
- package/test/integration/NetworkStack.test.ts +4 -4
- package/test/integration/NodeInfoRpc.test.ts +9 -5
- package/test/integration/Propagation.test.ts +6 -6
- package/test/integration/joining-streams-on-offline-peers.test.ts +5 -5
- package/test/integration/stream-without-default-entrypoints.test.ts +8 -7
- package/test/integration/streamEntryPointReplacing.test.ts +5 -5
- package/test/types/global.d.ts +1 -0
- package/test/unit/ContentDeliveryLayerNode.test.ts +26 -14
- package/test/unit/ContentDeliveryManager.test.ts +10 -9
- package/test/unit/ContentDeliveryRpcLocal.test.ts +3 -3
- package/test/unit/DuplicateMessageDetector.test.ts +10 -10
- package/test/unit/ExternalNetworkRpc.test.ts +3 -3
- package/test/unit/HandshakeRpcLocal.test.ts +8 -21
- package/test/unit/Handshaker.test.ts +2 -2
- package/test/unit/InspectSession.test.ts +7 -4
- package/test/unit/Inspector.test.ts +5 -5
- package/test/unit/NeighborFinder.test.ts +5 -5
- package/test/unit/NeighborUpdateRpcLocal.test.ts +6 -6
- package/test/unit/NetworkNode.test.ts +5 -5
- package/test/unit/NodeList.test.ts +23 -23
- package/test/unit/PeerDescriptorStoreManager.test.ts +4 -4
- package/test/unit/Propagation.test.ts +8 -7
- package/test/unit/ProxyConnectionRpcRemote.test.ts +5 -5
- package/test/unit/StreamPartReconnect.test.ts +2 -2
- package/test/unit/TemporaryConnectionRpcLocal.test.ts +3 -3
- package/test/utils/mock/MockControlLayerNode.ts +5 -0
- package/test/utils/mock/MockNeighborUpdateManager.ts +1 -1
- package/test/utils/mock/MockTransport.ts +11 -0
- package/test/utils/utils.ts +10 -9
- package/tsconfig.browser.json +1 -0
- package/tsconfig.jest.json +2 -1
- package/tsconfig.json +3 -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 -5
- package/src/proto/google/protobuf/any.ts +0 -319
- package/src/proto/google/protobuf/empty.ts +0 -82
- package/src/proto/google/protobuf/timestamp.ts +0 -281
- 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 -752
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +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
|
@@ -4,8 +4,8 @@ exports.ProxyConnectionRpcLocal = void 0;
|
|
|
4
4
|
const dht_1 = require("@streamr/dht");
|
|
5
5
|
const utils_1 = require("@streamr/utils");
|
|
6
6
|
const eventemitter3_1 = require("eventemitter3");
|
|
7
|
-
const NetworkRpc_1 = require("
|
|
8
|
-
const NetworkRpc_client_1 = require("
|
|
7
|
+
const NetworkRpc_1 = require("../../../generated/packages/trackerless-network/protos/NetworkRpc");
|
|
8
|
+
const NetworkRpc_client_1 = require("../../../generated/packages/trackerless-network/protos/NetworkRpc.client");
|
|
9
9
|
const ContentDeliveryRpcRemote_1 = require("../ContentDeliveryRpcRemote");
|
|
10
10
|
const logger = new utils_1.Logger(module);
|
|
11
11
|
class ProxyConnectionRpcLocal extends eventemitter3_1.EventEmitter {
|
|
@@ -34,7 +34,7 @@ class ProxyConnectionRpcLocal extends eventemitter3_1.EventEmitter {
|
|
|
34
34
|
if (msg.body.oneofKind === 'groupKeyRequest') {
|
|
35
35
|
try {
|
|
36
36
|
const recipientId = msg.body.groupKeyRequest.recipientId;
|
|
37
|
-
return this.getNodeIdsForUserId((0, utils_1.
|
|
37
|
+
return this.getNodeIdsForUserId((0, utils_1.toUserId)(recipientId));
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
40
|
logger.trace(`Could not parse GroupKeyRequest`, { err });
|
|
@@ -54,10 +54,10 @@ class ProxyConnectionRpcLocal extends eventemitter3_1.EventEmitter {
|
|
|
54
54
|
// IProxyConnectionRpc server method
|
|
55
55
|
async requestConnection(request, context) {
|
|
56
56
|
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
57
|
-
const remoteNodeId = (0, dht_1.
|
|
57
|
+
const remoteNodeId = (0, dht_1.toNodeId)(senderPeerDescriptor);
|
|
58
58
|
this.connections.set(remoteNodeId, {
|
|
59
59
|
direction: request.direction,
|
|
60
|
-
userId: (0, utils_1.
|
|
60
|
+
userId: (0, utils_1.toUserId)(request.userId),
|
|
61
61
|
remote: new ContentDeliveryRpcRemote_1.ContentDeliveryRpcRemote(this.options.localPeerDescriptor, senderPeerDescriptor, this.options.rpcCommunicator, NetworkRpc_client_1.ContentDeliveryRpcClient)
|
|
62
62
|
});
|
|
63
63
|
const response = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyConnectionRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/proxy/ProxyConnectionRpcLocal.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"ProxyConnectionRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/proxy/ProxyConnectionRpcLocal.ts"],"names":[],"mappings":";;;AACA,sCAA6G;AAC7G,0CAAuE;AACvE,iDAA4C;AAC5C,kGAK0E;AAC1E,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AChC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAChC,oBAAoB,EACpB,IAAI,CAAC,OAAO,CAAC,eAAe,EAC5B,4CAAwB,CAC3B;SACJ,CAAC,CAAA;QACF,MAAM,QAAQ,GAA4B;YACtC,QAAQ,EAAE,IAAI;SACjB,CAAA;QACD,MAAM,CAAC,KAAK,CAAC,oCAAoC,YAAY,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;QAChG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA;QACxC,OAAO,QAAQ,CAAA;IACnB,CAAC;CACJ;AAzED,0DAyEC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RpcRemote } from '@streamr/dht';
|
|
2
|
-
import {
|
|
3
|
-
import { ProxyDirection } from '
|
|
4
|
-
import { ProxyConnectionRpcClient } from '
|
|
2
|
+
import { UserID } from '@streamr/utils';
|
|
3
|
+
import { ProxyDirection } from '../../../generated/packages/trackerless-network/protos/NetworkRpc';
|
|
4
|
+
import { ProxyConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client';
|
|
5
5
|
export declare class ProxyConnectionRpcRemote extends RpcRemote<ProxyConnectionRpcClient> {
|
|
6
|
-
requestConnection(direction: ProxyDirection, userId:
|
|
6
|
+
requestConnection(direction: ProxyDirection, userId: UserID): Promise<boolean>;
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ class ProxyConnectionRpcRemote extends dht_1.RpcRemote {
|
|
|
8
8
|
async requestConnection(direction, userId) {
|
|
9
9
|
const request = {
|
|
10
10
|
direction,
|
|
11
|
-
userId: (0, utils_1.
|
|
11
|
+
userId: (0, utils_1.toUserIdRaw)(userId)
|
|
12
12
|
};
|
|
13
13
|
const options = this.formDhtRpcOptions({
|
|
14
14
|
timeout: dht_1.EXISTING_CONNECTION_TIMEOUT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyConnectionRpcRemote.js","sourceRoot":"","sources":["../../../../src/logic/proxy/ProxyConnectionRpcRemote.ts"],"names":[],"mappings":";;;AAAA,sCAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"ProxyConnectionRpcRemote.js","sourceRoot":"","sources":["../../../../src/logic/proxy/ProxyConnectionRpcRemote.ts"],"names":[],"mappings":";;;AAAA,sCAAqE;AACrE,0CAA4D;AAI5D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,wBAAyB,SAAQ,eAAmC;IAE7E,KAAK,CAAC,iBAAiB,CAAC,SAAyB,EAAE,MAAc;QAC7D,MAAM,OAAO,GAA2B;YACpC,SAAS;YACT,MAAM,EAAE,IAAA,mBAAW,EAAC,MAAM,CAAC;SAC9B,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnC,OAAO,EAAE,iCAA2B;SACvC,CAAC,CAAA;QACF,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACtE,OAAO,GAAG,CAAC,QAAQ,CAAA;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;YACjE,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;CACJ;AAlBD,4DAkBC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
2
2
|
import { ConnectionLocker, DhtAddress, ListeningRpcCommunicator } from '@streamr/dht';
|
|
3
3
|
import { StreamPartID } from '@streamr/utils';
|
|
4
|
-
import { Empty } from '
|
|
5
|
-
import { PeerDescriptor } from '
|
|
6
|
-
import { CloseTemporaryConnection, TemporaryConnectionRequest, TemporaryConnectionResponse } from '
|
|
7
|
-
import { ITemporaryConnectionRpc } from '
|
|
4
|
+
import { Empty } from '../../../generated/google/protobuf/empty';
|
|
5
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc';
|
|
6
|
+
import { CloseTemporaryConnection, TemporaryConnectionRequest, TemporaryConnectionResponse } from '../../../generated/packages/trackerless-network/protos/NetworkRpc';
|
|
7
|
+
import { ITemporaryConnectionRpc } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.server';
|
|
8
8
|
import { NodeList } from '../NodeList';
|
|
9
9
|
interface TemporaryConnectionRpcLocalOptions {
|
|
10
10
|
rpcCommunicator: ListeningRpcCommunicator;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TemporaryConnectionRpcLocal = void 0;
|
|
4
4
|
const dht_1 = require("@streamr/dht");
|
|
5
|
-
const NetworkRpc_client_1 = require("
|
|
5
|
+
const NetworkRpc_client_1 = require("../../../generated/packages/trackerless-network/protos/NetworkRpc.client");
|
|
6
6
|
const ContentDeliveryRpcRemote_1 = require("../ContentDeliveryRpcRemote");
|
|
7
7
|
const NodeList_1 = require("../NodeList");
|
|
8
8
|
const LOCK_ID_BASE = 'system/content-delivery/temporary-connection/';
|
|
@@ -13,7 +13,7 @@ class TemporaryConnectionRpcLocal {
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
this.options = options;
|
|
15
15
|
// TODO use options option or named constant?
|
|
16
|
-
this.temporaryNodes = new NodeList_1.NodeList((0, dht_1.
|
|
16
|
+
this.temporaryNodes = new NodeList_1.NodeList((0, dht_1.toNodeId)(options.localPeerDescriptor), 10);
|
|
17
17
|
this.lockId = LOCK_ID_BASE + options.streamPartId;
|
|
18
18
|
}
|
|
19
19
|
getNodes() {
|
|
@@ -30,13 +30,13 @@ class TemporaryConnectionRpcLocal {
|
|
|
30
30
|
const sender = context.incomingSourceDescriptor;
|
|
31
31
|
const remote = new ContentDeliveryRpcRemote_1.ContentDeliveryRpcRemote(this.options.localPeerDescriptor, sender, this.options.rpcCommunicator, NetworkRpc_client_1.ContentDeliveryRpcClient);
|
|
32
32
|
this.temporaryNodes.add(remote);
|
|
33
|
-
this.options.connectionLocker.weakLockConnection((0, dht_1.
|
|
33
|
+
this.options.connectionLocker.weakLockConnection((0, dht_1.toNodeId)(sender), this.lockId);
|
|
34
34
|
return {
|
|
35
35
|
accepted: true
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
async closeConnection(_request, context) {
|
|
39
|
-
const remoteNodeId = (0, dht_1.
|
|
39
|
+
const remoteNodeId = (0, dht_1.toNodeId)(context.incomingSourceDescriptor);
|
|
40
40
|
this.removeNode(remoteNodeId);
|
|
41
41
|
return {};
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporaryConnectionRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"TemporaryConnectionRpcLocal.js","sourceRoot":"","sources":["../../../../src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts"],"names":[],"mappings":";;;AACA,sCAA+G;AAS/G,gHAAmH;AAEnH,0EAAsE;AACtE,0CAAsC;AAStC,MAAM,YAAY,GAAG,+CAA+C,CAAA;AAEpE,MAAa,2BAA2B;IAEnB,OAAO,CAAoC;IAC3C,cAAc,CAAU;IACxB,MAAM,CAAQ;IAC/B,YAAY,OAA2C;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,6CAA6C;QAC7C,IAAI,CAAC,cAAc,GAAG,IAAI,mBAAQ,CAAC,IAAA,cAAQ,EAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAA;QAC7E,IAAI,CAAC,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;IACrD,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,cAAc,CAAA;IAC9B,CAAC;IAED,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;IAED,UAAU,CAAC,MAAkB;QACzB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3E,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,QAAoC,EACpC,OAA0B;QAE1B,MAAM,MAAM,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QACpE,MAAM,MAAM,GAAG,IAAI,mDAAwB,CACvC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAChC,MAAM,EACN,IAAI,CAAC,OAAO,CAAC,eAAe,EAC5B,4CAAwB,CAC3B,CAAA;QACD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,IAAA,cAAQ,EAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/E,OAAO;YACH,QAAQ,EAAE,IAAI;SACjB,CAAA;IACL,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAAkC,EAAE,OAA0B;QAChF,MAAM,YAAY,GAAG,IAAA,cAAQ,EAAE,OAA0B,CAAC,wBAAyB,CAAC,CAAA;QACpF,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;QAC7B,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AAhDD,kEAgDC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcRemote } from '@streamr/dht';
|
|
2
|
-
import { TemporaryConnectionRpcClient } from '
|
|
2
|
+
import { TemporaryConnectionRpcClient } from '../../../generated/packages/trackerless-network/protos/NetworkRpc.client';
|
|
3
3
|
export declare class TemporaryConnectionRpcRemote extends RpcRemote<TemporaryConnectionRpcClient> {
|
|
4
4
|
openConnection(): Promise<boolean>;
|
|
5
5
|
closeConnection(): Promise<void>;
|
|
@@ -11,7 +11,7 @@ class TemporaryConnectionRpcRemote extends dht_1.RpcRemote {
|
|
|
11
11
|
return response.accepted;
|
|
12
12
|
}
|
|
13
13
|
catch (err) {
|
|
14
|
-
logger.debug(`temporaryConnection to ${(0, dht_1.
|
|
14
|
+
logger.debug(`temporaryConnection to ${(0, dht_1.toNodeId)(this.getPeerDescriptor())} failed`, { err });
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -23,7 +23,7 @@ class TemporaryConnectionRpcRemote extends dht_1.RpcRemote {
|
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
25
25
|
catch (err) {
|
|
26
|
-
logger.trace(`closeConnection to ${(0, dht_1.
|
|
26
|
+
logger.trace(`closeConnection to ${(0, dht_1.toNodeId)(this.getPeerDescriptor())} failed`, { err });
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporaryConnectionRpcRemote.js","sourceRoot":"","sources":["../../../../src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"TemporaryConnectionRpcRemote.js","sourceRoot":"","sources":["../../../../src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts"],"names":[],"mappings":";;;AAAA,sCAAkD;AAClD,0CAAuC;AAGvC,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,4BAA6B,SAAQ,eAAuC;IAErF,KAAK,CAAC,cAAc;QAChB,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;YACpF,OAAO,QAAQ,CAAC,QAAQ,CAAA;QAC5B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAA,cAAQ,EAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;YAC5F,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,eAAe;QACjB,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC;gBAC9D,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,IAAI;aACrB,CAAC,CAAC,CAAA;QACP,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CAAC,sBAAsB,IAAA,cAAQ,EAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QAC5F,CAAC;IACL,CAAC;CACJ;AAtBD,oEAsBC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { MessageID, MessageRef } from '../../generated/packages/trackerless-network/protos/NetworkRpc';
|
|
1
2
|
import { DuplicateMessageDetector } from './DuplicateMessageDetector';
|
|
2
|
-
import { MessageID, MessageRef } from '../proto/packages/trackerless-network/protos/NetworkRpc';
|
|
3
3
|
export declare const markAndCheckDuplicate: (duplicateDetectors: Map<string, DuplicateMessageDetector>, currentMessage: MessageID, previousMessageRef?: MessageRef) => boolean;
|
package/dist/src/logic/utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.markAndCheckDuplicate = void 0;
|
|
4
|
-
const DuplicateMessageDetector_1 = require("./DuplicateMessageDetector");
|
|
5
4
|
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const DuplicateMessageDetector_1 = require("./DuplicateMessageDetector");
|
|
6
6
|
const markAndCheckDuplicate = (duplicateDetectors, currentMessage, previousMessageRef) => {
|
|
7
|
-
const detectorKey = `${(0, utils_1.
|
|
7
|
+
const detectorKey = `${(0, utils_1.toUserId)(currentMessage.publisherId)}-${currentMessage.messageChainId}`;
|
|
8
8
|
const previousNumberPair = previousMessageRef ?
|
|
9
9
|
new DuplicateMessageDetector_1.NumberPair(Number(previousMessageRef.timestamp), previousMessageRef.sequenceNumber) : null;
|
|
10
10
|
const currentNumberPair = new DuplicateMessageDetector_1.NumberPair(Number(currentMessage.timestamp), currentMessage.sequenceNumber);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/logic/utils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/logic/utils.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AAEzC,yEAAiF;AAE1E,MAAM,qBAAqB,GAAG,CACjC,kBAAyD,EACzD,cAAyB,EACzB,kBAA+B,EACxB,EAAE;IACT,MAAM,WAAW,GAAG,GAAG,IAAA,gBAAQ,EAAC,cAAc,CAAC,WAAW,CAAC,IAAI,cAAc,CAAC,cAAc,EAAE,CAAA;IAC9F,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,CAAC;QAC3C,IAAI,qCAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAClG,MAAM,iBAAiB,GAAG,IAAI,qCAAU,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAA;IACzG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,kBAAkB,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,mDAAwB,EAAE,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAA;AACnG,CAAC,CAAA;AAbY,QAAA,qBAAqB,yBAajC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChangeFieldType } from '@streamr/utils';
|
|
2
|
+
import { MarkRequired } from 'ts-essentials';
|
|
3
|
+
import { ContentDeliveryLayerNeighborInfo as ContentDeliveryLayerNeighborInfo_, NodeInfoResponse, StreamPartitionInfo as StreamPartitionInfo_ } from '../generated/packages/trackerless-network/protos/NetworkRpc';
|
|
4
|
+
export type ContentDeliveryLayerNeighborInfo = MarkRequired<ContentDeliveryLayerNeighborInfo_, 'peerDescriptor'>;
|
|
5
|
+
export type StreamPartitionInfo = ChangeFieldType<Required<StreamPartitionInfo_>, 'contentDeliveryLayerNeighbors', ContentDeliveryLayerNeighborInfo[]>;
|
|
6
|
+
export type NodeInfo = ChangeFieldType<Required<NodeInfoResponse>, 'streamPartitions', StreamPartitionInfo[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -8,7 +8,7 @@ const dht_1 = require("@streamr/dht");
|
|
|
8
8
|
const utils_1 = require("@streamr/utils");
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const ContentDeliveryManager_1 = require("../../src/logic/ContentDeliveryManager");
|
|
11
|
-
const NetworkRpc_1 = require("../../
|
|
11
|
+
const NetworkRpc_1 = require("../../generated/packages/trackerless-network/protos/NetworkRpc");
|
|
12
12
|
const utils_2 = require("../utils/utils");
|
|
13
13
|
const numNodes = 10000;
|
|
14
14
|
let nodes;
|
|
@@ -55,7 +55,7 @@ const measureJoiningTime = async () => {
|
|
|
55
55
|
const peerDescriptor = (0, utils_2.createMockPeerDescriptor)({
|
|
56
56
|
region: (0, dht_1.getRandomRegion)()
|
|
57
57
|
});
|
|
58
|
-
console.log('starting node with id ', (0, dht_1.
|
|
58
|
+
console.log('starting node with id ', (0, dht_1.toNodeId)(peerDescriptor));
|
|
59
59
|
// start publishing ons stream
|
|
60
60
|
const stream = Array.from(streamParts.keys())[Math.floor(Math.random() * streamParts.size)];
|
|
61
61
|
console.log(stream);
|
|
@@ -67,7 +67,7 @@ const measureJoiningTime = async () => {
|
|
|
67
67
|
streamPartition: 0,
|
|
68
68
|
timestamp: i,
|
|
69
69
|
sequenceNumber: Math.floor(Math.random() * 20000),
|
|
70
|
-
publisherId: (0, utils_1.
|
|
70
|
+
publisherId: (0, utils_1.toUserIdRaw)((0, utils_1.toUserId)('0x2222')),
|
|
71
71
|
messageChainId: 'msgChainId'
|
|
72
72
|
},
|
|
73
73
|
body: {
|
|
@@ -116,7 +116,6 @@ const run = async () => {
|
|
|
116
116
|
fs_1.default.closeSync(logFile);
|
|
117
117
|
await shutdownNetwork();
|
|
118
118
|
};
|
|
119
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
120
119
|
run().then(() => {
|
|
121
120
|
console.log('done');
|
|
122
121
|
}).catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first-message.js","sourceRoot":"","sources":["../../../test/benchmark/first-message.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;;;AAE/B,sCAOqB;AACrB,
|
|
1
|
+
{"version":3,"file":"first-message.js","sourceRoot":"","sources":["../../../test/benchmark/first-message.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;;;AAE/B,sCAOqB;AACrB,0CASuB;AACvB,4CAAmB;AAEnB,mFAA8E;AAG9E,+FAA2H;AAC3H,0CAAyF;AAEzF,MAAM,QAAQ,GAAG,KAAK,CAAA;AAEtB,IAAI,KAAoB,CAAA;AACxB,IAAI,SAAoB,CAAA;AACxB,IAAI,QAAwB,CAAA;AAC5B,MAAM,gBAAgB,GAAqB,EAA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|
2
|
-
import {
|
|
2
|
+
import { StreamPartID, UserID } from '@streamr/utils';
|
|
3
3
|
import { NetworkNode } from '../../src/NetworkNode';
|
|
4
4
|
import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode';
|
|
5
5
|
import { ContentDeliveryRpcRemote } from '../../src/logic/ContentDeliveryRpcRemote';
|
|
6
6
|
import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode';
|
|
7
7
|
import { HandshakeRpcRemote } from '../../src/logic/neighbor-discovery/HandshakeRpcRemote';
|
|
8
|
-
import { StreamMessage } from '../../
|
|
8
|
+
import { StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc';
|
|
9
9
|
export declare const mockConnectionLocker: ConnectionLocker;
|
|
10
10
|
export declare const createMockContentDeliveryLayerNodeAndDhtNode: (localPeerDescriptor: PeerDescriptor, entryPointDescriptor: PeerDescriptor, streamPartId: StreamPartID, simulator: Simulator) => Promise<[DiscoveryLayerNode, ContentDeliveryLayerNode]>;
|
|
11
|
-
export declare const createStreamMessage: (content: string, streamPartId: StreamPartID, publisherId:
|
|
12
|
-
export declare const createMockPeerDescriptor: (opts?: Omit<Partial<PeerDescriptor>,
|
|
11
|
+
export declare const createStreamMessage: (content: string, streamPartId: StreamPartID, publisherId: UserID, timestamp?: number, sequenceNumber?: number) => StreamMessage;
|
|
12
|
+
export declare const createMockPeerDescriptor: (opts?: Omit<Partial<PeerDescriptor>, "nodeId" | "type">) => PeerDescriptor;
|
|
13
13
|
export declare const createMockContentDeliveryRpcRemote: (remotePeerDescriptor?: PeerDescriptor) => ContentDeliveryRpcRemote;
|
|
14
14
|
export declare const createMockHandshakeRpcRemote: () => HandshakeRpcRemote;
|
|
15
15
|
export declare const createNetworkNodeWithSimulator: (peerDescriptor: PeerDescriptor, simulator: Simulator, entryPoints: PeerDescriptor[]) => Promise<NetworkNode>;
|
package/dist/test/utils/utils.js
CHANGED
|
@@ -8,8 +8,8 @@ const NetworkNode_1 = require("../../src/NetworkNode");
|
|
|
8
8
|
const ContentDeliveryRpcRemote_1 = require("../../src/logic/ContentDeliveryRpcRemote");
|
|
9
9
|
const createContentDeliveryLayerNode_1 = require("../../src/logic/createContentDeliveryLayerNode");
|
|
10
10
|
const HandshakeRpcRemote_1 = require("../../src/logic/neighbor-discovery/HandshakeRpcRemote");
|
|
11
|
-
const NetworkRpc_1 = require("../../
|
|
12
|
-
const NetworkRpc_client_1 = require("../../
|
|
11
|
+
const NetworkRpc_1 = require("../../generated/packages/trackerless-network/protos/NetworkRpc");
|
|
12
|
+
const NetworkRpc_client_1 = require("../../generated/packages/trackerless-network/protos/NetworkRpc.client");
|
|
13
13
|
exports.mockConnectionLocker = {
|
|
14
14
|
lockConnection: () => { },
|
|
15
15
|
unlockConnection: () => { },
|
|
@@ -28,7 +28,8 @@ const createMockContentDeliveryLayerNodeAndDhtNode = async (localPeerDescriptor,
|
|
|
28
28
|
peerDescriptor: localPeerDescriptor,
|
|
29
29
|
numberOfNodesPerKBucket: 4,
|
|
30
30
|
entryPoints: [entryPointDescriptor],
|
|
31
|
-
rpcRequestTimeout: 5000
|
|
31
|
+
rpcRequestTimeout: 5000,
|
|
32
|
+
neighborPingLimit: 16
|
|
32
33
|
});
|
|
33
34
|
const contentDeliveryLayerNode = (0, createContentDeliveryLayerNode_1.createContentDeliveryLayerNode)({
|
|
34
35
|
streamPartId,
|
|
@@ -48,7 +49,7 @@ const createStreamMessage = (content, streamPartId, publisherId, timestamp, sequ
|
|
|
48
49
|
streamPartition: utils_1.StreamPartIDUtils.getStreamPartition(streamPartId),
|
|
49
50
|
sequenceNumber: sequenceNumber ?? 0,
|
|
50
51
|
timestamp: timestamp ?? Date.now(),
|
|
51
|
-
publisherId: (0, utils_1.
|
|
52
|
+
publisherId: (0, utils_1.toUserIdRaw)(publisherId),
|
|
52
53
|
messageChainId: 'messageChain0',
|
|
53
54
|
};
|
|
54
55
|
const msg = {
|
|
@@ -70,7 +71,7 @@ exports.createStreamMessage = createStreamMessage;
|
|
|
70
71
|
const createMockPeerDescriptor = (opts) => {
|
|
71
72
|
return {
|
|
72
73
|
...opts,
|
|
73
|
-
nodeId: (0, dht_1.
|
|
74
|
+
nodeId: (0, dht_1.toDhtAddressRaw)((0, dht_1.randomDhtAddress)()),
|
|
74
75
|
type: dht_1.NodeType.NODEJS,
|
|
75
76
|
region: (0, dht_1.getRandomRegion)()
|
|
76
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../test/utils/utils.ts"],"names":[],"mappings":";;;AAAA,sCAUqB;AACrB,kDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../test/utils/utils.ts"],"names":[],"mappings":";;;AAAA,sCAUqB;AACrB,kDAAoD;AACpD,0CAAgH;AAChH,uDAAsE;AAEtE,uFAAmF;AAEnF,mGAA+F;AAC/F,8FAA0F;AAC1F,+FAMuE;AACvE,6GAAoI;AAEvH,QAAA,oBAAoB,GAAqB;IAClD,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC9B,6BAA6B,EAAE,GAAG,EAAE,CAAC,CAAC;IACtC,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,4BAA4B,EAAE,GAAG,EAAE,CAAC,CAAC;CACxC,CAAA;AAEM,MAAM,4CAA4C,GAAG,KAAK,EAC7D,mBAAmC,EACnC,oBAAoC,EACpC,YAA0B,EAC1B,SAAoB,EACqC,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAI,wBAAkB,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAA;IACrE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACpB,MAAM,kBAAkB,GAAG,IAAI,aAAO,CAAC;QACnC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AAM;YACvB,WAAW,EAAE,MAAM;SACtB;KACJ,CAAC,CAAA;AACN,CAAC,CAAA;AAlBY,QAAA,8BAA8B,kCAkB1C"}
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Config } from '@jest/types'
|
|
2
|
+
import defaultConfig from '../../jest.config'
|
|
3
|
+
|
|
4
|
+
const config: Config.InitialOptions = {
|
|
5
|
+
...defaultConfig,
|
|
6
|
+
setupFilesAfterEnv: [
|
|
7
|
+
...defaultConfig.setupFilesAfterEnv,
|
|
8
|
+
'@streamr/test-utils/setupCustomMatchers',
|
|
9
|
+
],
|
|
10
|
+
testTimeout: 15000,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default config
|
package/karma-setup.js
ADDED
package/karma.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/trackerless-network",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "102.0.0-beta.1",
|
|
4
4
|
"description": "Minimal and extendable implementation of the Streamr Network node.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc -b tsconfig.node.json",
|
|
16
16
|
"build-browser": "webpack --mode=development --progress",
|
|
17
|
-
"
|
|
18
|
-
"check": "tsc -p ./tsconfig.jest.json
|
|
17
|
+
"prebuild": "./proto.sh",
|
|
18
|
+
"check": "tsc -p ./tsconfig.jest.json",
|
|
19
19
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
20
20
|
"coverage": "jest --coverage",
|
|
21
21
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
@@ -30,22 +30,21 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
32
32
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
33
|
-
"@streamr/dht": "
|
|
34
|
-
"@streamr/proto-rpc": "
|
|
35
|
-
"@streamr/
|
|
36
|
-
"@streamr/utils": "101.1.2",
|
|
33
|
+
"@streamr/dht": "102.0.0-beta.1",
|
|
34
|
+
"@streamr/proto-rpc": "102.0.0-beta.1",
|
|
35
|
+
"@streamr/utils": "102.0.0-beta.1",
|
|
37
36
|
"eventemitter3": "^5.0.0",
|
|
38
37
|
"lodash": "^4.17.21",
|
|
39
|
-
"
|
|
38
|
+
"ts-essentials": "^10.0.4",
|
|
39
|
+
"uuid": "^11.0.5",
|
|
40
40
|
"yallist": "^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
44
|
-
"@
|
|
45
|
-
"@types/
|
|
44
|
+
"@streamr/test-utils": "102.0.0-beta.1",
|
|
45
|
+
"@types/lodash": "^4.17.14",
|
|
46
46
|
"@types/yallist": "^4.0.1",
|
|
47
47
|
"expect": "^29.6.2",
|
|
48
|
-
"ts-essentials": "^10.0.2",
|
|
49
48
|
"ts-node": "^10.9.2"
|
|
50
49
|
}
|
|
51
50
|
}
|
package/proto.sh
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
mkdir -p ./
|
|
2
|
-
npx protoc --ts_out ./
|
|
1
|
+
mkdir -p ./generated
|
|
2
|
+
npx protoc --ts_out ./generated --ts_opt server_generic,generate_dependencies,long_type_number --proto_path ../.. packages/trackerless-network/protos/NetworkRpc.proto --experimental_allow_proto3_optional
|
package/protos/NetworkRpc.proto
CHANGED
|
@@ -3,7 +3,6 @@ syntax = "proto3";
|
|
|
3
3
|
option optimize_for = CODE_SIZE;
|
|
4
4
|
|
|
5
5
|
import "google/protobuf/empty.proto";
|
|
6
|
-
import "google/protobuf/any.proto";
|
|
7
6
|
import "packages/dht/protos/DhtRpc.proto";
|
|
8
7
|
|
|
9
8
|
service ContentDeliveryRpc {
|
|
@@ -163,7 +162,13 @@ enum ProxyDirection {
|
|
|
163
162
|
message StreamPartitionInfo {
|
|
164
163
|
string id = 1;
|
|
165
164
|
repeated dht.PeerDescriptor controlLayerNeighbors = 2;
|
|
166
|
-
repeated dht.PeerDescriptor
|
|
165
|
+
repeated dht.PeerDescriptor deprecatedContentDeliveryLayerNeighbors = 3;
|
|
166
|
+
repeated ContentDeliveryLayerNeighborInfo contentDeliveryLayerNeighbors = 4;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
message ContentDeliveryLayerNeighborInfo {
|
|
170
|
+
dht.PeerDescriptor peerDescriptor = 1;
|
|
171
|
+
optional int32 rtt = 2;
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
message ControlLayerInfo {
|
|
@@ -176,6 +181,6 @@ message NodeInfoRequest {}
|
|
|
176
181
|
message NodeInfoResponse {
|
|
177
182
|
dht.PeerDescriptor peerDescriptor = 1;
|
|
178
183
|
repeated StreamPartitionInfo streamPartitions = 2;
|
|
179
|
-
|
|
180
|
-
string
|
|
184
|
+
ControlLayerInfo controlLayer = 3;
|
|
185
|
+
string applicationVersion = 4;
|
|
181
186
|
}
|
package/src/NetworkNode.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { DhtAddress, PeerDescriptor } from '@streamr/dht'
|
|
2
|
-
import { EthereumAddress, MetricsContext, StreamPartID } from '@streamr/utils'
|
|
3
|
-
import { NetworkOptions, NetworkStack, NodeInfo } from './NetworkStack'
|
|
4
|
-
import { ProxyDirection, StreamMessage } from './proto/packages/trackerless-network/protos/NetworkRpc'
|
|
5
|
-
import { ExternalNetworkRpc, ExternalRpcClient, ExternalRpcClientClass } from './logic/ExternalNetworkRpc'
|
|
6
1
|
import { IMessageType } from '@protobuf-ts/runtime'
|
|
7
2
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
3
|
+
import { DhtAddress, PeerDescriptor } from '@streamr/dht'
|
|
8
4
|
import { ProtoRpcClient } from '@streamr/proto-rpc'
|
|
5
|
+
import { MetricsContext, StreamPartID, UserID } from '@streamr/utils'
|
|
6
|
+
import { ExternalNetworkRpc, ExternalRpcClient, ExternalRpcClientClass } from './logic/ExternalNetworkRpc'
|
|
7
|
+
import { NetworkOptions, NetworkStack } from './NetworkStack'
|
|
8
|
+
import { ProxyDirection, StreamMessage } from '../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
9
|
+
import { NodeInfo } from './types'
|
|
9
10
|
|
|
10
11
|
export const createNetworkNode = (opts: NetworkOptions): NetworkNode => {
|
|
11
12
|
return new NetworkNode(new NetworkStack(opts))
|
|
@@ -46,7 +47,7 @@ export class NetworkNode {
|
|
|
46
47
|
streamPartId: StreamPartID,
|
|
47
48
|
nodes: PeerDescriptor[],
|
|
48
49
|
direction: ProxyDirection,
|
|
49
|
-
userId:
|
|
50
|
+
userId: UserID,
|
|
50
51
|
connectionCount?: number
|
|
51
52
|
): Promise<void> {
|
|
52
53
|
await this.stack.getContentDeliveryManager().setProxies(streamPartId, nodes, direction, userId, connectionCount)
|
|
@@ -75,7 +76,7 @@ export class NetworkNode {
|
|
|
75
76
|
await this.stack.getContentDeliveryManager().leaveStreamPart(streamPartId)
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
getNeighbors(streamPartId: StreamPartID):
|
|
79
|
+
getNeighbors(streamPartId: StreamPartID): readonly DhtAddress[] {
|
|
79
80
|
return this.stack.getContentDeliveryManager().getNeighbors(streamPartId)
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -113,9 +114,11 @@ export class NetworkNode {
|
|
|
113
114
|
return this.stack.fetchNodeInfo(node)
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
// eslint-disable-next-line class-methods-use-this
|
|
117
117
|
getDiagnosticInfo(): Record<string, unknown> {
|
|
118
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
controlLayer: this.stack.getControlLayerNode().getDiagnosticInfo(),
|
|
120
|
+
contentLayer: this.stack.getContentDeliveryManager().getDiagnosticInfo()
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
registerExternalNetworkRpcMethod<
|
package/src/NetworkStack.ts
CHANGED
|
@@ -5,16 +5,17 @@ import {
|
|
|
5
5
|
ListeningRpcCommunicator,
|
|
6
6
|
PeerDescriptor,
|
|
7
7
|
areEqualPeerDescriptors,
|
|
8
|
-
|
|
8
|
+
toNodeId
|
|
9
9
|
} from '@streamr/dht'
|
|
10
|
-
import { Logger, MetricsContext, StreamID, StreamPartID, toStreamPartID,
|
|
10
|
+
import { Logger, MetricsContext, StreamID, StreamPartID, toStreamPartID, until } from '@streamr/utils'
|
|
11
11
|
import { pull } from 'lodash'
|
|
12
12
|
import { version as applicationVersion } from '../package.json'
|
|
13
13
|
import { ContentDeliveryManager, ContentDeliveryManagerOptions } from './logic/ContentDeliveryManager'
|
|
14
14
|
import { ControlLayerNode } from './logic/ControlLayerNode'
|
|
15
15
|
import { NodeInfoClient } from './logic/node-info/NodeInfoClient'
|
|
16
16
|
import { NODE_INFO_RPC_SERVICE_ID, NodeInfoRpcLocal } from './logic/node-info/NodeInfoRpcLocal'
|
|
17
|
-
import {
|
|
17
|
+
import { ProxyDirection, StreamMessage } from '../generated/packages/trackerless-network/protos/NetworkRpc'
|
|
18
|
+
import { NodeInfo } from './types'
|
|
18
19
|
|
|
19
20
|
export interface NetworkOptions {
|
|
20
21
|
layer0?: DhtNodeOptions
|
|
@@ -49,8 +50,6 @@ if (typeof window === 'object') {
|
|
|
49
50
|
})
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
export type NodeInfo = Required<NodeInfoResponse>
|
|
53
|
-
|
|
54
53
|
export class NetworkStack {
|
|
55
54
|
|
|
56
55
|
private controlLayerNode?: ControlLayerNode
|
|
@@ -66,7 +65,8 @@ export class NetworkStack {
|
|
|
66
65
|
this.metricsContext = options.metricsContext ?? new MetricsContext()
|
|
67
66
|
this.controlLayerNode = new DhtNode({
|
|
68
67
|
...options.layer0,
|
|
69
|
-
metricsContext: this.metricsContext
|
|
68
|
+
metricsContext: this.metricsContext,
|
|
69
|
+
allowIncomingPrivateConnections: options.networkNode?.acceptProxyConnections
|
|
70
70
|
})
|
|
71
71
|
this.contentDeliveryManager = new ContentDeliveryManager({
|
|
72
72
|
...options.networkNode,
|
|
@@ -82,7 +82,7 @@ export class NetworkStack {
|
|
|
82
82
|
await this.ensureConnectedToControlLayer()
|
|
83
83
|
this.getContentDeliveryManager().joinStreamPart(streamPartId)
|
|
84
84
|
if (neighborRequirement !== undefined) {
|
|
85
|
-
await
|
|
85
|
+
await until(() => {
|
|
86
86
|
return this.getContentDeliveryManager().getNeighbors(streamPartId).length >= neighborRequirement.minCount
|
|
87
87
|
}, neighborRequirement.timeout)
|
|
88
88
|
}
|
|
@@ -106,9 +106,9 @@ export class NetworkStack {
|
|
|
106
106
|
async start(doJoin = true): Promise<void> {
|
|
107
107
|
logger.info('Starting a Streamr Network Node')
|
|
108
108
|
await this.controlLayerNode!.start()
|
|
109
|
-
logger.info(`Node id is ${
|
|
109
|
+
logger.info(`Node id is ${toNodeId(this.controlLayerNode!.getLocalPeerDescriptor())}`)
|
|
110
110
|
const connectionManager = this.controlLayerNode!.getTransport() as ConnectionManager
|
|
111
|
-
if ((this.options.layer0?.entryPoints
|
|
111
|
+
if ((this.options.layer0?.entryPoints?.some((entryPoint) =>
|
|
112
112
|
areEqualPeerDescriptors(entryPoint, this.controlLayerNode!.getLocalPeerDescriptor())
|
|
113
113
|
))) {
|
|
114
114
|
await this.controlLayerNode?.joinDht(this.options.layer0.entryPoints)
|
|
@@ -171,7 +171,7 @@ export class NetworkStack {
|
|
|
171
171
|
neighbors: this.getControlLayerNode().getNeighbors()
|
|
172
172
|
},
|
|
173
173
|
streamPartitions: this.getContentDeliveryManager().getNodeInfo(),
|
|
174
|
-
|
|
174
|
+
applicationVersion
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|