@streamr/trackerless-network 100.0.0-testnet-three.6 → 100.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +7 -7
- package/dist/src/NetworkNode.js +11 -11
- package/dist/src/NetworkNode.js.map +1 -1
- package/dist/src/NetworkStack.d.ts +6 -6
- package/dist/src/NetworkStack.js +22 -20
- package/dist/src/NetworkStack.js.map +1 -1
- package/dist/src/exports.d.ts +3 -3
- package/dist/src/exports.js +7 -1
- package/dist/src/exports.js.map +1 -1
- package/dist/src/logic/{StreamrNode.d.ts → ContentDeliveryManager.d.ts} +6 -6
- package/dist/src/logic/{StreamrNode.js → ContentDeliveryManager.js} +16 -13
- package/dist/src/logic/ContentDeliveryManager.js.map +1 -0
- package/dist/src/logic/{DeliveryRpcLocal.d.ts → ContentDeliveryRpcLocal.d.ts} +4 -4
- package/dist/src/logic/{DeliveryRpcLocal.js → ContentDeliveryRpcLocal.js} +4 -4
- package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -0
- package/dist/src/logic/{DeliveryRpcRemote.d.ts → ContentDeliveryRpcRemote.d.ts} +2 -2
- package/dist/src/logic/{DeliveryRpcRemote.js → ContentDeliveryRpcRemote.js} +4 -4
- package/dist/src/logic/ContentDeliveryRpcRemote.js.map +1 -0
- package/dist/src/logic/EntryPointDiscovery.d.ts +1 -1
- package/dist/src/logic/EntryPointDiscovery.js +3 -3
- package/dist/src/logic/EntryPointDiscovery.js.map +1 -1
- package/dist/src/logic/Layer0Node.d.ts +1 -1
- package/dist/src/logic/Layer1Node.d.ts +7 -1
- package/dist/src/logic/NodeList.d.ts +11 -10
- package/dist/src/logic/NodeList.js +7 -2
- package/dist/src/logic/NodeList.js.map +1 -1
- package/dist/src/logic/RandomGraphNode.d.ts +4 -1
- package/dist/src/logic/RandomGraphNode.js +36 -14
- package/dist/src/logic/RandomGraphNode.js.map +1 -1
- package/dist/src/logic/createRandomGraphNode.d.ts +1 -1
- package/dist/src/logic/createRandomGraphNode.js +16 -7
- package/dist/src/logic/createRandomGraphNode.js.map +1 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +1 -1
- package/dist/src/logic/formStreamPartDeliveryServiceId.js +4 -3
- package/dist/src/logic/formStreamPartDeliveryServiceId.js.map +1 -1
- package/dist/src/logic/inspect/Inspector.js +2 -2
- package/dist/src/logic/inspect/Inspector.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +3 -4
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +6 -11
- package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +2 -2
- package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +4 -3
- package/dist/src/logic/neighbor-discovery/Handshaker.js +35 -16
- package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +3 -0
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js +7 -1
- package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +1 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +0 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +1 -2
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +2 -3
- package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +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/protocol-integration/stream-message/GroupKeyResponseTranslator.js.map +1 -1
- package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js +64 -52
- package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js.map +1 -1
- package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.d.ts +5 -1
- package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js +19 -1
- package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js.map +1 -1
- package/dist/src/logic/proxy/ProxyClient.d.ts +1 -1
- package/dist/src/logic/proxy/ProxyClient.js +8 -8
- 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 +5 -5
- package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
- 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 +5 -1
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +7 -2
- package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +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/proto/google/protobuf/any.d.ts +11 -4
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +9 -3
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +16 -6
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +11 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +98 -87
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +45 -49
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +10 -4
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +7 -7
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.d.ts +62 -26
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +31 -14
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +1 -1
- package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.d.ts +2 -2
- package/dist/test/benchmark/first-message.js +5 -5
- 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 +18 -11
- package/dist/test/utils/utils.js.map +1 -1
- package/karma.config.js +2 -0
- package/package.json +7 -7
- package/protos/NetworkRpc.proto +19 -11
- package/src/NetworkNode.ts +11 -11
- package/src/NetworkStack.ts +30 -25
- package/src/exports.ts +7 -3
- package/src/logic/{StreamrNode.ts → ContentDeliveryManager.ts} +21 -17
- package/src/logic/{DeliveryRpcLocal.ts → ContentDeliveryRpcLocal.ts} +5 -5
- package/src/logic/{DeliveryRpcRemote.ts → ContentDeliveryRpcRemote.ts} +2 -2
- package/src/logic/EntryPointDiscovery.ts +4 -4
- package/src/logic/Layer0Node.ts +1 -1
- package/src/logic/Layer1Node.ts +16 -1
- package/src/logic/NodeList.ts +20 -14
- package/src/logic/RandomGraphNode.ts +89 -27
- package/src/logic/createRandomGraphNode.ts +18 -9
- package/src/logic/formStreamPartDeliveryServiceId.ts +2 -1
- package/src/logic/inspect/Inspector.ts +2 -2
- package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +10 -15
- package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +2 -2
- package/src/logic/neighbor-discovery/Handshaker.ts +41 -22
- package/src/logic/neighbor-discovery/NeighborFinder.ts +10 -1
- package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +1 -3
- package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +5 -7
- package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +1 -1
- package/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.ts +0 -1
- package/src/logic/protocol-integration/stream-message/StreamMessageTranslator.ts +74 -71
- package/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.ts +28 -2
- package/src/logic/proxy/ProxyClient.ts +11 -11
- package/src/logic/proxy/ProxyConnectionRpcLocal.ts +9 -11
- package/src/logic/proxy/ProxyConnectionRpcRemote.ts +1 -1
- package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +14 -6
- package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +2 -2
- package/src/proto/google/protobuf/any.ts +11 -4
- package/src/proto/google/protobuf/empty.ts +0 -1
- package/src/proto/google/protobuf/timestamp.ts +9 -3
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +22 -9
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +10 -4
- package/src/proto/packages/dht/protos/DhtRpc.ts +122 -100
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +8 -8
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +2 -2
- package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +79 -37
- package/test/benchmark/StreamPartIdDataKeyDistribution.test.ts +60 -0
- package/test/benchmark/first-message.ts +5 -5
- package/test/end-to-end/inspect.test.ts +6 -6
- package/test/end-to-end/proxy-and-full-node.test.ts +19 -19
- package/test/end-to-end/proxy-connections.test.ts +7 -7
- package/test/end-to-end/proxy-key-exchange.test.ts +16 -13
- package/test/end-to-end/webrtc-full-node-network.test.ts +8 -8
- package/test/end-to-end/websocket-full-node-network.test.ts +9 -9
- package/test/integration/ContentDeliveryManager.test.ts +135 -0
- package/test/integration/{DeliveryRpcRemote.test.ts → ContentDeliveryRpcRemote.test.ts} +6 -6
- package/test/integration/Handshakes.test.ts +7 -3
- package/test/integration/Inspect.test.ts +2 -2
- package/test/integration/NetworkRpc.test.ts +3 -3
- package/test/integration/NetworkStack.test.ts +7 -7
- package/test/integration/NodeInfoRpc.test.ts +10 -10
- package/test/integration/joining-streams-on-offline-peers.test.ts +3 -3
- package/test/integration/stream-without-default-entrypoints.test.ts +1 -1
- package/test/integration/streamEntryPointReplacing.test.ts +10 -8
- package/test/unit/ContentDeliveryManager.test.ts +96 -0
- package/test/unit/{DeliveryRpcLocal.test.ts → ContentDeliveryRpcLocal.test.ts} +4 -4
- package/test/unit/EntrypointDiscovery.test.ts +4 -4
- package/test/unit/HandshakeRpcLocal.test.ts +31 -15
- package/test/unit/Handshaker.test.ts +8 -3
- package/test/unit/NeighborFinder.test.ts +5 -2
- package/test/unit/NeighborUpdateRpcLocal.test.ts +8 -12
- package/test/unit/NetworkNode.test.ts +6 -6
- package/test/unit/NodeList.test.ts +6 -6
- package/test/unit/Propagation.test.ts +10 -7
- package/test/unit/RandomGraphNode.test.ts +3 -3
- package/test/unit/StreamMessageTranslator.test.ts +3 -4
- package/test/unit/StreamPartIDDataKey.test.ts +12 -0
- package/test/unit/TemporaryConnectionRpcLocal.test.ts +7 -1
- package/test/utils/mock/MockLayer0Node.ts +1 -1
- package/test/utils/mock/MockLayer1Node.ts +3 -0
- package/test/utils/utils.ts +19 -13
- package/dist/src/logic/DeliveryRpcLocal.js.map +0 -1
- package/dist/src/logic/DeliveryRpcRemote.js.map +0 -1
- package/dist/src/logic/StreamrNode.js.map +0 -1
- package/test/integration/StreamrNode.test.ts +0 -131
- package/test/unit/GroupKeyRequestTranslator.test.ts +0 -36
- package/test/unit/StreamrNode.test.ts +0 -98
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
StreamMessage as OldStreamMessage,
|
|
4
|
-
StreamMessageType as OldStreamMessageType,
|
|
5
|
-
MessageRef as OldMessageRef,
|
|
2
|
+
ContentType as OldContentType,
|
|
6
3
|
EncryptedGroupKey as OldEncryptedGroupKey,
|
|
7
|
-
StreamID,
|
|
8
4
|
EncryptionType as OldEncryptionType,
|
|
5
|
+
MessageID as OldMessageID,
|
|
6
|
+
MessageRef as OldMessageRef,
|
|
9
7
|
SignatureType as OldSignatureType,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
deserializeGroupKeyRequest as deserializeOldGroupKeyRequest,
|
|
14
|
-
deserializeGroupKeyResponse as deserializeOldGroupKeyResponse
|
|
8
|
+
StreamID,
|
|
9
|
+
StreamMessage as OldStreamMessage,
|
|
10
|
+
StreamMessageType as OldStreamMessageType
|
|
15
11
|
} from '@streamr/protocol'
|
|
16
12
|
import {
|
|
17
13
|
ContentType,
|
|
18
|
-
GroupKey,
|
|
19
14
|
EncryptionType,
|
|
15
|
+
GroupKey,
|
|
20
16
|
GroupKeyRequest,
|
|
21
17
|
GroupKeyResponse,
|
|
18
|
+
MessageID,
|
|
22
19
|
MessageRef,
|
|
23
20
|
SignatureType,
|
|
24
|
-
StreamMessage
|
|
25
|
-
StreamMessageType,
|
|
26
|
-
MessageID
|
|
21
|
+
StreamMessage
|
|
27
22
|
} from '../../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
28
|
-
import {
|
|
29
|
-
import { GroupKeyRequestTranslator } from './GroupKeyRequestTranslator'
|
|
30
|
-
import { GroupKeyResponseTranslator } from './GroupKeyResponseTranslator'
|
|
23
|
+
import { binaryToHex, hexToBinary, toEthereumAddress } from '@streamr/utils'
|
|
31
24
|
|
|
32
25
|
const oldToNewEncryptionType = (type: OldEncryptionType): EncryptionType => {
|
|
33
26
|
if (type === OldEncryptionType.AES) {
|
|
@@ -61,6 +54,9 @@ const oldToNewSignatureType = (type: OldSignatureType): SignatureType => {
|
|
|
61
54
|
if (type === OldSignatureType.LEGACY_SECP256K1) {
|
|
62
55
|
return SignatureType.LEGACY_SECP256K1
|
|
63
56
|
}
|
|
57
|
+
if (type === OldSignatureType.ERC_1271) {
|
|
58
|
+
return SignatureType.ERC_1271
|
|
59
|
+
}
|
|
64
60
|
return SignatureType.SECP256K1
|
|
65
61
|
}
|
|
66
62
|
|
|
@@ -68,6 +64,9 @@ const newToOldSignatureType = (type: SignatureType): OldSignatureType => {
|
|
|
68
64
|
if (type === SignatureType.LEGACY_SECP256K1) {
|
|
69
65
|
return OldSignatureType.LEGACY_SECP256K1
|
|
70
66
|
}
|
|
67
|
+
if (type === SignatureType.ERC_1271) {
|
|
68
|
+
return OldSignatureType.ERC_1271
|
|
69
|
+
}
|
|
71
70
|
return OldSignatureType.SECP256K1
|
|
72
71
|
|
|
73
72
|
}
|
|
@@ -76,24 +75,6 @@ const newToOldSignatureType = (type: SignatureType): OldSignatureType => {
|
|
|
76
75
|
export class StreamMessageTranslator {
|
|
77
76
|
|
|
78
77
|
static toProtobuf(msg: OldStreamMessage): StreamMessage {
|
|
79
|
-
let content: Uint8Array
|
|
80
|
-
let messageType: StreamMessageType
|
|
81
|
-
if (msg.messageType === OldStreamMessageType.MESSAGE) {
|
|
82
|
-
content = msg.content
|
|
83
|
-
messageType = StreamMessageType.MESSAGE
|
|
84
|
-
} else if (msg.messageType === OldStreamMessageType.GROUP_KEY_REQUEST) {
|
|
85
|
-
content = GroupKeyRequest.toBinary(
|
|
86
|
-
GroupKeyRequestTranslator.toProtobuf(deserializeOldGroupKeyRequest(msg.content))
|
|
87
|
-
)
|
|
88
|
-
messageType = StreamMessageType.GROUP_KEY_REQUEST
|
|
89
|
-
} else if (msg.messageType === OldStreamMessageType.GROUP_KEY_RESPONSE) {
|
|
90
|
-
content = GroupKeyResponse.toBinary(
|
|
91
|
-
GroupKeyResponseTranslator.toProtobuf(deserializeOldGroupKeyResponse(msg.content))
|
|
92
|
-
)
|
|
93
|
-
messageType = StreamMessageType.GROUP_KEY_RESPONSE
|
|
94
|
-
} else {
|
|
95
|
-
throw new Error('invalid message type')
|
|
96
|
-
}
|
|
97
78
|
const messageId: MessageID = {
|
|
98
79
|
timestamp: msg.getTimestamp(),
|
|
99
80
|
sequenceNumber: msg.getSequenceNumber(),
|
|
@@ -106,52 +87,81 @@ export class StreamMessageTranslator {
|
|
|
106
87
|
if (msg.prevMsgRef) {
|
|
107
88
|
previousMessageRef = {
|
|
108
89
|
timestamp: msg.prevMsgRef.timestamp,
|
|
109
|
-
sequenceNumber: msg.prevMsgRef.sequenceNumber
|
|
90
|
+
sequenceNumber: msg.prevMsgRef.sequenceNumber
|
|
110
91
|
}
|
|
111
92
|
}
|
|
112
|
-
let
|
|
113
|
-
if (msg.
|
|
114
|
-
newGroupKey =
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
let body: StreamMessage['body']
|
|
94
|
+
if (msg.messageType === OldStreamMessageType.MESSAGE) {
|
|
95
|
+
let newGroupKey: GroupKey | undefined = undefined
|
|
96
|
+
if (msg.newGroupKey) {
|
|
97
|
+
newGroupKey = {
|
|
98
|
+
id: msg.newGroupKey.id,
|
|
99
|
+
data: msg.newGroupKey.data
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
body = {
|
|
103
|
+
oneofKind: 'contentMessage',
|
|
104
|
+
contentMessage: {
|
|
105
|
+
content: msg.content,
|
|
106
|
+
contentType: oldToNewContentType(msg.contentType),
|
|
107
|
+
encryptionType: oldToNewEncryptionType(msg.encryptionType),
|
|
108
|
+
groupKeyId: msg.groupKeyId ?? undefined,
|
|
109
|
+
newGroupKey
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if (msg.messageType === OldStreamMessageType.GROUP_KEY_REQUEST) {
|
|
113
|
+
body = {
|
|
114
|
+
oneofKind: 'groupKeyRequest',
|
|
115
|
+
groupKeyRequest: GroupKeyRequest.fromBinary(msg.content)
|
|
117
116
|
}
|
|
117
|
+
} else if (msg.messageType === OldStreamMessageType.GROUP_KEY_RESPONSE) {
|
|
118
|
+
body = {
|
|
119
|
+
oneofKind: 'groupKeyResponse',
|
|
120
|
+
groupKeyResponse: GroupKeyResponse.fromBinary(msg.content)
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
throw new Error('invalid message type')
|
|
118
124
|
}
|
|
119
125
|
const translated: StreamMessage = {
|
|
120
126
|
messageId,
|
|
121
127
|
previousMessageRef,
|
|
122
|
-
content,
|
|
123
|
-
messageType,
|
|
124
|
-
contentType: oldToNewContentType(msg.contentType),
|
|
125
|
-
encryptionType: oldToNewEncryptionType(msg.encryptionType),
|
|
126
|
-
groupKeyId: msg.groupKeyId ?? undefined,
|
|
127
|
-
newGroupKey,
|
|
128
128
|
signature: msg.signature,
|
|
129
129
|
signatureType: oldToNewSignatureType(msg.signatureType),
|
|
130
|
+
body
|
|
130
131
|
}
|
|
131
132
|
return translated
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
static toClientProtocol(msg: StreamMessage): OldStreamMessage {
|
|
135
|
-
let content: Uint8Array
|
|
136
136
|
let messageType: OldStreamMessageType
|
|
137
|
-
|
|
137
|
+
let content: Uint8Array
|
|
138
|
+
let contentType: OldContentType = OldContentType.BINARY
|
|
139
|
+
let encryptionType: OldEncryptionType = OldEncryptionType.NONE
|
|
140
|
+
let newGroupKey: OldEncryptedGroupKey | undefined = undefined
|
|
141
|
+
let groupKeyId: string | undefined = undefined
|
|
142
|
+
if (msg.body.oneofKind === 'contentMessage') {
|
|
138
143
|
messageType = OldStreamMessageType.MESSAGE
|
|
139
|
-
content = msg.content
|
|
140
|
-
|
|
144
|
+
content = msg.body.contentMessage.content
|
|
145
|
+
contentType = newToOldContentType(msg.body.contentMessage.contentType)
|
|
146
|
+
encryptionType = newToOldEncryptionType(msg.body.contentMessage.encryptionType)
|
|
147
|
+
if (msg.body.contentMessage.newGroupKey) {
|
|
148
|
+
newGroupKey = new OldEncryptedGroupKey(
|
|
149
|
+
msg.body.contentMessage.newGroupKey.id,
|
|
150
|
+
msg.body.contentMessage.newGroupKey.data
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
groupKeyId = msg.body.contentMessage.groupKeyId
|
|
154
|
+
} else if (msg.body.oneofKind === 'groupKeyRequest') {
|
|
141
155
|
messageType = OldStreamMessageType.GROUP_KEY_REQUEST
|
|
142
156
|
try {
|
|
143
|
-
|
|
144
|
-
const oldGroupKeyRequest = GroupKeyRequestTranslator.toClientProtocol(parsedRequest)
|
|
145
|
-
content = serializeOldGroupKeyRequest(oldGroupKeyRequest)
|
|
157
|
+
content = GroupKeyRequest.toBinary(msg.body.groupKeyRequest)
|
|
146
158
|
} catch (err) {
|
|
147
159
|
throw new Error(`invalid group key request: ${err}`)
|
|
148
160
|
}
|
|
149
|
-
} else if (msg.
|
|
161
|
+
} else if (msg.body.oneofKind === 'groupKeyResponse') {
|
|
150
162
|
messageType = OldStreamMessageType.GROUP_KEY_RESPONSE
|
|
151
163
|
try {
|
|
152
|
-
|
|
153
|
-
const oldGroupKeyResponse = GroupKeyResponseTranslator.toClientProtocol(parsedResponse)
|
|
154
|
-
content = serializeOldGroupKeyResponse(oldGroupKeyResponse)
|
|
164
|
+
content = GroupKeyResponse.toBinary(msg.body.groupKeyResponse)
|
|
155
165
|
} catch (err) {
|
|
156
166
|
throw new Error(`invalid group key response: ${err}`)
|
|
157
167
|
}
|
|
@@ -170,24 +180,17 @@ export class StreamMessageTranslator {
|
|
|
170
180
|
if (msg.previousMessageRef) {
|
|
171
181
|
prevMsgRef = new OldMessageRef(Number(msg.previousMessageRef.timestamp), msg.previousMessageRef.sequenceNumber)
|
|
172
182
|
}
|
|
173
|
-
let newGroupKey: OldEncryptedGroupKey | undefined = undefined
|
|
174
|
-
if (msg.newGroupKey) {
|
|
175
|
-
newGroupKey = new OldEncryptedGroupKey(
|
|
176
|
-
msg.newGroupKey.id,
|
|
177
|
-
msg.newGroupKey.data,
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
183
|
const translated = new OldStreamMessage({
|
|
181
184
|
messageId,
|
|
182
185
|
prevMsgRef,
|
|
183
|
-
content,
|
|
184
186
|
messageType,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
groupKeyId: msg.groupKeyId,
|
|
188
|
-
newGroupKey,
|
|
187
|
+
content,
|
|
188
|
+
contentType,
|
|
189
189
|
signature: msg.signature,
|
|
190
|
-
signatureType: newToOldSignatureType(msg.signatureType)
|
|
190
|
+
signatureType: newToOldSignatureType(msg.signatureType),
|
|
191
|
+
encryptionType,
|
|
192
|
+
groupKeyId,
|
|
193
|
+
newGroupKey
|
|
191
194
|
})
|
|
192
195
|
return translated
|
|
193
196
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
StreamMessage as OldStreamMessage,
|
|
3
|
+
GroupKeyRequest as OldGroupKeyRequest,
|
|
4
|
+
GroupKeyResponse as OldGroupKeyResponse
|
|
5
|
+
} from '@streamr/protocol'
|
|
2
6
|
import { StreamMessageTranslator } from './StreamMessageTranslator'
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
StreamMessage,
|
|
9
|
+
GroupKeyRequest,
|
|
10
|
+
GroupKeyResponse
|
|
11
|
+
} from '../../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
12
|
+
import { GroupKeyResponseTranslator } from './GroupKeyResponseTranslator'
|
|
13
|
+
import { GroupKeyRequestTranslator } from './GroupKeyRequestTranslator'
|
|
4
14
|
|
|
5
15
|
export function convertStreamMessageToBytes(oldStreamMessage: OldStreamMessage): Uint8Array {
|
|
6
16
|
return StreamMessage.toBinary(StreamMessageTranslator.toProtobuf(oldStreamMessage))
|
|
@@ -9,3 +19,19 @@ export function convertStreamMessageToBytes(oldStreamMessage: OldStreamMessage):
|
|
|
9
19
|
export function convertBytesToStreamMessage(bytes: Uint8Array): OldStreamMessage {
|
|
10
20
|
return StreamMessageTranslator.toClientProtocol(StreamMessage.fromBinary(bytes))
|
|
11
21
|
}
|
|
22
|
+
|
|
23
|
+
export const convertGroupKeyRequestToBytes = (oldGroupKeyRequest: OldGroupKeyRequest): Uint8Array => {
|
|
24
|
+
return GroupKeyRequest.toBinary(GroupKeyRequestTranslator.toProtobuf(oldGroupKeyRequest))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const convertBytesToGroupKeyRequest = (bytes: Uint8Array): OldGroupKeyRequest => {
|
|
28
|
+
return GroupKeyRequestTranslator.toClientProtocol(GroupKeyRequest.fromBinary(bytes))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const convertGroupKeyResponseToBytes = (oldGroupKeyResponse: OldGroupKeyResponse): Uint8Array => {
|
|
32
|
+
return GroupKeyResponse.toBinary(GroupKeyResponseTranslator.toProtobuf(oldGroupKeyResponse))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const convertBytesToGroupKeyResponse = (bytes: Uint8Array): OldGroupKeyResponse => {
|
|
36
|
+
return GroupKeyResponseTranslator.toClientProtocol(GroupKeyResponse.fromBinary(bytes))
|
|
37
|
+
}
|
|
@@ -17,15 +17,15 @@ import {
|
|
|
17
17
|
ProxyDirection,
|
|
18
18
|
StreamMessage
|
|
19
19
|
} from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
20
|
-
import {
|
|
20
|
+
import { ContentDeliveryRpcClient, ProxyConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
21
21
|
import { DuplicateMessageDetector } from '../DuplicateMessageDetector'
|
|
22
22
|
import { NodeList } from '../NodeList'
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
23
|
+
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
24
|
+
import { ContentDeliveryRpcLocal } from '../ContentDeliveryRpcLocal'
|
|
25
25
|
import { Propagation } from '../propagation/Propagation'
|
|
26
26
|
import { markAndCheckDuplicate } from '../utils'
|
|
27
27
|
import { ProxyConnectionRpcRemote } from './ProxyConnectionRpcRemote'
|
|
28
|
-
import {
|
|
28
|
+
import { formStreamPartContentDeliveryServiceId } from '../formStreamPartDeliveryServiceId'
|
|
29
29
|
|
|
30
30
|
// TODO use config option or named constant?
|
|
31
31
|
export const retry = async <T>(task: () => Promise<T>, description: string, abortSignal: AbortSignal, delay = 10000): Promise<T> => {
|
|
@@ -74,7 +74,7 @@ const SERVICE_ID = 'system/proxy-client'
|
|
|
74
74
|
export class ProxyClient extends EventEmitter<Events> {
|
|
75
75
|
|
|
76
76
|
private readonly rpcCommunicator: ListeningRpcCommunicator
|
|
77
|
-
private readonly
|
|
77
|
+
private readonly contentDeliveryRpcLocal: ContentDeliveryRpcLocal
|
|
78
78
|
private readonly config: ProxyClientConfig
|
|
79
79
|
private readonly duplicateDetectors: Map<string, DuplicateMessageDetector> = new Map()
|
|
80
80
|
private definition?: ProxyDefinition
|
|
@@ -86,10 +86,10 @@ export class ProxyClient extends EventEmitter<Events> {
|
|
|
86
86
|
constructor(config: ProxyClientConfig) {
|
|
87
87
|
super()
|
|
88
88
|
this.config = config
|
|
89
|
-
this.rpcCommunicator = new ListeningRpcCommunicator(
|
|
89
|
+
this.rpcCommunicator = new ListeningRpcCommunicator(formStreamPartContentDeliveryServiceId(config.streamPartId), config.transport)
|
|
90
90
|
// TODO use config option or named constant?
|
|
91
91
|
this.neighbors = new NodeList(getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor), 1000)
|
|
92
|
-
this.
|
|
92
|
+
this.contentDeliveryRpcLocal = new ContentDeliveryRpcLocal({
|
|
93
93
|
localPeerDescriptor: this.config.localPeerDescriptor,
|
|
94
94
|
streamPartId: this.config.streamPartId,
|
|
95
95
|
markAndCheckDuplicate: (msg: MessageID, prev?: MessageRef) => markAndCheckDuplicate(this.duplicateDetectors, msg, prev),
|
|
@@ -121,9 +121,9 @@ export class ProxyClient extends EventEmitter<Events> {
|
|
|
121
121
|
|
|
122
122
|
private registerDefaultServerMethods(): void {
|
|
123
123
|
this.rpcCommunicator.registerRpcNotification(StreamMessage, 'sendStreamMessage',
|
|
124
|
-
(msg: StreamMessage, context) => this.
|
|
124
|
+
(msg: StreamMessage, context) => this.contentDeliveryRpcLocal.sendStreamMessage(msg, context))
|
|
125
125
|
this.rpcCommunicator.registerRpcNotification(LeaveStreamPartNotice, 'leaveStreamPartNotice',
|
|
126
|
-
(req: LeaveStreamPartNotice, context) => this.
|
|
126
|
+
(req: LeaveStreamPartNotice, context) => this.contentDeliveryRpcLocal.leaveStreamPartNotice(req, context))
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
async setProxies(
|
|
@@ -189,11 +189,11 @@ export class ProxyClient extends EventEmitter<Events> {
|
|
|
189
189
|
if (accepted) {
|
|
190
190
|
this.config.connectionLocker.lockConnection(peerDescriptor, SERVICE_ID)
|
|
191
191
|
this.connections.set(nodeId, { peerDescriptor, direction })
|
|
192
|
-
const remote = new
|
|
192
|
+
const remote = new ContentDeliveryRpcRemote(
|
|
193
193
|
this.config.localPeerDescriptor,
|
|
194
194
|
peerDescriptor,
|
|
195
195
|
this.rpcCommunicator,
|
|
196
|
-
|
|
196
|
+
ContentDeliveryRpcClient
|
|
197
197
|
)
|
|
198
198
|
this.neighbors.add(remote)
|
|
199
199
|
this.propagation.onNeighborJoined(nodeId)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import {
|
|
3
|
-
GroupKeyRequest,
|
|
4
3
|
ProxyConnectionRequest,
|
|
5
4
|
ProxyConnectionResponse,
|
|
6
5
|
ProxyDirection,
|
|
7
|
-
StreamMessage
|
|
8
|
-
StreamMessageType
|
|
6
|
+
StreamMessage
|
|
9
7
|
} from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
10
8
|
import { IProxyConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
11
|
-
import {
|
|
9
|
+
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
12
10
|
import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
|
|
13
|
-
import {
|
|
11
|
+
import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
14
12
|
import { EventEmitter } from 'eventemitter3'
|
|
15
13
|
import { EthereumAddress, Logger, binaryToHex, toEthereumAddress } from '@streamr/utils'
|
|
16
14
|
import { StreamPartID } from '@streamr/protocol'
|
|
@@ -20,7 +18,7 @@ const logger = new Logger(module)
|
|
|
20
18
|
interface ProxyConnection {
|
|
21
19
|
direction: ProxyDirection // Direction is from the client's point of view
|
|
22
20
|
userId: EthereumAddress
|
|
23
|
-
remote:
|
|
21
|
+
remote: ContentDeliveryRpcRemote
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
interface ProxyConnectionRpcLocalConfig {
|
|
@@ -64,12 +62,12 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
|
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
getPropagationTargets(msg: StreamMessage): DhtAddress[] {
|
|
67
|
-
if (msg.
|
|
65
|
+
if (msg.body.oneofKind === 'groupKeyRequest') {
|
|
68
66
|
try {
|
|
69
|
-
const recipientId =
|
|
67
|
+
const recipientId = msg.body.groupKeyRequest.recipientId
|
|
70
68
|
return this.getNodeIdsForUserId(toEthereumAddress(binaryToHex(recipientId, true)))
|
|
71
69
|
} catch (err) {
|
|
72
|
-
logger.trace(`Could not parse GroupKeyRequest
|
|
70
|
+
logger.trace(`Could not parse GroupKeyRequest`, { err })
|
|
73
71
|
return []
|
|
74
72
|
}
|
|
75
73
|
} else {
|
|
@@ -92,11 +90,11 @@ export class ProxyConnectionRpcLocal extends EventEmitter<Events> implements IPr
|
|
|
92
90
|
this.connections.set(senderId, {
|
|
93
91
|
direction: request.direction,
|
|
94
92
|
userId: toEthereumAddress(binaryToHex(request.userId, true)),
|
|
95
|
-
remote: new
|
|
93
|
+
remote: new ContentDeliveryRpcRemote(
|
|
96
94
|
this.config.localPeerDescriptor,
|
|
97
95
|
senderPeerDescriptor,
|
|
98
96
|
this.config.rpcCommunicator,
|
|
99
|
-
|
|
97
|
+
ContentDeliveryRpcClient
|
|
100
98
|
)
|
|
101
99
|
})
|
|
102
100
|
const response: ProxyConnectionResponse = {
|
|
@@ -19,7 +19,7 @@ export class ProxyConnectionRpcRemote extends RpcRemote<ProxyConnectionRpcClient
|
|
|
19
19
|
const res = await this.getClient().requestConnection(request, options)
|
|
20
20
|
return res.accepted
|
|
21
21
|
} catch (err) {
|
|
22
|
-
logger.debug(`ProxyConnectionRequest failed with error
|
|
22
|
+
logger.debug(`ProxyConnectionRequest failed with error`, { err })
|
|
23
23
|
return false
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -5,27 +5,33 @@ import {
|
|
|
5
5
|
TemporaryConnectionResponse
|
|
6
6
|
} from '../../proto/packages/trackerless-network/protos/NetworkRpc'
|
|
7
7
|
import { ITemporaryConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
|
|
8
|
-
import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
|
|
9
|
-
import {
|
|
8
|
+
import { ConnectionLocker, DhtAddress, DhtCallContext, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
|
|
9
|
+
import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
|
|
10
10
|
import { NodeList } from '../NodeList'
|
|
11
|
-
import {
|
|
11
|
+
import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
|
|
12
12
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
|
|
13
13
|
import { Empty } from '../../proto/google/protobuf/empty'
|
|
14
|
+
import { StreamPartID } from '@streamr/protocol'
|
|
14
15
|
|
|
15
16
|
interface TemporaryConnectionRpcLocalConfig {
|
|
16
17
|
rpcCommunicator: ListeningRpcCommunicator
|
|
17
18
|
localPeerDescriptor: PeerDescriptor
|
|
19
|
+
streamPartId: StreamPartID
|
|
20
|
+
connectionLocker: ConnectionLocker
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
const LOCK_ID_BASE = 'system/content-delivery/temporary-connection/'
|
|
24
|
+
|
|
20
25
|
export class TemporaryConnectionRpcLocal implements ITemporaryConnectionRpc {
|
|
21
26
|
|
|
22
27
|
private readonly config: TemporaryConnectionRpcLocalConfig
|
|
23
28
|
private readonly temporaryNodes: NodeList
|
|
24
|
-
|
|
29
|
+
private readonly lockId: string
|
|
25
30
|
constructor(config: TemporaryConnectionRpcLocalConfig) {
|
|
26
31
|
this.config = config
|
|
27
32
|
// TODO use config option or named constant?
|
|
28
33
|
this.temporaryNodes = new NodeList(getNodeIdFromPeerDescriptor(config.localPeerDescriptor), 10)
|
|
34
|
+
this.lockId = LOCK_ID_BASE + config.streamPartId
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
getNodes(): NodeList {
|
|
@@ -38,6 +44,7 @@ export class TemporaryConnectionRpcLocal implements ITemporaryConnectionRpc {
|
|
|
38
44
|
|
|
39
45
|
removeNode(nodeId: DhtAddress): void {
|
|
40
46
|
this.temporaryNodes.remove(nodeId)
|
|
47
|
+
this.config.connectionLocker.weakUnlockConnection(nodeId, this.lockId)
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
async openConnection(
|
|
@@ -45,13 +52,14 @@ export class TemporaryConnectionRpcLocal implements ITemporaryConnectionRpc {
|
|
|
45
52
|
context: ServerCallContext
|
|
46
53
|
): Promise<TemporaryConnectionResponse> {
|
|
47
54
|
const sender = (context as DhtCallContext).incomingSourceDescriptor!
|
|
48
|
-
const remote = new
|
|
55
|
+
const remote = new ContentDeliveryRpcRemote(
|
|
49
56
|
this.config.localPeerDescriptor,
|
|
50
57
|
sender,
|
|
51
58
|
this.config.rpcCommunicator,
|
|
52
|
-
|
|
59
|
+
ContentDeliveryRpcClient
|
|
53
60
|
)
|
|
54
61
|
this.temporaryNodes.add(remote)
|
|
62
|
+
this.config.connectionLocker.weakLockConnection(getNodeIdFromPeerDescriptor(sender), this.lockId)
|
|
55
63
|
return {
|
|
56
64
|
accepted: true
|
|
57
65
|
}
|
|
@@ -11,7 +11,7 @@ export class TemporaryConnectionRpcRemote extends RpcRemote<TemporaryConnectionR
|
|
|
11
11
|
const response = await this.getClient().openConnection({}, this.formDhtRpcOptions())
|
|
12
12
|
return response.accepted
|
|
13
13
|
} catch (err: any) {
|
|
14
|
-
logger.debug(`temporaryConnection to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} failed
|
|
14
|
+
logger.debug(`temporaryConnection to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} failed`, { err })
|
|
15
15
|
return false
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -23,7 +23,7 @@ export class TemporaryConnectionRpcRemote extends RpcRemote<TemporaryConnectionR
|
|
|
23
23
|
notification: true
|
|
24
24
|
}))
|
|
25
25
|
} catch (err) {
|
|
26
|
-
logger.trace(`closeConnection to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} failed
|
|
26
|
+
logger.trace(`closeConnection to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())} failed`, { err })
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -73,6 +73,10 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
73
73
|
* if (any.is(Foo.class)) {
|
|
74
74
|
* foo = any.unpack(Foo.class);
|
|
75
75
|
* }
|
|
76
|
+
* // or ...
|
|
77
|
+
* if (any.isSameTypeAs(Foo.getDefaultInstance())) {
|
|
78
|
+
* foo = any.unpack(Foo.getDefaultInstance());
|
|
79
|
+
* }
|
|
76
80
|
*
|
|
77
81
|
* Example 3: Pack and unpack a message in Python.
|
|
78
82
|
*
|
|
@@ -87,10 +91,13 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
87
91
|
* Example 4: Pack and unpack a message in Go
|
|
88
92
|
*
|
|
89
93
|
* foo := &pb.Foo{...}
|
|
90
|
-
* any, err :=
|
|
94
|
+
* any, err := anypb.New(foo)
|
|
95
|
+
* if err != nil {
|
|
96
|
+
* ...
|
|
97
|
+
* }
|
|
91
98
|
* ...
|
|
92
99
|
* foo := &pb.Foo{}
|
|
93
|
-
* if err :=
|
|
100
|
+
* if err := any.UnmarshalTo(foo); err != nil {
|
|
94
101
|
* ...
|
|
95
102
|
* }
|
|
96
103
|
*
|
|
@@ -100,7 +107,6 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
100
107
|
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
101
108
|
* name "y.z".
|
|
102
109
|
*
|
|
103
|
-
*
|
|
104
110
|
* JSON
|
|
105
111
|
* ====
|
|
106
112
|
* The JSON representation of an `Any` value uses the regular
|
|
@@ -157,7 +163,8 @@ export interface Any {
|
|
|
157
163
|
*
|
|
158
164
|
* Note: this functionality is not currently available in the official
|
|
159
165
|
* protobuf release, and it is not used for type URLs beginning with
|
|
160
|
-
* type.googleapis.com.
|
|
166
|
+
* type.googleapis.com. As of May 2023, there are no widely used type server
|
|
167
|
+
* implementations and no plans to implement one.
|
|
161
168
|
*
|
|
162
169
|
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
163
170
|
* used with implementation specific semantics.
|
|
@@ -49,7 +49,6 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
49
49
|
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
50
50
|
* }
|
|
51
51
|
*
|
|
52
|
-
* The JSON representation for `Empty` is empty JSON object `{}`.
|
|
53
52
|
*
|
|
54
53
|
* @generated from protobuf message google.protobuf.Empty
|
|
55
54
|
*/
|
|
@@ -97,8 +97,15 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
97
97
|
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
98
98
|
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
99
99
|
*
|
|
100
|
+
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
100
101
|
*
|
|
101
|
-
*
|
|
102
|
+
* Instant now = Instant.now();
|
|
103
|
+
*
|
|
104
|
+
* Timestamp timestamp =
|
|
105
|
+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
106
|
+
* .setNanos(now.getNano()).build();
|
|
107
|
+
*
|
|
108
|
+
* Example 6: Compute Timestamp from current time in Python.
|
|
102
109
|
*
|
|
103
110
|
* timestamp = Timestamp()
|
|
104
111
|
* timestamp.GetCurrentTime()
|
|
@@ -127,11 +134,10 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
127
134
|
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
128
135
|
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
129
136
|
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
130
|
-
* http://
|
|
137
|
+
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
131
138
|
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
132
139
|
*
|
|
133
140
|
*
|
|
134
|
-
*
|
|
135
141
|
* @generated from protobuf message google.protobuf.Timestamp
|
|
136
142
|
*/
|
|
137
143
|
export interface Timestamp {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { ExternalApiRpc } from "./DhtRpc";
|
|
5
5
|
import type { ExternalStoreDataResponse } from "./DhtRpc";
|
|
6
6
|
import type { ExternalStoreDataRequest } from "./DhtRpc";
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
7
|
+
import type { ExternalFetchDataResponse } from "./DhtRpc";
|
|
8
|
+
import type { ExternalFetchDataRequest } from "./DhtRpc";
|
|
9
9
|
import { ConnectionLockRpc } from "./DhtRpc";
|
|
10
10
|
import type { DisconnectNotice } from "./DhtRpc";
|
|
11
11
|
import type { UnlockRequest } from "./DhtRpc";
|
|
@@ -35,6 +35,8 @@ import type { Empty } from "../../../google/protobuf/empty";
|
|
|
35
35
|
import type { LeaveNotice } from "./DhtRpc";
|
|
36
36
|
import type { PingResponse } from "./DhtRpc";
|
|
37
37
|
import type { PingRequest } from "./DhtRpc";
|
|
38
|
+
import type { ClosestRingPeersResponse } from "./DhtRpc";
|
|
39
|
+
import type { ClosestRingPeersRequest } from "./DhtRpc";
|
|
38
40
|
import { stackIntercept } from "@protobuf-ts/runtime-rpc";
|
|
39
41
|
import type { ClosestPeersResponse } from "./DhtRpc";
|
|
40
42
|
import type { ClosestPeersRequest } from "./DhtRpc";
|
|
@@ -48,6 +50,10 @@ export interface IDhtNodeRpcClient {
|
|
|
48
50
|
* @generated from protobuf rpc: getClosestPeers(dht.ClosestPeersRequest) returns (dht.ClosestPeersResponse);
|
|
49
51
|
*/
|
|
50
52
|
getClosestPeers(input: ClosestPeersRequest, options?: RpcOptions): UnaryCall<ClosestPeersRequest, ClosestPeersResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* @generated from protobuf rpc: getClosestRingPeers(dht.ClosestRingPeersRequest) returns (dht.ClosestRingPeersResponse);
|
|
55
|
+
*/
|
|
56
|
+
getClosestRingPeers(input: ClosestRingPeersRequest, options?: RpcOptions): UnaryCall<ClosestRingPeersRequest, ClosestRingPeersResponse>;
|
|
51
57
|
/**
|
|
52
58
|
* @generated from protobuf rpc: ping(dht.PingRequest) returns (dht.PingResponse);
|
|
53
59
|
*/
|
|
@@ -73,18 +79,25 @@ export class DhtNodeRpcClient implements IDhtNodeRpcClient, ServiceInfo {
|
|
|
73
79
|
const method = this.methods[0], opt = this._transport.mergeOptions(options);
|
|
74
80
|
return stackIntercept<ClosestPeersRequest, ClosestPeersResponse>("unary", this._transport, method, opt, input);
|
|
75
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* @generated from protobuf rpc: getClosestRingPeers(dht.ClosestRingPeersRequest) returns (dht.ClosestRingPeersResponse);
|
|
84
|
+
*/
|
|
85
|
+
getClosestRingPeers(input: ClosestRingPeersRequest, options?: RpcOptions): UnaryCall<ClosestRingPeersRequest, ClosestRingPeersResponse> {
|
|
86
|
+
const method = this.methods[1], opt = this._transport.mergeOptions(options);
|
|
87
|
+
return stackIntercept<ClosestRingPeersRequest, ClosestRingPeersResponse>("unary", this._transport, method, opt, input);
|
|
88
|
+
}
|
|
76
89
|
/**
|
|
77
90
|
* @generated from protobuf rpc: ping(dht.PingRequest) returns (dht.PingResponse);
|
|
78
91
|
*/
|
|
79
92
|
ping(input: PingRequest, options?: RpcOptions): UnaryCall<PingRequest, PingResponse> {
|
|
80
|
-
const method = this.methods[
|
|
93
|
+
const method = this.methods[2], opt = this._transport.mergeOptions(options);
|
|
81
94
|
return stackIntercept<PingRequest, PingResponse>("unary", this._transport, method, opt, input);
|
|
82
95
|
}
|
|
83
96
|
/**
|
|
84
97
|
* @generated from protobuf rpc: leaveNotice(dht.LeaveNotice) returns (google.protobuf.Empty);
|
|
85
98
|
*/
|
|
86
99
|
leaveNotice(input: LeaveNotice, options?: RpcOptions): UnaryCall<LeaveNotice, Empty> {
|
|
87
|
-
const method = this.methods[
|
|
100
|
+
const method = this.methods[3], opt = this._transport.mergeOptions(options);
|
|
88
101
|
return stackIntercept<LeaveNotice, Empty>("unary", this._transport, method, opt, input);
|
|
89
102
|
}
|
|
90
103
|
}
|
|
@@ -352,9 +365,9 @@ export class ConnectionLockRpcClient implements IConnectionLockRpcClient, Servic
|
|
|
352
365
|
*/
|
|
353
366
|
export interface IExternalApiRpcClient {
|
|
354
367
|
/**
|
|
355
|
-
* @generated from protobuf rpc:
|
|
368
|
+
* @generated from protobuf rpc: externalFetchData(dht.ExternalFetchDataRequest) returns (dht.ExternalFetchDataResponse);
|
|
356
369
|
*/
|
|
357
|
-
|
|
370
|
+
externalFetchData(input: ExternalFetchDataRequest, options?: RpcOptions): UnaryCall<ExternalFetchDataRequest, ExternalFetchDataResponse>;
|
|
358
371
|
/**
|
|
359
372
|
* @generated from protobuf rpc: externalStoreData(dht.ExternalStoreDataRequest) returns (dht.ExternalStoreDataResponse);
|
|
360
373
|
*/
|
|
@@ -370,11 +383,11 @@ export class ExternalApiRpcClient implements IExternalApiRpcClient, ServiceInfo
|
|
|
370
383
|
constructor(private readonly _transport: RpcTransport) {
|
|
371
384
|
}
|
|
372
385
|
/**
|
|
373
|
-
* @generated from protobuf rpc:
|
|
386
|
+
* @generated from protobuf rpc: externalFetchData(dht.ExternalFetchDataRequest) returns (dht.ExternalFetchDataResponse);
|
|
374
387
|
*/
|
|
375
|
-
|
|
388
|
+
externalFetchData(input: ExternalFetchDataRequest, options?: RpcOptions): UnaryCall<ExternalFetchDataRequest, ExternalFetchDataResponse> {
|
|
376
389
|
const method = this.methods[0], opt = this._transport.mergeOptions(options);
|
|
377
|
-
return stackIntercept<
|
|
390
|
+
return stackIntercept<ExternalFetchDataRequest, ExternalFetchDataResponse>("unary", this._transport, method, opt, input);
|
|
378
391
|
}
|
|
379
392
|
/**
|
|
380
393
|
* @generated from protobuf rpc: externalStoreData(dht.ExternalStoreDataRequest) returns (dht.ExternalStoreDataResponse);
|