@fireproof/core 0.17.4 → 0.17.6
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/README.md +3 -2
- package/dist/browser/fireproof.cjs +7 -3
- package/dist/browser/fireproof.cjs.map +1 -1
- package/dist/browser/fireproof.d.cts +1 -0
- package/dist/browser/fireproof.d.ts +1 -0
- package/dist/browser/fireproof.global.js +129 -96
- package/dist/browser/fireproof.global.js.map +1 -1
- package/dist/browser/fireproof.js +7 -3
- package/dist/browser/fireproof.js.map +1 -1
- package/dist/browser/metafile-cjs.json +1 -1
- package/dist/browser/metafile-esm.json +1 -1
- package/dist/browser/metafile-iife.json +1 -1
- package/dist/memory/fireproof.cjs +7 -3
- package/dist/memory/fireproof.cjs.map +1 -1
- package/dist/memory/fireproof.d.cts +1 -0
- package/dist/memory/fireproof.d.ts +1 -0
- package/dist/memory/fireproof.global.js +129 -96
- package/dist/memory/fireproof.global.js.map +1 -1
- package/dist/memory/fireproof.js +7 -3
- package/dist/memory/fireproof.js.map +1 -1
- package/dist/memory/metafile-cjs.json +1 -1
- package/dist/memory/metafile-esm.json +1 -1
- package/dist/memory/metafile-iife.json +1 -1
- package/dist/node/fireproof.cjs +7 -3
- package/dist/node/fireproof.cjs.map +1 -1
- package/dist/node/fireproof.d.cts +1 -0
- package/dist/node/fireproof.d.ts +1 -0
- package/dist/node/fireproof.global.js +129 -96
- package/dist/node/fireproof.global.js.map +1 -1
- package/dist/node/fireproof.js +7 -3
- package/dist/node/fireproof.js.map +1 -1
- package/dist/node/metafile-cjs.json +1 -1
- package/dist/node/metafile-esm.json +1 -1
- package/dist/node/metafile-iife.json +1 -1
- package/package.json +3 -3
@@ -4082,7 +4082,7 @@ var Fireproof = (() => {
|
|
4082
4082
|
};
|
4083
4083
|
var parse = (source, base4) => CID.parse(source, base4);
|
4084
4084
|
|
4085
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
4085
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/block.js
|
4086
4086
|
var MemoryBlockstore = class {
|
4087
4087
|
/** @type {Map<string, Uint8Array>} */
|
4088
4088
|
#blocks = /* @__PURE__ */ new Map();
|
@@ -4129,6 +4129,22 @@ var Fireproof = (() => {
|
|
4129
4129
|
}
|
4130
4130
|
}
|
4131
4131
|
};
|
4132
|
+
var MultiBlockFetcher = class {
|
4133
|
+
/** @type {API.BlockFetcher[]} */
|
4134
|
+
#fetchers;
|
4135
|
+
/** @param {API.BlockFetcher[]} fetchers */
|
4136
|
+
constructor(...fetchers) {
|
4137
|
+
this.#fetchers = fetchers;
|
4138
|
+
}
|
4139
|
+
/** @type {API.BlockFetcher['get']} */
|
4140
|
+
async get(link2) {
|
4141
|
+
for (const f of this.#fetchers) {
|
4142
|
+
const v = await f.get(link2);
|
4143
|
+
if (v)
|
4144
|
+
return v;
|
4145
|
+
}
|
4146
|
+
}
|
4147
|
+
};
|
4132
4148
|
|
4133
4149
|
// ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
4134
4150
|
var Node = class {
|
@@ -9952,7 +9968,7 @@ You can use close({ resize: true }) to resize header`);
|
|
9952
9968
|
}
|
9953
9969
|
return bytes;
|
9954
9970
|
}
|
9955
|
-
var PACKAGE_VERSION = "0.17.
|
9971
|
+
var PACKAGE_VERSION = "0.17.5";
|
9956
9972
|
var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
|
9957
9973
|
if (!match)
|
9958
9974
|
throw new Error("invalid version: " + PACKAGE_VERSION);
|
@@ -10022,6 +10038,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10022
10038
|
key;
|
10023
10039
|
keyId;
|
10024
10040
|
seenCompacted = /* @__PURE__ */ new Set();
|
10041
|
+
processedCars = /* @__PURE__ */ new Set();
|
10025
10042
|
writing = Promise.resolve();
|
10026
10043
|
getBlockCache = /* @__PURE__ */ new Map();
|
10027
10044
|
seenMeta = /* @__PURE__ */ new Set();
|
@@ -10110,7 +10127,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10110
10127
|
// can these skip the queue? or have a file queue?
|
10111
10128
|
async _commitInternalFiles(t, done, opts = { noLoader: false, compact: false }) {
|
10112
10129
|
await this.ready;
|
10113
|
-
const { files: roots } = this.makeFileCarHeader(done
|
10130
|
+
const { files: roots } = this.makeFileCarHeader(done);
|
10114
10131
|
const { cid, bytes } = await this.prepareCarFile(roots[0], t, !!opts.public);
|
10115
10132
|
await this.fileStore.save({ cid, bytes });
|
10116
10133
|
await this.remoteWAL.enqueueFile(cid, !!opts.public);
|
@@ -10130,7 +10147,10 @@ You can use close({ resize: true }) to resize header`);
|
|
10130
10147
|
}
|
10131
10148
|
}
|
10132
10149
|
}
|
10133
|
-
async cacheCarReader(reader) {
|
10150
|
+
async cacheCarReader(carCidStr, reader) {
|
10151
|
+
if (this.processedCars.has(carCidStr))
|
10152
|
+
return;
|
10153
|
+
this.processedCars.add(carCidStr);
|
10134
10154
|
for await (const block of reader.blocks()) {
|
10135
10155
|
const sBlock = block.cid.toString();
|
10136
10156
|
if (!this.getBlockCache.has(sBlock)) {
|
@@ -10160,7 +10180,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10160
10180
|
const theKey = isPublic ? null : await this._getKey();
|
10161
10181
|
return theKey && this.ebOpts.crypto ? await encryptedEncodeCarFile(this.ebOpts.crypto, theKey, root2, t) : await encodeCarFile([root2], t);
|
10162
10182
|
}
|
10163
|
-
makeFileCarHeader(result
|
10183
|
+
makeFileCarHeader(result) {
|
10164
10184
|
const files = [];
|
10165
10185
|
for (const [, meta] of Object.entries(result.files)) {
|
10166
10186
|
if (meta && typeof meta === "object" && "cid" in meta && meta !== null) {
|
@@ -10195,10 +10215,27 @@ You can use close({ resize: true }) to resize header`);
|
|
10195
10215
|
// await this.remoteWAL!.enqueue(dbMeta, { public: false })
|
10196
10216
|
// }
|
10197
10217
|
// }
|
10198
|
-
async *entries() {
|
10218
|
+
async *entries(cache22 = true) {
|
10199
10219
|
await this.ready;
|
10200
|
-
|
10201
|
-
|
10220
|
+
if (cache22) {
|
10221
|
+
for (const [, block] of this.getBlockCache) {
|
10222
|
+
yield block;
|
10223
|
+
}
|
10224
|
+
} else {
|
10225
|
+
for (const [, block] of this.getBlockCache) {
|
10226
|
+
yield block;
|
10227
|
+
}
|
10228
|
+
for (const cid of this.carLog) {
|
10229
|
+
const reader = await this.loadCar(cid);
|
10230
|
+
if (!reader)
|
10231
|
+
throw new Error(`missing car reader ${cid.toString()}`);
|
10232
|
+
for await (const block of reader.blocks()) {
|
10233
|
+
const sCid = block.cid.toString();
|
10234
|
+
if (!this.getBlockCache.has(sCid)) {
|
10235
|
+
yield block;
|
10236
|
+
}
|
10237
|
+
}
|
10238
|
+
}
|
10202
10239
|
}
|
10203
10240
|
}
|
10204
10241
|
async getBlock(cid) {
|
@@ -10211,11 +10248,37 @@ You can use close({ resize: true }) to resize header`);
|
|
10211
10248
|
if (!reader) {
|
10212
10249
|
throw new Error(`missing car reader ${carCid.toString()}`);
|
10213
10250
|
}
|
10214
|
-
await this.cacheCarReader(reader)
|
10251
|
+
await this.cacheCarReader(carCid.toString(), reader).catch((e) => {
|
10252
|
+
});
|
10215
10253
|
if (this.getBlockCache.has(sCid))
|
10216
10254
|
return this.getBlockCache.get(sCid);
|
10217
10255
|
throw new Error(`block not in reader: ${cid.toString()}`);
|
10218
10256
|
};
|
10257
|
+
const getCompactCarCids = async (carCid) => {
|
10258
|
+
const reader = await this.loadCar(carCid);
|
10259
|
+
if (!reader) {
|
10260
|
+
throw new Error(`missing car reader ${carCid.toString()}`);
|
10261
|
+
}
|
10262
|
+
const header = await parseCarFile(reader);
|
10263
|
+
const compacts = header.compact;
|
10264
|
+
let got2;
|
10265
|
+
const batchSize2 = 5;
|
10266
|
+
for (let i = 0; i < compacts.length; i += batchSize2) {
|
10267
|
+
const promises = [];
|
10268
|
+
for (let j = i; j < Math.min(i + batchSize2, compacts.length); j++) {
|
10269
|
+
promises.push(getCarCid(compacts[j]));
|
10270
|
+
}
|
10271
|
+
try {
|
10272
|
+
got2 = await Promise.any(promises);
|
10273
|
+
} catch {
|
10274
|
+
}
|
10275
|
+
if (got2)
|
10276
|
+
break;
|
10277
|
+
}
|
10278
|
+
if (this.getBlockCache.has(sCid))
|
10279
|
+
return this.getBlockCache.get(sCid);
|
10280
|
+
throw new Error(`block not in compact reader: ${cid.toString()}`);
|
10281
|
+
};
|
10219
10282
|
let got;
|
10220
10283
|
const batchSize = 5;
|
10221
10284
|
for (let i = 0; i < this.carLog.length; i += batchSize) {
|
@@ -10230,8 +10293,19 @@ You can use close({ resize: true }) to resize header`);
|
|
10230
10293
|
if (got)
|
10231
10294
|
break;
|
10232
10295
|
}
|
10233
|
-
if (got) {
|
10234
|
-
this.
|
10296
|
+
if (!got) {
|
10297
|
+
for (let i = 0; i < this.carLog.length; i += batchSize) {
|
10298
|
+
const promises = [];
|
10299
|
+
for (let j = i; j < Math.min(i + batchSize, this.carLog.length); j++) {
|
10300
|
+
promises.push(getCompactCarCids(this.carLog[j]));
|
10301
|
+
}
|
10302
|
+
try {
|
10303
|
+
got = await Promise.any(promises);
|
10304
|
+
} catch {
|
10305
|
+
}
|
10306
|
+
if (got)
|
10307
|
+
break;
|
10308
|
+
}
|
10235
10309
|
}
|
10236
10310
|
return got;
|
10237
10311
|
}
|
@@ -10338,6 +10412,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10338
10412
|
compacting = false;
|
10339
10413
|
ebOpts;
|
10340
10414
|
transactions = /* @__PURE__ */ new Set();
|
10415
|
+
lastTxMeta = null;
|
10341
10416
|
constructor(ebOpts) {
|
10342
10417
|
this.ebOpts = ebOpts;
|
10343
10418
|
const { name: name7 } = ebOpts;
|
@@ -10352,6 +10427,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10352
10427
|
async transaction(fn, opts = { noLoader: false }) {
|
10353
10428
|
const t = new CarTransaction(this);
|
10354
10429
|
const done = await fn(t);
|
10430
|
+
this.lastTxMeta = done;
|
10355
10431
|
if (this.loader) {
|
10356
10432
|
const car = await this.loader.commit(t, done, opts);
|
10357
10433
|
if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
|
@@ -10397,7 +10473,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10397
10473
|
throw new Error("loader required to compact");
|
10398
10474
|
if (this.loader.carLog.length < 2)
|
10399
10475
|
return;
|
10400
|
-
const compactFn = this.ebOpts.compact;
|
10476
|
+
const compactFn = this.ebOpts.compact || ((blocks) => this.defaultCompact(blocks));
|
10401
10477
|
if (!compactFn || this.compacting)
|
10402
10478
|
return;
|
10403
10479
|
const blockLog = new CompactionFetcher(this);
|
@@ -10409,6 +10485,23 @@ You can use close({ resize: true }) to resize header`);
|
|
10409
10485
|
});
|
10410
10486
|
this.compacting = false;
|
10411
10487
|
}
|
10488
|
+
async defaultCompact(blocks) {
|
10489
|
+
if (!this.loader) {
|
10490
|
+
throw new Error("no loader");
|
10491
|
+
}
|
10492
|
+
if (!this.lastTxMeta) {
|
10493
|
+
throw new Error("no lastTxMeta");
|
10494
|
+
}
|
10495
|
+
for await (const blk of this.loader.entries(false)) {
|
10496
|
+
blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
|
10497
|
+
}
|
10498
|
+
for (const t of this.transactions) {
|
10499
|
+
for await (const blk of t.entries()) {
|
10500
|
+
blocks.loggedBlocks.putSync(blk.cid, blk.bytes);
|
10501
|
+
}
|
10502
|
+
}
|
10503
|
+
return this.lastTxMeta;
|
10504
|
+
}
|
10412
10505
|
async *entries() {
|
10413
10506
|
const seen = /* @__PURE__ */ new Set();
|
10414
10507
|
if (this.loader) {
|
@@ -10678,7 +10771,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10678
10771
|
}));
|
10679
10772
|
|
10680
10773
|
// ../encrypted-blockstore/dist/lib/store-web.js
|
10681
|
-
var PACKAGE_VERSION2 = "0.17.
|
10774
|
+
var PACKAGE_VERSION2 = "0.17.5";
|
10682
10775
|
var match2 = PACKAGE_VERSION2.match(/^([^.]*\.[^.]*)/);
|
10683
10776
|
if (!match2)
|
10684
10777
|
throw new Error("invalid version: " + PACKAGE_VERSION2);
|
@@ -10816,7 +10909,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10816
10909
|
const car = await this.loader.carStore.load(dbMeta.car).catch(() => null);
|
10817
10910
|
if (!car) {
|
10818
10911
|
if (cidListIncludes2(this.loader.carLog, dbMeta.car))
|
10819
|
-
throw new Error(`missing car ${dbMeta.car.toString()}`);
|
10912
|
+
throw new Error(`missing local car ${dbMeta.car.toString()}`);
|
10820
10913
|
} else {
|
10821
10914
|
await this.loader.remoteCarStore.save(car);
|
10822
10915
|
}
|
@@ -10829,7 +10922,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10829
10922
|
const car = await this.loader.carStore.load(dbMeta.car).catch(() => null);
|
10830
10923
|
if (!car) {
|
10831
10924
|
if (cidListIncludes2(this.loader.carLog, dbMeta.car))
|
10832
|
-
throw new Error(`missing car ${dbMeta.car.toString()}`);
|
10925
|
+
throw new Error(`missing local car ${dbMeta.car.toString()}`);
|
10833
10926
|
} else {
|
10834
10927
|
await this.loader.remoteCarStore.save(car);
|
10835
10928
|
}
|
@@ -10854,7 +10947,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10854
10947
|
const res = await Promise.allSettled(uploads);
|
10855
10948
|
const errors = res.filter((r) => r.status === "rejected");
|
10856
10949
|
if (errors.length) {
|
10857
|
-
console.error("error uploading", JSON.stringify(errors));
|
10950
|
+
console.error("error uploading", JSON.stringify(errors.map((e) => e.reason)));
|
10858
10951
|
throw errors[0].reason;
|
10859
10952
|
}
|
10860
10953
|
if (operations.length) {
|
@@ -10976,7 +11069,7 @@ You can use close({ resize: true }) to resize header`);
|
|
10976
11069
|
makeRemoteWAL
|
10977
11070
|
};
|
10978
11071
|
|
10979
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11072
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/clock/index.js
|
10980
11073
|
var advance = async (blocks, head, event) => {
|
10981
11074
|
const events = new EventFetcher(blocks);
|
10982
11075
|
const headmap = new Map(head.map((cid) => [cid.toString(), cid]));
|
@@ -11102,7 +11195,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11102
11195
|
};
|
11103
11196
|
var shortLink = (l) => `${String(l).slice(0, 4)}..${String(l).slice(-4)}`;
|
11104
11197
|
|
11105
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11198
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/shard.js
|
11106
11199
|
var MaxKeyLength = 64;
|
11107
11200
|
var MaxShardSize = 512 * 1024;
|
11108
11201
|
var CID_TAG2 = new Token(Type.tag, 42);
|
@@ -11234,7 +11327,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11234
11327
|
}
|
11235
11328
|
};
|
11236
11329
|
|
11237
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11330
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/index.js
|
11238
11331
|
var put = async (blocks, root2, key, value) => {
|
11239
11332
|
const shards = new ShardFetcher(blocks);
|
11240
11333
|
const rshard = await shards.get(root2);
|
@@ -11437,71 +11530,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11437
11530
|
return [shard];
|
11438
11531
|
};
|
11439
11532
|
|
11440
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11441
|
-
var MemoryBlockstore2 = class {
|
11442
|
-
/** @type {Map<string, Uint8Array>} */
|
11443
|
-
#blocks = /* @__PURE__ */ new Map();
|
11444
|
-
/**
|
11445
|
-
* @param {Array<import('multiformats').Block>} [blocks]
|
11446
|
-
*/
|
11447
|
-
constructor(blocks) {
|
11448
|
-
if (blocks) {
|
11449
|
-
this.#blocks = new Map(blocks.map((b) => [b.cid.toString(), b.bytes]));
|
11450
|
-
}
|
11451
|
-
}
|
11452
|
-
/** @type {API.BlockFetcher['get']} */
|
11453
|
-
async get(cid) {
|
11454
|
-
const bytes = this.#blocks.get(cid.toString());
|
11455
|
-
if (!bytes)
|
11456
|
-
return;
|
11457
|
-
return { cid, bytes };
|
11458
|
-
}
|
11459
|
-
/**
|
11460
|
-
* @param {API.UnknownLink} cid
|
11461
|
-
* @param {Uint8Array} bytes
|
11462
|
-
*/
|
11463
|
-
async put(cid, bytes) {
|
11464
|
-
this.#blocks.set(cid.toString(), bytes);
|
11465
|
-
}
|
11466
|
-
/**
|
11467
|
-
* @param {API.UnknownLink} cid
|
11468
|
-
* @param {Uint8Array} bytes
|
11469
|
-
*/
|
11470
|
-
putSync(cid, bytes) {
|
11471
|
-
this.#blocks.set(cid.toString(), bytes);
|
11472
|
-
}
|
11473
|
-
/** @param {API.UnknownLink} cid */
|
11474
|
-
async delete(cid) {
|
11475
|
-
this.#blocks.delete(cid.toString());
|
11476
|
-
}
|
11477
|
-
/** @param {API.UnknownLink} cid */
|
11478
|
-
deleteSync(cid) {
|
11479
|
-
this.#blocks.delete(cid.toString());
|
11480
|
-
}
|
11481
|
-
*entries() {
|
11482
|
-
for (const [str, bytes] of this.#blocks) {
|
11483
|
-
yield { cid: parse(str), bytes };
|
11484
|
-
}
|
11485
|
-
}
|
11486
|
-
};
|
11487
|
-
var MultiBlockFetcher = class {
|
11488
|
-
/** @type {API.BlockFetcher[]} */
|
11489
|
-
#fetchers;
|
11490
|
-
/** @param {API.BlockFetcher[]} fetchers */
|
11491
|
-
constructor(...fetchers) {
|
11492
|
-
this.#fetchers = fetchers;
|
11493
|
-
}
|
11494
|
-
/** @type {API.BlockFetcher['get']} */
|
11495
|
-
async get(link2) {
|
11496
|
-
for (const f of this.#fetchers) {
|
11497
|
-
const v = await f.get(link2);
|
11498
|
-
if (v)
|
11499
|
-
return v;
|
11500
|
-
}
|
11501
|
-
}
|
11502
|
-
};
|
11503
|
-
|
11504
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.1/node_modules/@web3-storage/pail/src/batch/shard.js
|
11533
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/shard.js
|
11505
11534
|
var ShardLinkByteLength = 36;
|
11506
11535
|
var CID_TAG3 = new Token(Type.tag, 42);
|
11507
11536
|
var create8 = (init2) => ({
|
@@ -11548,7 +11577,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11548
11577
|
return tokensToLength(tokens);
|
11549
11578
|
};
|
11550
11579
|
|
11551
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11580
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/batch/index.js
|
11552
11581
|
var Batcher = class _Batcher {
|
11553
11582
|
#committed = false;
|
11554
11583
|
/**
|
@@ -11730,9 +11759,9 @@ You can use close({ resize: true }) to resize header`);
|
|
11730
11759
|
static code = "ERR_BATCH_COMMITTED";
|
11731
11760
|
};
|
11732
11761
|
|
11733
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
11762
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/index.js
|
11734
11763
|
var put3 = async (blocks, head, key, value) => {
|
11735
|
-
const mblocks = new
|
11764
|
+
const mblocks = new MemoryBlockstore();
|
11736
11765
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
11737
11766
|
if (!head.length) {
|
11738
11767
|
const shard = await ShardBlock.create();
|
@@ -11816,7 +11845,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11816
11845
|
var root = async (blocks, head) => {
|
11817
11846
|
if (!head.length)
|
11818
11847
|
throw new Error("cannot determine root of headless clock");
|
11819
|
-
const mblocks = new
|
11848
|
+
const mblocks = new MemoryBlockstore();
|
11820
11849
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
11821
11850
|
const events = new EventFetcher(blocks);
|
11822
11851
|
if (head.length === 1) {
|
@@ -11875,7 +11904,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11875
11904
|
return;
|
11876
11905
|
const result = await root(blocks, head);
|
11877
11906
|
if (result.additions.length) {
|
11878
|
-
blocks = new MultiBlockFetcher(new
|
11907
|
+
blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
|
11879
11908
|
}
|
11880
11909
|
return get2(blocks, result.root, key);
|
11881
11910
|
};
|
@@ -11884,7 +11913,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11884
11913
|
return;
|
11885
11914
|
const result = await root(blocks, head);
|
11886
11915
|
if (result.additions.length) {
|
11887
|
-
blocks = new MultiBlockFetcher(new
|
11916
|
+
blocks = new MultiBlockFetcher(new MemoryBlockstore(result.additions), blocks);
|
11888
11917
|
}
|
11889
11918
|
yield* entries(blocks, result.root, options);
|
11890
11919
|
};
|
@@ -11968,7 +11997,7 @@ You can use close({ resize: true }) to resize header`);
|
|
11968
11997
|
return acc.concat(...rest);
|
11969
11998
|
};
|
11970
11999
|
|
11971
|
-
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.
|
12000
|
+
// ../../node_modules/.pnpm/@web3-storage+pail@0.4.2/node_modules/@web3-storage/pail/src/crdt/batch/index.js
|
11972
12001
|
var Batcher2 = class _Batcher {
|
11973
12002
|
#committed = false;
|
11974
12003
|
/**
|
@@ -12013,7 +12042,7 @@ You can use close({ resize: true }) to resize header`);
|
|
12013
12042
|
const res = await commit(this);
|
12014
12043
|
const data = { type: "batch", ops: this.ops, root: res.root };
|
12015
12044
|
const event = await EventBlock.create(data, this.head);
|
12016
|
-
const mblocks = new
|
12045
|
+
const mblocks = new MemoryBlockstore();
|
12017
12046
|
const blocks = new MultiBlockFetcher(mblocks, this.blocks);
|
12018
12047
|
mblocks.putSync(event.cid, event.bytes);
|
12019
12048
|
const head = await advance(blocks, this.head, event.cid);
|
@@ -12053,7 +12082,7 @@ You can use close({ resize: true }) to resize header`);
|
|
12053
12082
|
* @param {string} init.prefix
|
12054
12083
|
*/
|
12055
12084
|
static async create({ blocks, head, prefix }) {
|
12056
|
-
const mblocks = new
|
12085
|
+
const mblocks = new MemoryBlockstore();
|
12057
12086
|
blocks = new MultiBlockFetcher(mblocks, blocks);
|
12058
12087
|
if (!head.length) {
|
12059
12088
|
const base5 = await ShardBlock.create();
|
@@ -20718,7 +20747,6 @@ You can use close({ resize: true }) to resize header`);
|
|
20718
20747
|
var isCompacting = false;
|
20719
20748
|
async function doCompact(blockLog, head) {
|
20720
20749
|
if (isCompacting) {
|
20721
|
-
console.log("already compacting");
|
20722
20750
|
return;
|
20723
20751
|
}
|
20724
20752
|
isCompacting = true;
|
@@ -21425,7 +21453,10 @@ You can use close({ resize: true }) to resize header`);
|
|
21425
21453
|
const task = queue.shift();
|
21426
21454
|
if (!task)
|
21427
21455
|
continue;
|
21428
|
-
await worker(task.newHead, task.prevHead, task.updates !== null)
|
21456
|
+
await worker(task.newHead, task.prevHead, task.updates !== null).catch((e) => {
|
21457
|
+
console.error("int_applyHead worker error", e);
|
21458
|
+
throw e;
|
21459
|
+
});
|
21429
21460
|
if (task.updates) {
|
21430
21461
|
allUpdates.push(...task.updates);
|
21431
21462
|
}
|
@@ -21448,6 +21479,9 @@ You can use close({ resize: true }) to resize header`);
|
|
21448
21479
|
push(task) {
|
21449
21480
|
queue.push(task);
|
21450
21481
|
return process();
|
21482
|
+
},
|
21483
|
+
size() {
|
21484
|
+
return queue.length;
|
21451
21485
|
}
|
21452
21486
|
};
|
21453
21487
|
}
|
@@ -21549,7 +21583,6 @@ You can use close({ resize: true }) to resize header`);
|
|
21549
21583
|
try {
|
21550
21584
|
head = await advance(tblocks, head, cid);
|
21551
21585
|
} catch (e) {
|
21552
|
-
console.log("failed to advance head:", cid.toString());
|
21553
21586
|
continue;
|
21554
21587
|
}
|
21555
21588
|
}
|