@waku/core 0.0.26-4c5a8a9.0 → 0.0.26-7eb3375.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/base_protocol-46017f51.js +468 -0
- package/bundle/{base_protocol-4bcf7514.js → browser-9a6558bb.js} +742 -451
- package/bundle/{index-27b91e3b.js → index-7581d519.js} +1 -1
- package/bundle/index.js +3742 -4917
- package/bundle/lib/base_protocol.js +3 -3
- package/bundle/lib/message/version_0.js +3 -3
- package/bundle/lib/predefined_bootstrap_nodes.js +1 -1
- package/bundle/{version_0-2f1176e3.js → version_0-7190df43.js} +7 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/connection_manager.d.ts +8 -4
- package/dist/lib/connection_manager.js +34 -12
- package/dist/lib/connection_manager.js.map +1 -1
- package/dist/lib/constants.d.ts +2 -2
- package/dist/lib/constants.js +2 -2
- package/dist/lib/filter/index.js +4 -4
- package/dist/lib/keep_alive_manager.d.ts +1 -0
- package/dist/lib/keep_alive_manager.js +4 -1
- package/dist/lib/keep_alive_manager.js.map +1 -1
- package/dist/lib/light_push/index.js +2 -2
- package/dist/lib/message/version_0.d.ts +6 -6
- package/dist/lib/message/version_0.js +3 -3
- package/dist/lib/store/index.js +11 -11
- package/dist/lib/waku.d.ts +4 -3
- package/dist/lib/waku.js +3 -0
- package/dist/lib/waku.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/lib/connection_manager.ts +44 -13
- package/src/lib/constants.ts +2 -2
- package/src/lib/filter/index.ts +11 -11
- package/src/lib/keep_alive_manager.ts +7 -1
- package/src/lib/light_push/index.ts +4 -4
- package/src/lib/message/version_0.ts +6 -6
- package/src/lib/store/index.ts +13 -13
- package/src/lib/waku.ts +6 -2
- package/bundle/browser-90197c87.js +0 -754
package/src/lib/store/index.ts
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
IStore,
|
8
8
|
Libp2p,
|
9
9
|
ProtocolCreateOptions,
|
10
|
-
|
10
|
+
PubsubTopic
|
11
11
|
} from "@waku/interfaces";
|
12
12
|
import { proto_store as proto } from "@waku/proto";
|
13
13
|
import { ensurePubsubTopicIsConfigured, isDefined } from "@waku/utils";
|
@@ -19,7 +19,7 @@ import { pipe } from "it-pipe";
|
|
19
19
|
import { Uint8ArrayList } from "uint8arraylist";
|
20
20
|
|
21
21
|
import { BaseProtocol } from "../base_protocol.js";
|
22
|
-
import {
|
22
|
+
import { DefaultPubsubTopic } from "../constants.js";
|
23
23
|
import { toProtoMessage } from "../to_proto_message.js";
|
24
24
|
|
25
25
|
import { HistoryRpc, PageDirection, Params } from "./history_rpc.js";
|
@@ -75,12 +75,12 @@ export interface QueryOptions {
|
|
75
75
|
* The Waku Store protocol can be used to retrieved historical messages.
|
76
76
|
*/
|
77
77
|
class Store extends BaseProtocol implements IStore {
|
78
|
-
private readonly pubsubTopics:
|
78
|
+
private readonly pubsubTopics: PubsubTopic[];
|
79
79
|
private readonly NUM_PEERS_PROTOCOL = 1;
|
80
80
|
|
81
81
|
constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
|
82
82
|
super(StoreCodec, libp2p.components);
|
83
|
-
this.pubsubTopics = options?.pubsubTopics ?? [
|
83
|
+
this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubsubTopic];
|
84
84
|
}
|
85
85
|
|
86
86
|
/**
|
@@ -230,29 +230,29 @@ class Store extends BaseProtocol implements IStore {
|
|
230
230
|
}
|
231
231
|
|
232
232
|
// convert array to set to remove duplicates
|
233
|
-
const
|
233
|
+
const uniquePubsubTopicsInQuery = Array.from(
|
234
234
|
new Set(decoders.map((decoder) => decoder.pubsubTopic))
|
235
235
|
);
|
236
236
|
|
237
237
|
// If multiple pubsub topics are provided, throw an error
|
238
|
-
if (
|
238
|
+
if (uniquePubsubTopicsInQuery.length > 1) {
|
239
239
|
throw new Error(
|
240
240
|
"API does not support querying multiple pubsub topics at once"
|
241
241
|
);
|
242
242
|
}
|
243
243
|
|
244
244
|
// we can be certain that there is only one pubsub topic in the query
|
245
|
-
const
|
245
|
+
const pubsubTopicForQuery = uniquePubsubTopicsInQuery[0];
|
246
246
|
|
247
|
-
ensurePubsubTopicIsConfigured(
|
247
|
+
ensurePubsubTopicIsConfigured(pubsubTopicForQuery, this.pubsubTopics);
|
248
248
|
|
249
249
|
// check that the pubsubTopic from the Cursor and Decoder match
|
250
250
|
if (
|
251
251
|
options?.cursor?.pubsubTopic &&
|
252
|
-
options.cursor.pubsubTopic !==
|
252
|
+
options.cursor.pubsubTopic !== pubsubTopicForQuery
|
253
253
|
) {
|
254
254
|
throw new Error(
|
255
|
-
`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${
|
255
|
+
`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubsubTopicForQuery})`
|
256
256
|
);
|
257
257
|
}
|
258
258
|
|
@@ -267,16 +267,16 @@ class Store extends BaseProtocol implements IStore {
|
|
267
267
|
});
|
268
268
|
|
269
269
|
const contentTopics = decoders
|
270
|
-
.filter((decoder) => decoder.pubsubTopic ===
|
270
|
+
.filter((decoder) => decoder.pubsubTopic === pubsubTopicForQuery)
|
271
271
|
.map((dec) => dec.contentTopic);
|
272
272
|
|
273
273
|
if (contentTopics.length === 0) {
|
274
|
-
throw new Error("No decoders found for topic " +
|
274
|
+
throw new Error("No decoders found for topic " + pubsubTopicForQuery);
|
275
275
|
}
|
276
276
|
|
277
277
|
const queryOpts = Object.assign(
|
278
278
|
{
|
279
|
-
pubsubTopic:
|
279
|
+
pubsubTopic: pubsubTopicForQuery,
|
280
280
|
pageDirection: PageDirection.BACKWARD,
|
281
281
|
pageSize: DefaultPageSize
|
282
282
|
},
|
package/src/lib/waku.ts
CHANGED
@@ -7,7 +7,7 @@ import type {
|
|
7
7
|
IRelay,
|
8
8
|
IStore,
|
9
9
|
Libp2p,
|
10
|
-
|
10
|
+
PubsubTopic,
|
11
11
|
Waku
|
12
12
|
} from "@waku/interfaces";
|
13
13
|
import { Protocols } from "@waku/interfaces";
|
@@ -53,7 +53,7 @@ export class WakuNode implements Waku {
|
|
53
53
|
|
54
54
|
constructor(
|
55
55
|
options: WakuOptions,
|
56
|
-
public readonly pubsubTopics:
|
56
|
+
public readonly pubsubTopics: PubsubTopic[],
|
57
57
|
libp2p: Libp2p,
|
58
58
|
store?: (libp2p: Libp2p) => IStore,
|
59
59
|
lightPush?: (libp2p: Libp2p) => ILightPush,
|
@@ -178,6 +178,10 @@ export class WakuNode implements Waku {
|
|
178
178
|
return this.libp2p.isStarted();
|
179
179
|
}
|
180
180
|
|
181
|
+
isConnected(): boolean {
|
182
|
+
return this.connectionManager.isConnected();
|
183
|
+
}
|
184
|
+
|
181
185
|
/**
|
182
186
|
* Return the local multiaddr with peer id on which libp2p is listening.
|
183
187
|
*
|