@waku/core 0.0.37-987c6cd.0 → 0.0.37-c24842a.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/bundle/index.js +168 -66
- package/bundle/lib/message/version_0.js +1 -1
- package/bundle/{version_0-BpF0pNhc.js → version_0-BHaZD8Qu.js} +172 -26
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/connection_manager/connection_limiter.d.ts +12 -3
- package/dist/lib/connection_manager/connection_limiter.js +98 -45
- package/dist/lib/connection_manager/connection_limiter.js.map +1 -1
- package/dist/lib/connection_manager/connection_manager.d.ts +1 -4
- package/dist/lib/connection_manager/connection_manager.js +15 -7
- package/dist/lib/connection_manager/connection_manager.js.map +1 -1
- package/dist/lib/connection_manager/dialer.d.ts +7 -1
- package/dist/lib/connection_manager/dialer.js +41 -6
- package/dist/lib/connection_manager/dialer.js.map +1 -1
- package/dist/lib/connection_manager/discovery_dialer.d.ts +1 -1
- package/dist/lib/connection_manager/discovery_dialer.js.map +1 -1
- package/dist/lib/metadata/metadata.d.ts +2 -2
- package/dist/lib/metadata/metadata.js +14 -8
- package/dist/lib/metadata/metadata.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/connection_manager/connection_limiter.ts +156 -65
- package/src/lib/connection_manager/connection_manager.ts +16 -12
- package/src/lib/connection_manager/dialer.ts +60 -7
- package/src/lib/connection_manager/discovery_dialer.ts +2 -4
- package/src/lib/metadata/metadata.ts +13 -12
@@ -1,16 +1,16 @@
|
|
1
1
|
import type { PeerId } from "@libp2p/interface";
|
2
2
|
import { IncomingStreamData } from "@libp2p/interface";
|
3
3
|
import {
|
4
|
+
type ClusterId,
|
4
5
|
type IMetadata,
|
5
6
|
type Libp2pComponents,
|
6
7
|
type MetadataQueryResult,
|
7
8
|
type PeerIdStr,
|
8
9
|
ProtocolError,
|
9
|
-
PubsubTopic,
|
10
10
|
type ShardInfo
|
11
11
|
} from "@waku/interfaces";
|
12
12
|
import { proto_metadata } from "@waku/proto";
|
13
|
-
import { encodeRelayShard, Logger
|
13
|
+
import { encodeRelayShard, Logger } from "@waku/utils";
|
14
14
|
import all from "it-all";
|
15
15
|
import * as lp from "it-length-prefixed";
|
16
16
|
import { pipe } from "it-pipe";
|
@@ -30,7 +30,7 @@ class Metadata implements IMetadata {
|
|
30
30
|
public readonly multicodec = MetadataCodec;
|
31
31
|
|
32
32
|
public constructor(
|
33
|
-
public
|
33
|
+
public clusterId: ClusterId,
|
34
34
|
libp2p: Libp2pComponents
|
35
35
|
) {
|
36
36
|
this.streamManager = new StreamManager(MetadataCodec, libp2p);
|
@@ -44,9 +44,10 @@ class Metadata implements IMetadata {
|
|
44
44
|
* Make a metadata query to a peer
|
45
45
|
*/
|
46
46
|
public async query(peerId: PeerId): Promise<MetadataQueryResult> {
|
47
|
-
const request = proto_metadata.WakuMetadataRequest.encode(
|
48
|
-
|
49
|
-
|
47
|
+
const request = proto_metadata.WakuMetadataRequest.encode({
|
48
|
+
clusterId: this.clusterId,
|
49
|
+
shards: [] // Only services node need to provide shards
|
50
|
+
});
|
50
51
|
|
51
52
|
const peer = await this.libp2pComponents.peerStore.get(peerId);
|
52
53
|
if (!peer) {
|
@@ -112,9 +113,10 @@ class Metadata implements IMetadata {
|
|
112
113
|
private async onRequest(streamData: IncomingStreamData): Promise<void> {
|
113
114
|
try {
|
114
115
|
const { stream, connection } = streamData;
|
115
|
-
const encodedShardInfo = proto_metadata.WakuMetadataResponse.encode(
|
116
|
-
|
117
|
-
|
116
|
+
const encodedShardInfo = proto_metadata.WakuMetadataResponse.encode({
|
117
|
+
clusterId: this.clusterId,
|
118
|
+
shards: [] // Only service nodes need to provide shards
|
119
|
+
});
|
118
120
|
|
119
121
|
const encodedResponse = await pipe(
|
120
122
|
[encodedShardInfo],
|
@@ -178,8 +180,7 @@ class Metadata implements IMetadata {
|
|
178
180
|
}
|
179
181
|
|
180
182
|
export function wakuMetadata(
|
181
|
-
|
183
|
+
clusterId: ClusterId
|
182
184
|
): (components: Libp2pComponents) => IMetadata {
|
183
|
-
return (components: Libp2pComponents) =>
|
184
|
-
new Metadata(pubsubTopics, components);
|
185
|
+
return (components: Libp2pComponents) => new Metadata(clusterId, components);
|
185
186
|
}
|