@waku/core 0.0.28-b5e8b17.0 → 0.0.28
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 +30 -0
- package/bundle/{base_protocol-BCwLeb-A.js → base_protocol-D0Zdzb-v.js} +1 -1
- package/bundle/{index-vlQahmUj.js → index-BJwgMx4y.js} +32 -61
- package/bundle/index.js +111 -250
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/lib/predefined_bootstrap_nodes.js +16 -16
- package/bundle/{version_0-DiakMc1A.js → version_0-C6o0DvNW.js} +566 -321
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/message/version_0.js +1 -1
- package/dist/lib/message/version_0.js.map +1 -1
- package/dist/lib/predefined_bootstrap_nodes.d.ts +11 -11
- package/dist/lib/predefined_bootstrap_nodes.js +16 -16
- package/dist/lib/predefined_bootstrap_nodes.js.map +1 -1
- package/dist/lib/store/history_rpc.js +1 -1
- package/dist/lib/store/history_rpc.js.map +1 -1
- package/dist/lib/store/index.d.ts +14 -6
- package/dist/lib/store/index.js +50 -232
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.js +1 -1
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/package.json +136 -1
- package/src/index.ts +2 -1
- package/src/lib/predefined_bootstrap_nodes.ts +22 -22
- package/src/lib/store/index.ts +77 -339
- package/src/lib/wait_for_remote_peer.ts +1 -1
package/bundle/index.js
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, H as HistoryRpc$1, f as PagingInfo, g as HistoryResponse, h as createEncoder, W as WakuMetadataResponse, i as WakuMetadataRequest } from './version_0-
|
2
|
-
export { j as createDecoder } from './version_0-
|
1
|
+
import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, H as HistoryRpc$1, f as PagingInfo, g as HistoryResponse, h as createEncoder, W as WakuMetadataResponse, i as WakuMetadataRequest } from './version_0-C6o0DvNW.js';
|
2
|
+
export { j as createDecoder } from './version_0-C6o0DvNW.js';
|
3
3
|
import { g as getDefaultExportFromCjs, P as ProtocolError, a as Protocols, E as EConnectionStateEvents, T as Tags, b as EPeersByDiscoveryEvents } from './browser-DoQRY-an.js';
|
4
|
-
import { b as bytesToUtf8, u as utf8ToBytes, c as concat$1, s as sha256, a as
|
5
|
-
import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-
|
6
|
-
export { S as StreamManager } from './base_protocol-
|
7
|
-
|
8
|
-
function isDefined(value) {
|
9
|
-
return Boolean(value);
|
10
|
-
}
|
4
|
+
import { b as bytesToUtf8, u as utf8ToBytes, c as concat$1, s as sha256, a as allocUnsafe, d as alloc, L as Logger, e as singleShardInfoToPubsubTopic, f as ensurePubsubTopicIsConfigured, D as DefaultPubsubTopic, p as pubsubTopicToSingleShardInfo, g as shardInfoToPubsubTopics } from './index-BJwgMx4y.js';
|
5
|
+
import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-D0Zdzb-v.js';
|
6
|
+
export { S as StreamManager } from './base_protocol-D0Zdzb-v.js';
|
11
7
|
|
12
8
|
function groupByContentTopic(values) {
|
13
9
|
const groupedDecoders = new Map();
|
@@ -174,13 +170,18 @@ function all(source) {
|
|
174
170
|
return arr;
|
175
171
|
}
|
176
172
|
|
173
|
+
/**
|
174
|
+
* To guarantee Uint8Array semantics, convert nodejs Buffers
|
175
|
+
* into vanilla Uint8Arrays
|
176
|
+
*/
|
177
|
+
function asUint8Array(buf) {
|
178
|
+
return buf;
|
179
|
+
}
|
180
|
+
|
177
181
|
/**
|
178
182
|
* Returns a new Uint8Array created by concatenating the passed Uint8Arrays
|
179
183
|
*/
|
180
184
|
function concat(arrays, length) {
|
181
|
-
if (globalThis.Buffer != null) {
|
182
|
-
return asUint8Array(globalThis.Buffer.concat(arrays, length));
|
183
|
-
}
|
184
185
|
if (length == null) {
|
185
186
|
length = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
186
187
|
}
|
@@ -1358,6 +1359,47 @@ function _pushable(getNext, options) {
|
|
1358
1359
|
return pushable;
|
1359
1360
|
}
|
1360
1361
|
|
1362
|
+
/**
|
1363
|
+
* @packageDocumentation
|
1364
|
+
*
|
1365
|
+
* Merge several (async)iterables into one, yield values as they arrive.
|
1366
|
+
*
|
1367
|
+
* Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.
|
1368
|
+
*
|
1369
|
+
* @example
|
1370
|
+
*
|
1371
|
+
* ```javascript
|
1372
|
+
* import merge from 'it-merge'
|
1373
|
+
* import all from 'it-all'
|
1374
|
+
*
|
1375
|
+
* // This can also be an iterator, generator, etc
|
1376
|
+
* const values1 = [0, 1, 2, 3, 4]
|
1377
|
+
* const values2 = [5, 6, 7, 8, 9]
|
1378
|
+
*
|
1379
|
+
* const arr = all(merge(values1, values2))
|
1380
|
+
*
|
1381
|
+
* console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
1382
|
+
* ```
|
1383
|
+
*
|
1384
|
+
* Async sources must be awaited:
|
1385
|
+
*
|
1386
|
+
* ```javascript
|
1387
|
+
* import merge from 'it-merge'
|
1388
|
+
* import all from 'it-all'
|
1389
|
+
*
|
1390
|
+
* // This can also be an iterator, async iterator, generator, etc
|
1391
|
+
* const values1 = async function * () {
|
1392
|
+
* yield * [0, 1, 2, 3, 4]
|
1393
|
+
* }
|
1394
|
+
* const values2 = async function * () {
|
1395
|
+
* yield * [5, 6, 7, 8, 9]
|
1396
|
+
* }
|
1397
|
+
*
|
1398
|
+
* const arr = await all(merge(values1(), values2()))
|
1399
|
+
*
|
1400
|
+
* console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed
|
1401
|
+
* ```
|
1402
|
+
*/
|
1361
1403
|
function isAsyncIterable$1(thing) {
|
1362
1404
|
return thing[Symbol.asyncIterator] != null;
|
1363
1405
|
}
|
@@ -2128,7 +2170,7 @@ function toProtoMessage(wire) {
|
|
2128
2170
|
return { ...EmptyMessage, ...wire };
|
2129
2171
|
}
|
2130
2172
|
|
2131
|
-
const OneMillion = BigInt(
|
2173
|
+
const OneMillion = BigInt(1_000_000);
|
2132
2174
|
var PageDirection;
|
2133
2175
|
(function (PageDirection) {
|
2134
2176
|
PageDirection["BACKWARD"] = "backward";
|
@@ -2201,261 +2243,80 @@ function directionToProto(pageDirection) {
|
|
2201
2243
|
var HistoryError = HistoryResponse.HistoryError;
|
2202
2244
|
const log$4 = new Logger("store");
|
2203
2245
|
const StoreCodec = "/vac/waku/store/2.0.0-beta4";
|
2204
|
-
const DefaultPageSize = 10;
|
2205
2246
|
/**
|
2206
2247
|
* Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).
|
2207
2248
|
*
|
2208
2249
|
* The Waku Store protocol can be used to retrieved historical messages.
|
2209
2250
|
*/
|
2210
|
-
class
|
2211
|
-
NUM_PEERS_PROTOCOL = 1;
|
2251
|
+
class StoreCore extends BaseProtocol {
|
2212
2252
|
constructor(libp2p, options) {
|
2213
2253
|
super(StoreCodec, libp2p.components, log$4, options.pubsubTopics, options);
|
2214
2254
|
}
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
async processMessages(messages, callback, options) {
|
2220
|
-
let abort = false;
|
2221
|
-
const messagesOrUndef = await Promise.all(messages);
|
2222
|
-
let processedMessages = messagesOrUndef.filter(isDefined);
|
2223
|
-
if (this.shouldReverseOrder(options)) {
|
2224
|
-
processedMessages = processedMessages.reverse();
|
2255
|
+
async *queryPerPage(queryOpts, decoders, peer) {
|
2256
|
+
if (queryOpts.contentTopics.toString() !==
|
2257
|
+
Array.from(decoders.keys()).toString()) {
|
2258
|
+
throw new Error("Internal error, the decoders should match the query's content topics");
|
2225
2259
|
}
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2260
|
+
let currentCursor = queryOpts.cursor;
|
2261
|
+
while (true) {
|
2262
|
+
queryOpts.cursor = currentCursor;
|
2263
|
+
const historyRpcQuery = HistoryRpc.createQuery(queryOpts);
|
2264
|
+
const stream = await this.getStream(peer);
|
2265
|
+
const res = await pipe([historyRpcQuery.encode()], encode, stream, decode, async (source) => await all(source));
|
2266
|
+
const bytes = new Uint8ArrayList();
|
2267
|
+
res.forEach((chunk) => {
|
2268
|
+
bytes.append(chunk);
|
2269
|
+
});
|
2270
|
+
const reply = historyRpcQuery.decode(bytes);
|
2271
|
+
if (!reply.response) {
|
2272
|
+
log$4.warn("Stopping pagination due to store `response` field missing");
|
2273
|
+
break;
|
2229
2274
|
}
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
* Messages in pages are ordered from oldest (first) to most recent (last).
|
2237
|
-
* https://github.com/vacp2p/rfc/issues/533
|
2238
|
-
*
|
2239
|
-
* @private
|
2240
|
-
*/
|
2241
|
-
shouldReverseOrder(options) {
|
2242
|
-
return (typeof options?.pageDirection === "undefined" ||
|
2243
|
-
options?.pageDirection === PageDirection.BACKWARD);
|
2244
|
-
}
|
2245
|
-
/**
|
2246
|
-
* @deprecated Use `queryWithOrderedCallback` instead
|
2247
|
-
**/
|
2248
|
-
queryOrderedCallback = this.queryWithOrderedCallback;
|
2249
|
-
/**
|
2250
|
-
* Do a query to a Waku Store to retrieve historical/missed messages.
|
2251
|
-
*
|
2252
|
-
* The callback function takes a `WakuMessage` in input,
|
2253
|
-
* messages are processed in order:
|
2254
|
-
* - oldest to latest if `options.pageDirection` == { @link PageDirection.FORWARD }
|
2255
|
-
* - latest to oldest if `options.pageDirection` == { @link PageDirection.BACKWARD }
|
2256
|
-
*
|
2257
|
-
* The ordering may affect performance.
|
2258
|
-
* The ordering depends on the behavior of the remote store node.
|
2259
|
-
* If strong ordering is needed, you may need to handle this at application level
|
2260
|
-
* and set your own timestamps too (the WakuMessage timestamps are not certified).
|
2261
|
-
*
|
2262
|
-
* @throws If not able to reach a Waku Store peer to query,
|
2263
|
-
* or if an error is encountered when processing the reply,
|
2264
|
-
* or if two decoders with the same content topic are passed.
|
2265
|
-
*/
|
2266
|
-
async queryWithOrderedCallback(decoders, callback, options) {
|
2267
|
-
for await (const promises of this.queryGenerator(decoders, options)) {
|
2268
|
-
if (await this.processMessages(promises, callback, options))
|
2275
|
+
const response = reply.response;
|
2276
|
+
if (response.error && response.error !== HistoryError.NONE) {
|
2277
|
+
throw "History response contains an Error: " + response.error;
|
2278
|
+
}
|
2279
|
+
if (!response.messages || !response.messages.length) {
|
2280
|
+
log$4.warn("Stopping pagination due to store `response.messages` field missing or empty");
|
2269
2281
|
break;
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
* Do note that the resolution of the `Promise<WakuMessage | undefined` may
|
2282
|
-
* break the order as it may rely on the browser decryption API, which in turn,
|
2283
|
-
* may have a different speed depending on the type of decryption.
|
2284
|
-
*
|
2285
|
-
* @throws If not able to reach a Waku Store peer to query,
|
2286
|
-
* or if an error is encountered when processing the reply,
|
2287
|
-
* or if two decoders with the same content topic are passed.
|
2288
|
-
*/
|
2289
|
-
async queryWithPromiseCallback(decoders, callback, options) {
|
2290
|
-
let abort = false;
|
2291
|
-
for await (const page of this.queryGenerator(decoders, options)) {
|
2292
|
-
const _promises = page.map(async (msgPromise) => {
|
2293
|
-
if (abort)
|
2294
|
-
return;
|
2295
|
-
abort = Boolean(await callback(msgPromise));
|
2282
|
+
}
|
2283
|
+
log$4.error(`${response.messages.length} messages retrieved from store`);
|
2284
|
+
yield response.messages.map((protoMsg) => {
|
2285
|
+
const contentTopic = protoMsg.contentTopic;
|
2286
|
+
if (typeof contentTopic !== "undefined") {
|
2287
|
+
const decoder = decoders.get(contentTopic);
|
2288
|
+
if (decoder) {
|
2289
|
+
return decoder.fromProtoObj(queryOpts.pubsubTopic, toProtoMessage(protoMsg));
|
2290
|
+
}
|
2291
|
+
}
|
2292
|
+
return Promise.resolve(undefined);
|
2296
2293
|
});
|
2297
|
-
|
2298
|
-
if (
|
2294
|
+
const nextCursor = response.pagingInfo?.cursor;
|
2295
|
+
if (typeof nextCursor === "undefined") {
|
2296
|
+
// If the server does not return cursor then there is an issue,
|
2297
|
+
// Need to abort, or we end up in an infinite loop
|
2298
|
+
log$4.warn("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");
|
2299
|
+
break;
|
2300
|
+
}
|
2301
|
+
currentCursor = nextCursor;
|
2302
|
+
const responsePageSize = response.pagingInfo?.pageSize;
|
2303
|
+
const queryPageSize = historyRpcQuery.query?.pagingInfo?.pageSize;
|
2304
|
+
if (
|
2305
|
+
// Response page size smaller than query, meaning this is the last page
|
2306
|
+
responsePageSize &&
|
2307
|
+
queryPageSize &&
|
2308
|
+
responsePageSize < queryPageSize) {
|
2299
2309
|
break;
|
2300
|
-
}
|
2301
|
-
}
|
2302
|
-
/**
|
2303
|
-
* Do a query to a Waku Store to retrieve historical/missed messages.
|
2304
|
-
*
|
2305
|
-
* This is a generator, useful if you want most control on how messages
|
2306
|
-
* are processed.
|
2307
|
-
*
|
2308
|
-
* The order of the messages returned by the remote Waku node SHOULD BE
|
2309
|
-
* as follows:
|
2310
|
-
* - within a page, messages SHOULD be ordered from oldest to most recent
|
2311
|
-
* - pages direction depends on { @link QueryOptions.pageDirection }
|
2312
|
-
* @throws If not able to reach a Waku Store peer to query,
|
2313
|
-
* or if an error is encountered when processing the reply,
|
2314
|
-
* or if two decoders with the same content topic are passed.
|
2315
|
-
*
|
2316
|
-
* This API only supports querying a single pubsub topic at a time.
|
2317
|
-
* If multiple decoders are provided, they must all have the same pubsub topic.
|
2318
|
-
* @throws If multiple decoders with different pubsub topics are provided.
|
2319
|
-
* @throws If no decoders are provided.
|
2320
|
-
* @throws If no decoders are found for the provided pubsub topic.
|
2321
|
-
*/
|
2322
|
-
async *queryGenerator(decoders, options) {
|
2323
|
-
if (decoders.length === 0) {
|
2324
|
-
throw new Error("No decoders provided");
|
2325
|
-
}
|
2326
|
-
let startTime, endTime;
|
2327
|
-
if (options?.timeFilter) {
|
2328
|
-
startTime = options.timeFilter.startTime;
|
2329
|
-
endTime = options.timeFilter.endTime;
|
2330
|
-
}
|
2331
|
-
// convert array to set to remove duplicates
|
2332
|
-
const uniquePubsubTopicsInQuery = Array.from(new Set(decoders.map((decoder) => decoder.pubsubTopic)));
|
2333
|
-
// If multiple pubsub topics are provided, throw an error
|
2334
|
-
if (uniquePubsubTopicsInQuery.length > 1) {
|
2335
|
-
throw new Error("API does not support querying multiple pubsub topics at once");
|
2336
|
-
}
|
2337
|
-
// we can be certain that there is only one pubsub topic in the query
|
2338
|
-
const pubsubTopicForQuery = uniquePubsubTopicsInQuery[0];
|
2339
|
-
ensurePubsubTopicIsConfigured(pubsubTopicForQuery, this.pubsubTopics);
|
2340
|
-
// check that the pubsubTopic from the Cursor and Decoder match
|
2341
|
-
if (options?.cursor?.pubsubTopic &&
|
2342
|
-
options.cursor.pubsubTopic !== pubsubTopicForQuery) {
|
2343
|
-
throw new Error(`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubsubTopicForQuery})`);
|
2344
|
-
}
|
2345
|
-
const decodersAsMap = new Map();
|
2346
|
-
decoders.forEach((dec) => {
|
2347
|
-
if (decodersAsMap.has(dec.contentTopic)) {
|
2348
|
-
throw new Error("API does not support different decoder per content topic");
|
2349
|
-
}
|
2350
|
-
decodersAsMap.set(dec.contentTopic, dec);
|
2351
|
-
});
|
2352
|
-
const contentTopics = decoders
|
2353
|
-
.filter((decoder) => decoder.pubsubTopic === pubsubTopicForQuery)
|
2354
|
-
.map((dec) => dec.contentTopic);
|
2355
|
-
if (contentTopics.length === 0) {
|
2356
|
-
throw new Error("No decoders found for topic " + pubsubTopicForQuery);
|
2357
|
-
}
|
2358
|
-
const queryOpts = Object.assign({
|
2359
|
-
pubsubTopic: pubsubTopicForQuery,
|
2360
|
-
pageDirection: PageDirection.BACKWARD,
|
2361
|
-
pageSize: DefaultPageSize
|
2362
|
-
}, options, { contentTopics, startTime, endTime });
|
2363
|
-
const peer = (await this.getPeers({
|
2364
|
-
numPeers: this.NUM_PEERS_PROTOCOL,
|
2365
|
-
maxBootstrapPeers: 1
|
2366
|
-
}))[0];
|
2367
|
-
for await (const messages of paginate(this.getStream.bind(this, peer), queryOpts, decodersAsMap, options?.cursor)) {
|
2368
|
-
yield messages;
|
2369
|
-
}
|
2370
|
-
}
|
2371
|
-
}
|
2372
|
-
async function* paginate(streamFactory, queryOpts, decoders, cursor) {
|
2373
|
-
if (queryOpts.contentTopics.toString() !==
|
2374
|
-
Array.from(decoders.keys()).toString()) {
|
2375
|
-
throw new Error("Internal error, the decoders should match the query's content topics");
|
2376
|
-
}
|
2377
|
-
let currentCursor = cursor;
|
2378
|
-
while (true) {
|
2379
|
-
queryOpts.cursor = currentCursor;
|
2380
|
-
const historyRpcQuery = HistoryRpc.createQuery(queryOpts);
|
2381
|
-
log$4.info("Querying store peer", `for (${queryOpts.pubsubTopic})`, queryOpts.contentTopics);
|
2382
|
-
const stream = await streamFactory();
|
2383
|
-
const res = await pipe([historyRpcQuery.encode()], encode, stream, decode, async (source) => await all(source));
|
2384
|
-
const bytes = new Uint8ArrayList();
|
2385
|
-
res.forEach((chunk) => {
|
2386
|
-
bytes.append(chunk);
|
2387
|
-
});
|
2388
|
-
const reply = historyRpcQuery.decode(bytes);
|
2389
|
-
if (!reply.response) {
|
2390
|
-
log$4.warn("Stopping pagination due to store `response` field missing");
|
2391
|
-
break;
|
2392
|
-
}
|
2393
|
-
const response = reply.response;
|
2394
|
-
if (response.error && response.error !== HistoryError.NONE) {
|
2395
|
-
throw "History response contains an Error: " + response.error;
|
2396
|
-
}
|
2397
|
-
if (!response.messages || !response.messages.length) {
|
2398
|
-
log$4.warn("Stopping pagination due to store `response.messages` field missing or empty");
|
2399
|
-
break;
|
2400
|
-
}
|
2401
|
-
log$4.error(`${response.messages.length} messages retrieved from store`);
|
2402
|
-
yield response.messages.map((protoMsg) => {
|
2403
|
-
const contentTopic = protoMsg.contentTopic;
|
2404
|
-
if (typeof contentTopic !== "undefined") {
|
2405
|
-
const decoder = decoders.get(contentTopic);
|
2406
|
-
if (decoder) {
|
2407
|
-
return decoder.fromProtoObj(queryOpts.pubsubTopic, toProtoMessage(protoMsg));
|
2408
|
-
}
|
2409
2310
|
}
|
2410
|
-
return Promise.resolve(undefined);
|
2411
|
-
});
|
2412
|
-
const nextCursor = response.pagingInfo?.cursor;
|
2413
|
-
if (typeof nextCursor === "undefined") {
|
2414
|
-
// If the server does not return cursor then there is an issue,
|
2415
|
-
// Need to abort, or we end up in an infinite loop
|
2416
|
-
log$4.warn("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");
|
2417
|
-
break;
|
2418
|
-
}
|
2419
|
-
currentCursor = nextCursor;
|
2420
|
-
const responsePageSize = response.pagingInfo?.pageSize;
|
2421
|
-
const queryPageSize = historyRpcQuery.query?.pagingInfo?.pageSize;
|
2422
|
-
if (
|
2423
|
-
// Response page size smaller than query, meaning this is the last page
|
2424
|
-
responsePageSize &&
|
2425
|
-
queryPageSize &&
|
2426
|
-
responsePageSize < queryPageSize) {
|
2427
|
-
break;
|
2428
2311
|
}
|
2429
2312
|
}
|
2430
2313
|
}
|
2431
|
-
async function createCursor(message) {
|
2432
|
-
if (!message ||
|
2433
|
-
!message.timestamp ||
|
2434
|
-
!message.payload ||
|
2435
|
-
!message.contentTopic) {
|
2436
|
-
throw new Error("Message is missing required fields");
|
2437
|
-
}
|
2438
|
-
const contentTopicBytes = utf8ToBytes(message.contentTopic);
|
2439
|
-
const digest = sha256(concat$1([contentTopicBytes, message.payload]));
|
2440
|
-
const messageTime = BigInt(message.timestamp.getTime()) * BigInt(1000000);
|
2441
|
-
return {
|
2442
|
-
digest,
|
2443
|
-
pubsubTopic: message.pubsubTopic,
|
2444
|
-
senderTime: messageTime,
|
2445
|
-
receiverTime: messageTime
|
2446
|
-
};
|
2447
|
-
}
|
2448
|
-
function wakuStore(init = {}) {
|
2449
|
-
return (libp2p) => new Store(libp2p, init);
|
2450
|
-
}
|
2451
2314
|
|
2452
2315
|
var index = /*#__PURE__*/Object.freeze({
|
2453
2316
|
__proto__: null,
|
2454
|
-
DefaultPageSize: DefaultPageSize,
|
2455
2317
|
get PageDirection () { return PageDirection; },
|
2456
2318
|
StoreCodec: StoreCodec,
|
2457
|
-
|
2458
|
-
wakuStore: wakuStore
|
2319
|
+
StoreCore: StoreCore
|
2459
2320
|
});
|
2460
2321
|
|
2461
2322
|
class TimeoutError extends Error {
|
@@ -2576,8 +2437,8 @@ function pTimeout(promise, options) {
|
|
2576
2437
|
}
|
2577
2438
|
|
2578
2439
|
const normalizeEmitter = emitter => {
|
2579
|
-
const addListener = emitter.
|
2580
|
-
const removeListener = emitter.
|
2440
|
+
const addListener = emitter.addEventListener || emitter.on || emitter.addListener;
|
2441
|
+
const removeListener = emitter.removeEventListener || emitter.off || emitter.removeListener;
|
2581
2442
|
|
2582
2443
|
if (!addListener || !removeListener) {
|
2583
2444
|
throw new TypeError('Emitter is not compatible');
|
@@ -2724,7 +2585,7 @@ async function waitForRemotePeer(waku, protocols, timeoutMs) {
|
|
2724
2585
|
if (protocols.includes(Protocols.Store)) {
|
2725
2586
|
if (!waku.store)
|
2726
2587
|
throw new Error("Cannot wait for Store peer: protocol not mounted");
|
2727
|
-
promises.push(waitForConnectedPeer(waku.store, waku.libp2p.services.metadata));
|
2588
|
+
promises.push(waitForConnectedPeer(waku.store.protocol, waku.libp2p.services.metadata));
|
2728
2589
|
}
|
2729
2590
|
if (protocols.includes(Protocols.LightPush)) {
|
2730
2591
|
if (!waku.lightPush)
|
@@ -3524,4 +3385,4 @@ function wakuMetadata(shardInfo) {
|
|
3524
3385
|
return (components) => new Metadata(shardInfo, components);
|
3525
3386
|
}
|
3526
3387
|
|
3527
|
-
export { ConnectionManager, FilterCodecs, KeepAliveManager, LightPushCodec, LightPushCore, MetadataCodec, PageDirection,
|
3388
|
+
export { ConnectionManager, FilterCodecs, KeepAliveManager, LightPushCodec, LightPushCore, MetadataCodec, PageDirection, StoreCore, createEncoder, index$3 as message, waitForRemotePeer, wakuFilter, wakuMetadata, index$2 as waku_filter, index$1 as waku_light_push, index as waku_store };
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import '../index-
|
1
|
+
import '../index-BJwgMx4y.js';
|
2
2
|
import '../browser-DoQRY-an.js';
|
3
|
-
export { B as BaseProtocol } from '../base_protocol-
|
3
|
+
export { B as BaseProtocol } from '../base_protocol-D0Zdzb-v.js';
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { D as DecodedMessage, k as Decoder, E as Encoder, V as Version, j as createDecoder, h as createEncoder, m as proto } from '../../version_0-
|
2
|
-
import '../../index-
|
1
|
+
export { D as DecodedMessage, k as Decoder, E as Encoder, V as Version, j as createDecoder, h as createEncoder, m as proto } from '../../version_0-C6o0DvNW.js';
|
2
|
+
import '../../index-BJwgMx4y.js';
|
3
3
|
import '../../browser-DoQRY-an.js';
|
@@ -28,51 +28,51 @@ function shuffle(arr) {
|
|
28
28
|
const DefaultWantedNumber = 1;
|
29
29
|
var Fleet;
|
30
30
|
(function (Fleet) {
|
31
|
-
Fleet["
|
31
|
+
Fleet["Sandbox"] = "sandbox";
|
32
32
|
Fleet["Test"] = "test";
|
33
33
|
})(Fleet || (Fleet = {}));
|
34
34
|
/**
|
35
35
|
* Return list of pre-defined (hardcoded) bootstrap nodes.
|
36
36
|
*
|
37
|
-
* Default behavior is to return nodes of the nwaku Status
|
37
|
+
* Default behavior is to return nodes of the nwaku Status Sandbox fleet.
|
38
38
|
*
|
39
|
-
* @param fleet The fleet to be returned. Defaults to
|
39
|
+
* @param fleet The fleet to be returned. Defaults to sandbox fleet.
|
40
40
|
* @param wantedNumber The number of connections desired. Defaults to {@link DefaultWantedNumber}.
|
41
41
|
*
|
42
42
|
* @returns An array of multiaddresses.
|
43
43
|
*/
|
44
|
-
function getPredefinedBootstrapNodes(fleet = Fleet.
|
44
|
+
function getPredefinedBootstrapNodes(fleet = Fleet.Sandbox, wantedNumber = DefaultWantedNumber) {
|
45
45
|
if (wantedNumber <= 0) {
|
46
46
|
return [];
|
47
47
|
}
|
48
48
|
let nodes;
|
49
49
|
switch (fleet) {
|
50
|
-
case Fleet.
|
51
|
-
nodes = fleets.fleets["
|
50
|
+
case Fleet.Sandbox:
|
51
|
+
nodes = fleets.fleets["waku.sandbox"]["waku-websocket"];
|
52
52
|
break;
|
53
53
|
case Fleet.Test:
|
54
|
-
nodes = fleets.fleets["
|
54
|
+
nodes = fleets.fleets["waku.test"]["waku-websocket"];
|
55
55
|
break;
|
56
56
|
default:
|
57
|
-
nodes = fleets.fleets["
|
57
|
+
nodes = fleets.fleets["waku.sandbox"]["waku-websocket"];
|
58
58
|
}
|
59
59
|
nodes = Object.values(nodes);
|
60
60
|
return getPseudoRandomSubset(nodes, wantedNumber);
|
61
61
|
}
|
62
62
|
const fleets = {
|
63
63
|
fleets: {
|
64
|
-
"
|
64
|
+
"waku.sandbox": {
|
65
65
|
"waku-websocket": {
|
66
|
-
"node-01.ac-cn-hongkong-c.
|
67
|
-
"node-01.do-ams3.
|
68
|
-
"node-01.gc-us-central1-a.
|
66
|
+
"node-01.ac-cn-hongkong-c.waku.sandbox": "/dns4/node-01.ac-cn-hongkong-c.waku.sandbox.status.im/tcp/8000/wss/p2p/16Uiu2HAmSJvSJphxRdbnigUV5bjRRZFBhTtWFTSyiKaQByCjwmpV",
|
67
|
+
"node-01.do-ams3.waku.sandbox": "/dns4/node-01.do-ams3.waku.sandbox.status.im/tcp/8000/wss/p2p/16Uiu2HAmQSMNExfUYUqfuXWkD5DaNZnMYnigRxFKbk3tcEFQeQeE",
|
68
|
+
"node-01.gc-us-central1-a.waku.sandbox": "/dns4/node-01.gc-us-central1-a.waku.sandbox.status.im/tcp/8000/wss/p2p/16Uiu2HAm6fyqE1jB5MonzvoMdU8v76bWV8ZeNpncDamY1MQXfjdB"
|
69
69
|
}
|
70
70
|
},
|
71
|
-
"
|
71
|
+
"waku.test": {
|
72
72
|
"waku-websocket": {
|
73
|
-
"node-01.ac-cn-hongkong-c.
|
74
|
-
"node-01.do-ams3.
|
75
|
-
"node-01.gc-us-central1-a.
|
73
|
+
"node-01.ac-cn-hongkong-c.waku.test": "/dns4/node-01.ac-cn-hongkong-c.waku.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAkzHaTP5JsUwfR9NR8Rj9HC24puS6ocaU8wze4QrXr9iXp",
|
74
|
+
"node-01.do-ams3.waku.test": "/dns4/node-01.do-ams3.waku.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAkykgaECHswi3YKJ5dMLbq2kPVCo89fcyTd38UcQD6ej5W",
|
75
|
+
"node-01.gc-us-central1-a.waku.test": "/dns4/node-01.gc-us-central1-a.waku.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmDCp8XJ9z1ev18zuv8NHekAsjNyezAvmMfFEJkiharitG"
|
76
76
|
}
|
77
77
|
}
|
78
78
|
}
|