@based/db 0.0.49 → 0.0.50
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/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/references/references.js +3 -3
- package/dist/src/client/modify/types.d.ts +2 -0
- package/dist/src/client/modify/types.js +2 -0
- package/dist/src/client/query/BasedDbQuery.js +15 -1
- package/dist/src/server/start.js +23 -7
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { REFERENCES } from '@based/schema/def';
|
|
2
2
|
import { ModifyError, ModifyState } from '../ModifyRes.js';
|
|
3
3
|
import { setCursor } from '../setCursor.js';
|
|
4
|
-
import { DELETE, EDGE_INDEX_REALID, EDGE_INDEX_TMPID, EDGE_NOINDEX_REALID, EDGE_NOINDEX_TMPID, NOEDGE_INDEX_REALID, NOEDGE_INDEX_TMPID, NOEDGE_NOINDEX_REALID, NOEDGE_NOINDEX_TMPID, RANGE_ERR, REF_OP_UPDATE, } from '../types.js';
|
|
4
|
+
import { DELETE, EDGE_INDEX_REALID, EDGE_INDEX_TMPID, EDGE_NOINDEX_REALID, EDGE_NOINDEX_TMPID, NOEDGE_INDEX_REALID, NOEDGE_INDEX_TMPID, NOEDGE_NOINDEX_REALID, NOEDGE_NOINDEX_TMPID, RANGE_ERR, REF_OP_OVERWRITE, REF_OP_PUT_ADD, REF_OP_PUT_OVERWRITE, REF_OP_UPDATE, } from '../types.js';
|
|
5
5
|
import { writeEdges } from './edge.js';
|
|
6
6
|
export function writeReferences(value, ctx, schema, def, res, mod) {
|
|
7
7
|
if (typeof value !== 'object') {
|
|
@@ -266,8 +266,8 @@ function putRefs(def, ctx, modifyOp, refs, op) {
|
|
|
266
266
|
ctx.buf[ctx.len++] = size >>>= 8;
|
|
267
267
|
ctx.buf[ctx.len++] = size >>>= 8;
|
|
268
268
|
ctx.buf[ctx.len++] = size >>>= 8;
|
|
269
|
-
ctx.buf[ctx.len++] =
|
|
270
|
-
|
|
269
|
+
ctx.buf[ctx.len++] =
|
|
270
|
+
op === REF_OP_OVERWRITE ? REF_OP_PUT_OVERWRITE : REF_OP_PUT_ADD;
|
|
271
271
|
let i = 0;
|
|
272
272
|
for (; i < refs.length; i++) {
|
|
273
273
|
let ref = refs[i];
|
|
@@ -37,4 +37,6 @@ export declare const EDGE_INDEX_TMPID = 6;
|
|
|
37
37
|
export declare const NOEDGE_INDEX_TMPID = 7;
|
|
38
38
|
export declare const REF_OP_UPDATE = 1;
|
|
39
39
|
export declare const REF_OP_OVERWRITE = 0;
|
|
40
|
+
export declare const REF_OP_PUT_OVERWRITE = 3;
|
|
41
|
+
export declare const REF_OP_PUT_ADD = 4;
|
|
40
42
|
export type REF_OP = typeof REF_OP_OVERWRITE | typeof REF_OP_UPDATE;
|
|
@@ -12,6 +12,8 @@ import { convertFilter } from './filter/convertFilter.js';
|
|
|
12
12
|
import { validateLocale, validateRange } from './validation.js';
|
|
13
13
|
import { DEF_RANGE_PROP_LIMIT } from './thresholds.js';
|
|
14
14
|
import { concatUint8Arr } from '@saulx/utils';
|
|
15
|
+
import { displayTarget } from './display.js';
|
|
16
|
+
import picocolors from 'picocolors';
|
|
15
17
|
export class QueryBranch {
|
|
16
18
|
db;
|
|
17
19
|
def;
|
|
@@ -357,7 +359,19 @@ export class BasedDbQuery extends QueryBranch {
|
|
|
357
359
|
return this;
|
|
358
360
|
}
|
|
359
361
|
subscribe(onData, onError) {
|
|
360
|
-
return subscribe(this,
|
|
362
|
+
return subscribe(this, (res) => {
|
|
363
|
+
try {
|
|
364
|
+
onData(res);
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
// const t = displayTarget(this.def)
|
|
368
|
+
const def = this.def;
|
|
369
|
+
let name = picocolors.red(`QueryError[${displayTarget(def)}]\n`);
|
|
370
|
+
name += ` Error executing onData handler in subscription\n`;
|
|
371
|
+
name += ` ${err.message}\n`;
|
|
372
|
+
console.error(name);
|
|
373
|
+
}
|
|
374
|
+
}, onError ??
|
|
361
375
|
((err) => {
|
|
362
376
|
console.error(err);
|
|
363
377
|
}));
|
package/dist/src/server/start.js
CHANGED
|
@@ -2,13 +2,12 @@ import { DbWorker, SCHEMA_FILE, WRITELOG_FILE } from './index.js';
|
|
|
2
2
|
import native from '../native.js';
|
|
3
3
|
import { rm, mkdir, readFile } from 'node:fs/promises';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import { foreachBlock, initCsmt, makeCsmtKey } from './tree.js';
|
|
5
|
+
import { destructureCsmtKey, foreachBlock, initCsmt, makeCsmtKey, specialBlock } from './tree.js';
|
|
7
6
|
import { availableParallelism } from 'node:os';
|
|
8
7
|
import exitHook from 'exit-hook';
|
|
9
8
|
import { save } from './save.js';
|
|
10
9
|
import { DEFAULT_BLOCK_CAPACITY } from '@based/schema/def';
|
|
11
|
-
import { bufToHex
|
|
10
|
+
import { bufToHex } from '@saulx/utils';
|
|
12
11
|
export async function start(db, opts) {
|
|
13
12
|
const path = db.fileSystemPath;
|
|
14
13
|
const noop = () => { };
|
|
@@ -74,10 +73,27 @@ export async function start(db, opts) {
|
|
|
74
73
|
}, true);
|
|
75
74
|
}
|
|
76
75
|
if (writelog?.hash) {
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
// FIXME FDN-1301
|
|
77
|
+
//const oldHash = hexToBuf(writelog.hash)
|
|
78
|
+
//const newHash = db.merkleTree.getRoot()?.hash
|
|
79
|
+
//if (!hashEq(oldHash, newHash)) {
|
|
80
|
+
// console.error(
|
|
81
|
+
// `WARN: CSMT hash mismatch. expected: ${writelog.hash} actual: ${bufToHex(newHash)}`,
|
|
82
|
+
// )
|
|
83
|
+
//}
|
|
84
|
+
const oldHashSet = new Set();
|
|
85
|
+
const newHashSet = new Set();
|
|
86
|
+
for (let k in writelog.rangeDumps)
|
|
87
|
+
writelog.rangeDumps[k].forEach(({ hash }) => oldHashSet.add(hash));
|
|
88
|
+
db.merkleTree.visitLeafNodes(({ key, hash }) => {
|
|
89
|
+
const [_typeId, start] = destructureCsmtKey(key);
|
|
90
|
+
if (start == specialBlock)
|
|
91
|
+
return; // skip the type specialBlock
|
|
92
|
+
newHashSet.add(bufToHex(hash));
|
|
93
|
+
});
|
|
94
|
+
const setEq = (a, b) => a.size === b.size && [...a].every(value => b.has(value));
|
|
95
|
+
if (!setEq(oldHashSet, newHashSet)) {
|
|
96
|
+
console.error(`WARN: CSMT hash mismatch.`);
|
|
81
97
|
}
|
|
82
98
|
}
|
|
83
99
|
// start workers
|