@fireproof/core 0.19.100 → 0.19.102
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +35 -16
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -0
- package/index.d.ts +4 -0
- package/index.global.js +35 -16
- package/index.global.js.map +1 -1
- package/index.js +35 -16
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
@@ -1257,6 +1257,8 @@ var BaseBlockstore = class {
|
|
1257
1257
|
}
|
1258
1258
|
async destroy() {
|
1259
1259
|
}
|
1260
|
+
async compact() {
|
1261
|
+
}
|
1260
1262
|
async get(cid) {
|
1261
1263
|
if (!cid) throw this.logger.Error().Msg("required cid").AsError();
|
1262
1264
|
for (const f of this.transactions) {
|
@@ -1275,6 +1277,21 @@ var BaseBlockstore = class {
|
|
1275
1277
|
this.lastTxMeta = done;
|
1276
1278
|
return { t, meta: done };
|
1277
1279
|
}
|
1280
|
+
openTransaction(opts = { add: true, noLoader: false }) {
|
1281
|
+
return new CarTransaction(this, opts);
|
1282
|
+
}
|
1283
|
+
async commitTransaction(t, done, opts) {
|
1284
|
+
if (!this.loader) throw this.logger.Error().Msg("loader required to commit").AsError();
|
1285
|
+
const cars = await this.loader?.commit(t, done, opts);
|
1286
|
+
if (this.ebOpts.autoCompact && this.loader.carLog.length > this.ebOpts.autoCompact) {
|
1287
|
+
setTimeout(() => void this.compact(), 10);
|
1288
|
+
}
|
1289
|
+
if (cars) {
|
1290
|
+
this.transactions.delete(t);
|
1291
|
+
return { meta: done, cars, t };
|
1292
|
+
}
|
1293
|
+
throw this.logger.Error().Msg("failed to commit car files").AsError();
|
1294
|
+
}
|
1278
1295
|
async *entries() {
|
1279
1296
|
const seen = /* @__PURE__ */ new Set();
|
1280
1297
|
for (const t of this.transactions) {
|
@@ -3950,21 +3967,23 @@ var CRDTClock = class {
|
|
3950
3967
|
throw this.logger.Error().Msg("missing blockstore").AsError();
|
3951
3968
|
}
|
3952
3969
|
await validateBlocks(this.logger, newHead, this.blockstore);
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
3958
|
-
|
3959
|
-
|
3960
|
-
|
3961
|
-
|
3962
|
-
|
3963
|
-
|
3964
|
-
|
3965
|
-
|
3966
|
-
|
3967
|
-
|
3970
|
+
if (!this.transaction) {
|
3971
|
+
this.transaction = this.blockstore.openTransaction({ noLoader, add: false });
|
3972
|
+
}
|
3973
|
+
const tblocks = this.transaction;
|
3974
|
+
const advancedHead = await advanceBlocks(this.logger, newHead, tblocks, this.head);
|
3975
|
+
const result = await (0, import_crdt2.root)(tblocks, advancedHead);
|
3976
|
+
for (const { cid, bytes } of [
|
3977
|
+
...result.additions
|
3978
|
+
// ...result.removals
|
3979
|
+
]) {
|
3980
|
+
tblocks.putSync(cid, bytes);
|
3981
|
+
}
|
3982
|
+
if (!noLoader) {
|
3983
|
+
await this.blockstore.commitTransaction(tblocks, { head: advancedHead }, { add: false, noLoader });
|
3984
|
+
this.transaction = void 0;
|
3985
|
+
}
|
3986
|
+
this.setHead(advancedHead);
|
3968
3987
|
}
|
3969
3988
|
};
|
3970
3989
|
function sortClockHead(clockHead) {
|
@@ -4335,6 +4354,6 @@ init_utils();
|
|
4335
4354
|
|
4336
4355
|
// src/version.ts
|
4337
4356
|
var PACKAGE_VERSION = Object.keys({
|
4338
|
-
"0.19.
|
4357
|
+
"0.19.102": "xxxx"
|
4339
4358
|
})[0];
|
4340
4359
|
//# sourceMappingURL=index.cjs.map
|