@waku/core 0.0.23 → 0.0.25-a42b7be.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/CHANGELOG.md +34 -0
- package/bundle/{base_protocol-84d9b670.js → base_protocol-4bcf7514.js} +194 -134
- package/bundle/{browser-bde977a3.js → browser-90197c87.js} +26 -1
- package/bundle/index-27b91e3b.js +31 -0
- package/bundle/index.js +19384 -2421
- package/bundle/lib/base_protocol.js +3 -2
- package/bundle/lib/message/version_0.js +3 -2
- package/bundle/lib/predefined_bootstrap_nodes.js +2 -0
- package/bundle/{version_0-74b4b9db.js → version_0-2f1176e3.js} +36 -24
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/connection_manager.d.ts +17 -4
- package/dist/lib/connection_manager.js +111 -45
- package/dist/lib/connection_manager.js.map +1 -1
- package/dist/lib/filter/index.js +53 -37
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/keep_alive_manager.d.ts +1 -0
- package/dist/lib/keep_alive_manager.js +42 -18
- package/dist/lib/keep_alive_manager.js.map +1 -1
- package/dist/lib/light_push/index.js +60 -38
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/light_push/push_rpc.d.ts +1 -1
- package/dist/lib/light_push/push_rpc.js +2 -2
- package/dist/lib/message/version_0.d.ts +13 -13
- package/dist/lib/message/version_0.js +22 -20
- package/dist/lib/message/version_0.js.map +1 -1
- package/dist/lib/store/history_rpc.d.ts +1 -1
- package/dist/lib/store/history_rpc.js +1 -1
- package/dist/lib/store/index.d.ts +1 -1
- package/dist/lib/store/index.js +43 -17
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/stream_manager.d.ts +1 -1
- package/dist/lib/stream_manager.js +8 -5
- package/dist/lib/stream_manager.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.d.ts +2 -2
- package/dist/lib/wait_for_remote_peer.js +13 -11
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/dist/lib/waku.d.ts +4 -3
- package/dist/lib/waku.js +13 -11
- package/dist/lib/waku.js.map +1 -1
- package/package.json +1 -137
- package/src/lib/connection_manager.ts +156 -51
- package/src/lib/filter/index.ts +76 -40
- package/src/lib/keep_alive_manager.ts +53 -20
- package/src/lib/light_push/index.ts +74 -38
- package/src/lib/light_push/push_rpc.ts +2 -2
- package/src/lib/message/version_0.ts +25 -17
- package/src/lib/store/history_rpc.ts +2 -2
- package/src/lib/store/index.ts +60 -23
- package/src/lib/stream_manager.ts +12 -7
- package/src/lib/wait_for_remote_peer.ts +13 -11
- package/src/lib/waku.ts +12 -9
- package/dist/lib/push_or_init_map.d.ts +0 -1
- package/dist/lib/push_or_init_map.js +0 -9
- package/dist/lib/push_or_init_map.js.map +0 -1
- package/src/lib/push_or_init_map.ts +0 -13
package/dist/lib/store/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { sha256 } from "@noble/hashes/sha256";
|
2
2
|
import { proto_store as proto } from "@waku/proto";
|
3
|
-
import { isDefined } from "@waku/utils";
|
3
|
+
import { ensurePubsubTopicIsConfigured, isDefined } from "@waku/utils";
|
4
|
+
import { Logger } from "@waku/utils";
|
4
5
|
import { concat, utf8ToBytes } from "@waku/utils/bytes";
|
5
|
-
import debug from "debug";
|
6
6
|
import all from "it-all";
|
7
7
|
import * as lp from "it-length-prefixed";
|
8
8
|
import { pipe } from "it-pipe";
|
@@ -12,7 +12,7 @@ import { DefaultPubSubTopic } from "../constants.js";
|
|
12
12
|
import { toProtoMessage } from "../to_proto_message.js";
|
13
13
|
import { HistoryRpc, PageDirection } from "./history_rpc.js";
|
14
14
|
var HistoryError = proto.HistoryResponse.HistoryError;
|
15
|
-
const log =
|
15
|
+
const log = new Logger("store");
|
16
16
|
export const StoreCodec = "/vac/waku/store/2.0.0-beta4";
|
17
17
|
export const DefaultPageSize = 10;
|
18
18
|
export { PageDirection };
|
@@ -22,11 +22,11 @@ export { PageDirection };
|
|
22
22
|
* The Waku Store protocol can be used to retrieved historical messages.
|
23
23
|
*/
|
24
24
|
class Store extends BaseProtocol {
|
25
|
-
|
25
|
+
pubsubTopics;
|
26
26
|
NUM_PEERS_PROTOCOL = 1;
|
27
27
|
constructor(libp2p, options) {
|
28
28
|
super(StoreCodec, libp2p.components);
|
29
|
-
this.
|
29
|
+
this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubSubTopic];
|
30
30
|
}
|
31
31
|
/**
|
32
32
|
* Processes messages based on the provided callback and options.
|
@@ -128,14 +128,36 @@ class Store extends BaseProtocol {
|
|
128
128
|
* @throws If not able to reach a Waku Store peer to query,
|
129
129
|
* or if an error is encountered when processing the reply,
|
130
130
|
* or if two decoders with the same content topic are passed.
|
131
|
+
*
|
132
|
+
* This API only supports querying a single pubsub topic at a time.
|
133
|
+
* If multiple decoders are provided, they must all have the same pubsub topic.
|
134
|
+
* @throws If multiple decoders with different pubsub topics are provided.
|
135
|
+
* @throws If no decoders are provided.
|
136
|
+
* @throws If no decoders are found for the provided pubsub topic.
|
131
137
|
*/
|
132
138
|
async *queryGenerator(decoders, options) {
|
133
|
-
|
139
|
+
if (decoders.length === 0) {
|
140
|
+
throw new Error("No decoders provided");
|
141
|
+
}
|
134
142
|
let startTime, endTime;
|
135
143
|
if (options?.timeFilter) {
|
136
144
|
startTime = options.timeFilter.startTime;
|
137
145
|
endTime = options.timeFilter.endTime;
|
138
146
|
}
|
147
|
+
// convert array to set to remove duplicates
|
148
|
+
const uniquePubSubTopicsInQuery = Array.from(new Set(decoders.map((decoder) => decoder.pubsubTopic)));
|
149
|
+
// If multiple pubsub topics are provided, throw an error
|
150
|
+
if (uniquePubSubTopicsInQuery.length > 1) {
|
151
|
+
throw new Error("API does not support querying multiple pubsub topics at once");
|
152
|
+
}
|
153
|
+
// we can be certain that there is only one pubsub topic in the query
|
154
|
+
const pubSubTopicForQuery = uniquePubSubTopicsInQuery[0];
|
155
|
+
ensurePubsubTopicIsConfigured(pubSubTopicForQuery, this.pubsubTopics);
|
156
|
+
// check that the pubsubTopic from the Cursor and Decoder match
|
157
|
+
if (options?.cursor?.pubsubTopic &&
|
158
|
+
options.cursor.pubsubTopic !== pubSubTopicForQuery) {
|
159
|
+
throw new Error(`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubSubTopicForQuery})`);
|
160
|
+
}
|
139
161
|
const decodersAsMap = new Map();
|
140
162
|
decoders.forEach((dec) => {
|
141
163
|
if (decodersAsMap.has(dec.contentTopic)) {
|
@@ -143,13 +165,17 @@ class Store extends BaseProtocol {
|
|
143
165
|
}
|
144
166
|
decodersAsMap.set(dec.contentTopic, dec);
|
145
167
|
});
|
146
|
-
const contentTopics = decoders
|
168
|
+
const contentTopics = decoders
|
169
|
+
.filter((decoder) => decoder.pubsubTopic === pubSubTopicForQuery)
|
170
|
+
.map((dec) => dec.contentTopic);
|
171
|
+
if (contentTopics.length === 0) {
|
172
|
+
throw new Error("No decoders found for topic " + pubSubTopicForQuery);
|
173
|
+
}
|
147
174
|
const queryOpts = Object.assign({
|
148
|
-
|
175
|
+
pubsubTopic: pubSubTopicForQuery,
|
149
176
|
pageDirection: PageDirection.BACKWARD,
|
150
177
|
pageSize: DefaultPageSize
|
151
178
|
}, options, { contentTopics, startTime, endTime });
|
152
|
-
log("Querying history with the following options", options);
|
153
179
|
const peer = (await this.getPeers({
|
154
180
|
numPeers: this.NUM_PEERS_PROTOCOL,
|
155
181
|
maxBootstrapPeers: 1
|
@@ -168,7 +194,7 @@ async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
|
168
194
|
while (true) {
|
169
195
|
queryOpts.cursor = currentCursor;
|
170
196
|
const historyRpcQuery = HistoryRpc.createQuery(queryOpts);
|
171
|
-
log("Querying store peer", `for (${queryOpts.
|
197
|
+
log.info("Querying store peer", `for (${queryOpts.pubsubTopic})`, queryOpts.contentTopics);
|
172
198
|
const stream = await streamFactory();
|
173
199
|
const res = await pipe([historyRpcQuery.encode()], lp.encode, stream, lp.decode, async (source) => await all(source));
|
174
200
|
const bytes = new Uint8ArrayList();
|
@@ -177,7 +203,7 @@ async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
|
177
203
|
});
|
178
204
|
const reply = historyRpcQuery.decode(bytes);
|
179
205
|
if (!reply.response) {
|
180
|
-
log("Stopping pagination due to store `response` field missing");
|
206
|
+
log.warn("Stopping pagination due to store `response` field missing");
|
181
207
|
break;
|
182
208
|
}
|
183
209
|
const response = reply.response;
|
@@ -185,16 +211,16 @@ async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
|
185
211
|
throw "History response contains an Error: " + response.error;
|
186
212
|
}
|
187
213
|
if (!response.messages || !response.messages.length) {
|
188
|
-
log("Stopping pagination due to store `response.messages` field missing or empty");
|
214
|
+
log.warn("Stopping pagination due to store `response.messages` field missing or empty");
|
189
215
|
break;
|
190
216
|
}
|
191
|
-
log(`${response.messages.length} messages retrieved from store`);
|
217
|
+
log.error(`${response.messages.length} messages retrieved from store`);
|
192
218
|
yield response.messages.map((protoMsg) => {
|
193
219
|
const contentTopic = protoMsg.contentTopic;
|
194
220
|
if (typeof contentTopic !== "undefined") {
|
195
221
|
const decoder = decoders.get(contentTopic);
|
196
222
|
if (decoder) {
|
197
|
-
return decoder.fromProtoObj(queryOpts.
|
223
|
+
return decoder.fromProtoObj(queryOpts.pubsubTopic, toProtoMessage(protoMsg));
|
198
224
|
}
|
199
225
|
}
|
200
226
|
return Promise.resolve(undefined);
|
@@ -203,7 +229,7 @@ async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
|
203
229
|
if (typeof nextCursor === "undefined") {
|
204
230
|
// If the server does not return cursor then there is an issue,
|
205
231
|
// Need to abort, or we end up in an infinite loop
|
206
|
-
log("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");
|
232
|
+
log.warn("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");
|
207
233
|
break;
|
208
234
|
}
|
209
235
|
currentCursor = nextCursor;
|
@@ -218,7 +244,7 @@ async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
|
218
244
|
}
|
219
245
|
}
|
220
246
|
}
|
221
|
-
export async function createCursor(message
|
247
|
+
export async function createCursor(message) {
|
222
248
|
if (!message ||
|
223
249
|
!message.timestamp ||
|
224
250
|
!message.payload ||
|
@@ -230,7 +256,7 @@ export async function createCursor(message, pubsubTopic = DefaultPubSubTopic) {
|
|
230
256
|
const messageTime = BigInt(message.timestamp.getTime()) * BigInt(1000000);
|
231
257
|
return {
|
232
258
|
digest,
|
233
|
-
pubsubTopic,
|
259
|
+
pubsubTopic: message.pubsubTopic,
|
234
260
|
senderTime: messageTime,
|
235
261
|
receiverTime: messageTime
|
236
262
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/store/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/store/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAU9C,OAAO,EAAE,WAAW,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,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C,CAAC;KACvD;IAED,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE5D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAEpE,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1E,OAAO;QACL,MAAM;QACN,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,WAAW;QACvB,YAAY,EAAE,WAAW;KAC1B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,OAAuC,EAAE;IAEzC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
@@ -6,7 +6,7 @@ export declare class StreamManager {
|
|
6
6
|
getConnections: Libp2p["getConnections"];
|
7
7
|
addEventListener: Libp2p["addEventListener"];
|
8
8
|
private streamPool;
|
9
|
-
private log;
|
9
|
+
private readonly log;
|
10
10
|
constructor(multicodec: string, getConnections: Libp2p["getConnections"], addEventListener: Libp2p["addEventListener"]);
|
11
11
|
getStream(peer: Peer): Promise<Stream>;
|
12
12
|
private newStream;
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { Logger } from "@waku/utils";
|
1
2
|
import { selectConnection } from "@waku/utils/libp2p";
|
2
|
-
import debug from "debug";
|
3
3
|
export class StreamManager {
|
4
4
|
multicodec;
|
5
5
|
getConnections;
|
@@ -10,7 +10,7 @@ export class StreamManager {
|
|
10
10
|
this.multicodec = multicodec;
|
11
11
|
this.getConnections = getConnections;
|
12
12
|
this.addEventListener = addEventListener;
|
13
|
-
this.log =
|
13
|
+
this.log = new Logger(`stream-manager:${multicodec}`);
|
14
14
|
this.addEventListener("peer:update", this.handlePeerUpdateStreamPool.bind(this));
|
15
15
|
this.getStream = this.getStream.bind(this);
|
16
16
|
this.streamPool = new Map();
|
@@ -25,7 +25,7 @@ export class StreamManager {
|
|
25
25
|
this.streamPool.delete(peerIdStr);
|
26
26
|
this.prepareNewStream(peer);
|
27
27
|
const stream = await streamPromise;
|
28
|
-
if (stream.status === "closed") {
|
28
|
+
if (!stream || stream.status === "closed") {
|
29
29
|
return this.newStream(peer); // fallback by creating a new stream on the spot
|
30
30
|
}
|
31
31
|
return stream;
|
@@ -39,13 +39,16 @@ export class StreamManager {
|
|
39
39
|
return connection.newStream(this.multicodec);
|
40
40
|
}
|
41
41
|
prepareNewStream(peer) {
|
42
|
-
const streamPromise = this.newStream(peer)
|
42
|
+
const streamPromise = this.newStream(peer).catch(() => {
|
43
|
+
// No error thrown as this call is not triggered by the user
|
44
|
+
this.log.error(`Failed to prepare a new stream for ${peer.id.toString()}`);
|
45
|
+
});
|
43
46
|
this.streamPool.set(peer.id.toString(), streamPromise);
|
44
47
|
}
|
45
48
|
handlePeerUpdateStreamPool = (evt) => {
|
46
49
|
const peer = evt.detail.peer;
|
47
50
|
if (peer.protocols.includes(this.multicodec)) {
|
48
|
-
this.log(`Preemptively opening a stream to ${peer.id.toString()}`);
|
51
|
+
this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);
|
49
52
|
this.prepareNewStream(peer);
|
50
53
|
}
|
51
54
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stream_manager.js","sourceRoot":"","sources":["../../src/lib/stream_manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"stream_manager.js","sourceRoot":"","sources":["../../src/lib/stream_manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,OAAO,aAAa;IAKf;IACA;IACA;IAND,UAAU,CAAsC;IACv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AC,EAAE,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC3D;QACD,OAAO,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAEO,gBAAgB,CAAC,IAAU;QACjC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACpD,4DAA4D;YAC5D,IAAI,CAAC,GAAG,CAAC,KAAK,CACZ,sCAAsC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC3D,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,CAAC;IACzD,CAAC;IAEO,0BAA0B,GAAG,CAAC,GAA4B,EAAQ,EAAE;QAC1E,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC7B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YAC5C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oCAAoC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;SAC7B;IACH,CAAC,CAAC;CACH"}
|
@@ -3,8 +3,8 @@ import { Protocols } from "@waku/interfaces";
|
|
3
3
|
/**
|
4
4
|
* Wait for a remote peer to be ready given the passed protocols.
|
5
5
|
* Must be used after attempting to connect to nodes, using
|
6
|
-
* {@link @waku/core
|
7
|
-
* {@link @waku/sdk
|
6
|
+
* {@link @waku/core!WakuNode.dial} or a bootstrap method with
|
7
|
+
* {@link @waku/sdk!createLightNode}.
|
8
8
|
*
|
9
9
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
10
10
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { Protocols } from "@waku/interfaces";
|
2
|
-
import
|
2
|
+
import { Logger } from "@waku/utils";
|
3
3
|
import { pEvent } from "p-event";
|
4
|
-
const log =
|
4
|
+
const log = new Logger("wait-for-remote-peer");
|
5
5
|
/**
|
6
6
|
* Wait for a remote peer to be ready given the passed protocols.
|
7
7
|
* Must be used after attempting to connect to nodes, using
|
8
|
-
* {@link @waku/core
|
9
|
-
* {@link @waku/sdk
|
8
|
+
* {@link @waku/core!WakuNode.dial} or a bootstrap method with
|
9
|
+
* {@link @waku/sdk!createLightNode}.
|
10
10
|
*
|
11
11
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
12
12
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -60,13 +60,12 @@ async function waitForConnectedPeer(protocol) {
|
|
60
60
|
const codec = protocol.multicodec;
|
61
61
|
const peers = await protocol.peers();
|
62
62
|
if (peers.length) {
|
63
|
-
log(`${codec} peer found: `, peers[0].id.toString());
|
63
|
+
log.info(`${codec} peer found: `, peers[0].id.toString());
|
64
64
|
return;
|
65
65
|
}
|
66
66
|
await new Promise((resolve) => {
|
67
67
|
const cb = (evt) => {
|
68
68
|
if (evt.detail?.protocols?.includes(codec)) {
|
69
|
-
log("Resolving for", codec, evt.detail.protocols);
|
70
69
|
protocol.removeLibp2pEventListener("peer:identify", cb);
|
71
70
|
resolve();
|
72
71
|
}
|
@@ -75,14 +74,17 @@ async function waitForConnectedPeer(protocol) {
|
|
75
74
|
});
|
76
75
|
}
|
77
76
|
/**
|
78
|
-
* Wait for
|
79
|
-
* mesh.
|
77
|
+
* Wait for at least one peer with the given protocol to be connected and in the gossipsub
|
78
|
+
* mesh for all pubsubTopics.
|
80
79
|
*/
|
81
80
|
async function waitForGossipSubPeerInMesh(waku) {
|
82
81
|
let peers = waku.getMeshPeers();
|
83
|
-
|
84
|
-
|
85
|
-
peers
|
82
|
+
const pubsubTopics = waku.pubsubTopics;
|
83
|
+
for (const topic of pubsubTopics) {
|
84
|
+
while (peers.length == 0) {
|
85
|
+
await pEvent(waku.gossipSub, "gossipsub:heartbeat");
|
86
|
+
peers = waku.getMeshPeers(topic);
|
87
|
+
}
|
86
88
|
}
|
87
89
|
}
|
88
90
|
const awaitTimeout = (ms, rejectReason) => new Promise((_resolve, reject) => setTimeout(() => reject(rejectReason), ms));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,
|
1
|
+
{"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,SAAuB,EACvB,SAAkB;IAElB,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAEzE,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACvC,IAAI,CAAC,IAAI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B,EACjB,YAAoB;IAEpB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAU;IACrC,MAAM,SAAS,GAAG,EAAE,CAAC;IAErB,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAClC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;KACrC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/lib/waku.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { Stream } from "@libp2p/interface/connection";
|
2
2
|
import { PeerId } from "@libp2p/interface/peer-id";
|
3
3
|
import { MultiaddrInput } from "@multiformats/multiaddr";
|
4
|
-
import type { IFilter, ILightPush, IRelay, IStore, Libp2p, Waku } from "@waku/interfaces";
|
4
|
+
import type { IFilter, ILightPush, IRelay, IStore, Libp2p, PubSubTopic, Waku } from "@waku/interfaces";
|
5
5
|
import { Protocols } from "@waku/interfaces";
|
6
6
|
import { ConnectionManager } from "./connection_manager.js";
|
7
|
-
export declare const DefaultPingKeepAliveValueSecs
|
7
|
+
export declare const DefaultPingKeepAliveValueSecs: number;
|
8
8
|
export declare const DefaultRelayKeepAliveValueSecs: number;
|
9
9
|
export declare const DefaultUserAgent = "js-waku";
|
10
10
|
export interface WakuOptions {
|
@@ -29,13 +29,14 @@ export interface WakuOptions {
|
|
29
29
|
userAgent?: string;
|
30
30
|
}
|
31
31
|
export declare class WakuNode implements Waku {
|
32
|
+
readonly pubsubTopics: PubSubTopic[];
|
32
33
|
libp2p: Libp2p;
|
33
34
|
relay?: IRelay;
|
34
35
|
store?: IStore;
|
35
36
|
filter?: IFilter;
|
36
37
|
lightPush?: ILightPush;
|
37
38
|
connectionManager: ConnectionManager;
|
38
|
-
constructor(options: WakuOptions, libp2p: Libp2p, store?: (libp2p: Libp2p) => IStore, lightPush?: (libp2p: Libp2p) => ILightPush, filter?: (libp2p: Libp2p) => IFilter, relay?: (libp2p: Libp2p) => IRelay);
|
39
|
+
constructor(options: WakuOptions, pubsubTopics: PubSubTopic[], libp2p: Libp2p, store?: (libp2p: Libp2p) => IStore, lightPush?: (libp2p: Libp2p) => ILightPush, filter?: (libp2p: Libp2p) => IFilter, relay?: (libp2p: Libp2p) => IRelay);
|
39
40
|
/**
|
40
41
|
* Dials to the provided peer.
|
41
42
|
*
|
package/dist/lib/waku.js
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
import { isPeerId } from "@libp2p/interface/peer-id";
|
2
2
|
import { multiaddr } from "@multiformats/multiaddr";
|
3
3
|
import { Protocols } from "@waku/interfaces";
|
4
|
-
import
|
4
|
+
import { Logger } from "@waku/utils";
|
5
5
|
import { ConnectionManager } from "./connection_manager.js";
|
6
|
-
export const DefaultPingKeepAliveValueSecs =
|
6
|
+
export const DefaultPingKeepAliveValueSecs = 5 * 60;
|
7
7
|
export const DefaultRelayKeepAliveValueSecs = 5 * 60;
|
8
8
|
export const DefaultUserAgent = "js-waku";
|
9
|
-
const log =
|
9
|
+
const log = new Logger("waku");
|
10
10
|
export class WakuNode {
|
11
|
+
pubsubTopics;
|
11
12
|
libp2p;
|
12
13
|
relay;
|
13
14
|
store;
|
14
15
|
filter;
|
15
16
|
lightPush;
|
16
17
|
connectionManager;
|
17
|
-
constructor(options, libp2p, store, lightPush, filter, relay) {
|
18
|
+
constructor(options, pubsubTopics, libp2p, store, lightPush, filter, relay) {
|
19
|
+
this.pubsubTopics = pubsubTopics;
|
18
20
|
this.libp2p = libp2p;
|
19
21
|
if (store) {
|
20
22
|
this.store = store(libp2p);
|
@@ -33,8 +35,8 @@ export class WakuNode {
|
|
33
35
|
? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs
|
34
36
|
: 0;
|
35
37
|
const peerId = this.libp2p.peerId.toString();
|
36
|
-
this.connectionManager = ConnectionManager.create(peerId, libp2p, { pingKeepAlive, relayKeepAlive }, this.relay);
|
37
|
-
log("Waku node created", peerId, `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this
|
38
|
+
this.connectionManager = ConnectionManager.create(peerId, libp2p, { pingKeepAlive, relayKeepAlive }, pubsubTopics, this.relay);
|
39
|
+
log.info("Waku node created", peerId, `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this
|
38
40
|
.lightPush}, filter: ${!!this.filter}`);
|
39
41
|
}
|
40
42
|
/**
|
@@ -58,7 +60,7 @@ export class WakuNode {
|
|
58
60
|
this.relay.gossipSub.multicodecs.forEach((codec) => codecs.push(codec));
|
59
61
|
}
|
60
62
|
else {
|
61
|
-
log("Relay codec not included in dial codec: protocol not mounted locally");
|
63
|
+
log.error("Relay codec not included in dial codec: protocol not mounted locally");
|
62
64
|
}
|
63
65
|
}
|
64
66
|
if (_protocols.includes(Protocols.Store)) {
|
@@ -66,7 +68,7 @@ export class WakuNode {
|
|
66
68
|
codecs.push(this.store.multicodec);
|
67
69
|
}
|
68
70
|
else {
|
69
|
-
log("Store codec not included in dial codec: protocol not mounted locally");
|
71
|
+
log.error("Store codec not included in dial codec: protocol not mounted locally");
|
70
72
|
}
|
71
73
|
}
|
72
74
|
if (_protocols.includes(Protocols.LightPush)) {
|
@@ -74,7 +76,7 @@ export class WakuNode {
|
|
74
76
|
codecs.push(this.lightPush.multicodec);
|
75
77
|
}
|
76
78
|
else {
|
77
|
-
log("Light Push codec not included in dial codec: protocol not mounted locally");
|
79
|
+
log.error("Light Push codec not included in dial codec: protocol not mounted locally");
|
78
80
|
}
|
79
81
|
}
|
80
82
|
if (_protocols.includes(Protocols.Filter)) {
|
@@ -82,10 +84,10 @@ export class WakuNode {
|
|
82
84
|
codecs.push(this.filter.multicodec);
|
83
85
|
}
|
84
86
|
else {
|
85
|
-
log("Filter codec not included in dial codec: protocol not mounted locally");
|
87
|
+
log.error("Filter codec not included in dial codec: protocol not mounted locally");
|
86
88
|
}
|
87
89
|
}
|
88
|
-
log(`Dialing to ${peerId.toString()} with protocols ${_protocols}`);
|
90
|
+
log.info(`Dialing to ${peerId.toString()} with protocols ${_protocols}`);
|
89
91
|
return this.libp2p.dialProtocol(peerId, codecs);
|
90
92
|
}
|
91
93
|
async start() {
|
package/dist/lib/waku.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waku.js","sourceRoot":"","sources":["../../src/lib/waku.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAU,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAA6B,MAAM,yBAAyB,CAAC;
|
1
|
+
{"version":3,"file":"waku.js","sourceRoot":"","sources":["../../src/lib/waku.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAU,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAA6B,MAAM,yBAAyB,CAAC;AAU/E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,GAAG,EAAE,CAAC;AACpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,GAAG,EAAE,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAE1C,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM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D,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YACvD,MAAM,4BAA4B,CAAC;SACpC;QACD,OAAO,cAAc,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClE,CAAC;CACF;AACD,SAAS,sBAAsB,CAC7B,MAA+B;IAE/B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
@@ -1,137 +1 @@
|
|
1
|
-
{
|
2
|
-
"name": "@waku/core",
|
3
|
-
"version": "0.0.23",
|
4
|
-
"description": "TypeScript implementation of the Waku v2 protocol",
|
5
|
-
"types": "./dist/index.d.ts",
|
6
|
-
"module": "./dist/index.js",
|
7
|
-
"exports": {
|
8
|
-
".": {
|
9
|
-
"types": "./dist/index.d.ts",
|
10
|
-
"import": "./dist/index.js"
|
11
|
-
},
|
12
|
-
"./lib/predefined_bootstrap_nodes": {
|
13
|
-
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
14
|
-
"import": "./dist/lib/predefined_bootstrap_nodes.js"
|
15
|
-
},
|
16
|
-
"./lib/message/version_0": {
|
17
|
-
"types": "./dist/lib/message/version_0.d.ts",
|
18
|
-
"import": "./dist/lib/message/version_0.js"
|
19
|
-
},
|
20
|
-
"./lib/base_protocol": {
|
21
|
-
"types": "./dist/lib/base_protocol.d.ts",
|
22
|
-
"import": "./dist/lib/base_protocol.js"
|
23
|
-
}
|
24
|
-
},
|
25
|
-
"typesVersions": {
|
26
|
-
"*": {
|
27
|
-
"lib/*": [
|
28
|
-
"dist/lib/*"
|
29
|
-
],
|
30
|
-
"constants/*": [
|
31
|
-
"dist/constants/*"
|
32
|
-
]
|
33
|
-
}
|
34
|
-
},
|
35
|
-
"type": "module",
|
36
|
-
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/core#readme",
|
37
|
-
"repository": {
|
38
|
-
"type": "git",
|
39
|
-
"url": "https://github.com/waku-org/js-waku.git"
|
40
|
-
},
|
41
|
-
"bugs": {
|
42
|
-
"url": "https://github.com/waku-org/js-waku/issues"
|
43
|
-
},
|
44
|
-
"license": "MIT OR Apache-2.0",
|
45
|
-
"keywords": [
|
46
|
-
"waku",
|
47
|
-
"decentralised",
|
48
|
-
"communication",
|
49
|
-
"web3",
|
50
|
-
"ethereum",
|
51
|
-
"dapps"
|
52
|
-
],
|
53
|
-
"scripts": {
|
54
|
-
"build": "run-s build:**",
|
55
|
-
"build:esm": "tsc",
|
56
|
-
"build:bundle": "rollup --config rollup.config.js",
|
57
|
-
"fix": "run-s fix:*",
|
58
|
-
"fix:lint": "eslint src *.js --fix",
|
59
|
-
"check": "run-s check:*",
|
60
|
-
"check:tsc": "tsc -p tsconfig.dev.json",
|
61
|
-
"check:lint": "eslint src *.js",
|
62
|
-
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
|
63
|
-
"test": "run-s test:*",
|
64
|
-
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
|
65
|
-
"test:browser": "karma start karma.conf.cjs",
|
66
|
-
"watch:build": "tsc -p tsconfig.json -w",
|
67
|
-
"watch:test": "mocha --watch",
|
68
|
-
"prepublish": "npm run build",
|
69
|
-
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
70
|
-
},
|
71
|
-
"engines": {
|
72
|
-
"node": ">=16"
|
73
|
-
},
|
74
|
-
"dependencies": {
|
75
|
-
"@noble/hashes": "^1.3.2",
|
76
|
-
"@waku/interfaces": "0.0.18",
|
77
|
-
"@waku/proto": "0.0.5",
|
78
|
-
"@waku/utils": "0.0.11",
|
79
|
-
"debug": "^4.3.4",
|
80
|
-
"it-all": "^3.0.3",
|
81
|
-
"it-length-prefixed": "^9.0.1",
|
82
|
-
"it-pipe": "^3.0.1",
|
83
|
-
"p-event": "^5.0.1",
|
84
|
-
"uint8arraylist": "^2.4.3",
|
85
|
-
"uuid": "^9.0.0"
|
86
|
-
},
|
87
|
-
"devDependencies": {
|
88
|
-
"@multiformats/multiaddr": "^12.0.0",
|
89
|
-
"@rollup/plugin-commonjs": "^25.0.4",
|
90
|
-
"@rollup/plugin-json": "^6.0.0",
|
91
|
-
"@rollup/plugin-node-resolve": "^15.1.0",
|
92
|
-
"@types/chai": "^4.3.5",
|
93
|
-
"@types/debug": "^4.1.8",
|
94
|
-
"@types/mocha": "^10.0.1",
|
95
|
-
"@types/uuid": "^9.0.3",
|
96
|
-
"@waku/build-utils": "*",
|
97
|
-
"chai": "^4.3.7",
|
98
|
-
"cspell": "^7.3.2",
|
99
|
-
"fast-check": "^3.12.0",
|
100
|
-
"ignore-loader": "^0.1.2",
|
101
|
-
"isomorphic-fetch": "^3.0.0",
|
102
|
-
"karma": "^6.4.1",
|
103
|
-
"karma-chrome-launcher": "^3.2.0",
|
104
|
-
"karma-mocha": "^2.0.1",
|
105
|
-
"karma-webpack": "^5.0.0",
|
106
|
-
"mocha": "^10.2.0",
|
107
|
-
"npm-run-all": "^4.1.5",
|
108
|
-
"process": "^0.11.10",
|
109
|
-
"puppeteer": "^21.1.1",
|
110
|
-
"rollup": "^3.29.0",
|
111
|
-
"ts-loader": "^9.4.2",
|
112
|
-
"ts-node": "^10.9.1",
|
113
|
-
"typescript": "^5.0.4"
|
114
|
-
},
|
115
|
-
"peerDependencies": {
|
116
|
-
"@multiformats/multiaddr": "^12.0.0",
|
117
|
-
"libp2p": "^0.46.3"
|
118
|
-
},
|
119
|
-
"peerDependenciesMeta": {
|
120
|
-
"@multiformats/multiaddr": {
|
121
|
-
"optional": true
|
122
|
-
}
|
123
|
-
},
|
124
|
-
"typedoc": {
|
125
|
-
"entryPoint": "./src/index.ts"
|
126
|
-
},
|
127
|
-
"files": [
|
128
|
-
"dist",
|
129
|
-
"bundle",
|
130
|
-
"src/**/*.ts",
|
131
|
-
"!**/*.spec.*",
|
132
|
-
"!**/*.json",
|
133
|
-
"CHANGELOG.md",
|
134
|
-
"LICENSE",
|
135
|
-
"README.md"
|
136
|
-
]
|
137
|
-
}
|
1
|
+
{"name":"@waku/core","version":"0.0.25-a42b7be.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/predefined_bootstrap_nodes":{"types":"./dist/lib/predefined_bootstrap_nodes.d.ts","import":"./dist/lib/predefined_bootstrap_nodes.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"run-s test:*","test:node":"TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=18"},"dependencies":{"@noble/hashes":"^1.3.2","@waku/enr":"0.0.19-a42b7be.0","@waku/interfaces":"0.0.20-a42b7be.0","@waku/proto":"0.0.6-a42b7be.0","@waku/utils":"0.0.13-a42b7be.0","debug":"^4.3.4","it-all":"^3.0.3","it-length-prefixed":"^9.0.1","it-pipe":"^3.0.1","p-event":"^6.0.0","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.4","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.5","@types/debug":"^4.1.10","@types/mocha":"^10.0.1","@types/uuid":"^9.0.3","@waku/build-utils":"*","chai":"^4.3.7","cspell":"^7.3.2","fast-check":"^3.13.1","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.2.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^3.29.2"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"^0.46.3"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
|