@peerbit/shared-log 10.4.12 → 11.0.0-c5f9b43
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/src/debounce.d.ts +4 -16
- package/dist/src/debounce.d.ts.map +1 -1
- package/dist/src/debounce.js +2 -74
- package/dist/src/debounce.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +20 -15
- package/dist/src/index.js.map +1 -1
- package/dist/src/ranges.d.ts +9 -2
- package/dist/src/ranges.d.ts.map +1 -1
- package/dist/src/ranges.js +14 -1
- package/dist/src/ranges.js.map +1 -1
- package/dist/src/sync/rateless-iblt.d.ts +2 -2
- package/dist/src/sync/rateless-iblt.d.ts.map +1 -1
- package/dist/src/sync/rateless-iblt.js +10 -15
- package/dist/src/sync/rateless-iblt.js.map +1 -1
- package/dist/src/sync/simple.d.ts +2 -2
- package/dist/src/sync/simple.d.ts.map +1 -1
- package/dist/src/sync/simple.js +9 -11
- package/dist/src/sync/simple.js.map +1 -1
- package/package.json +70 -70
- package/src/debounce.ts +2 -100
- package/src/index.ts +28 -16
- package/src/ranges.ts +13 -1
- package/src/sync/rateless-iblt.ts +13 -23
- package/src/sync/simple.ts +9 -11
package/src/sync/simple.ts
CHANGED
|
@@ -43,11 +43,11 @@ export class ResponseMaybeSync extends TransportMessage {
|
|
|
43
43
|
@variant([0, 5])
|
|
44
44
|
export class RequestMaybeSyncCoordinate extends TransportMessage {
|
|
45
45
|
@field({ type: vec("u64") })
|
|
46
|
-
|
|
46
|
+
hashNumbers: bigint[];
|
|
47
47
|
|
|
48
|
-
constructor(props: {
|
|
48
|
+
constructor(props: { hashNumbers: bigint[] }) {
|
|
49
49
|
super();
|
|
50
|
-
this.
|
|
50
|
+
this.hashNumbers = props.hashNumbers;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -64,16 +64,14 @@ const getHashesFromSymbols = async (
|
|
|
64
64
|
const entries = await entryIndex
|
|
65
65
|
.iterate(
|
|
66
66
|
{ query: queries.length > 1 ? new Or(queries) : queries },
|
|
67
|
-
{ shape: { hash: true,
|
|
67
|
+
{ shape: { hash: true, hashNumber: true } },
|
|
68
68
|
)
|
|
69
69
|
.all();
|
|
70
70
|
queries = [];
|
|
71
71
|
|
|
72
72
|
for (const entry of entries) {
|
|
73
73
|
results.add(entry.value.hash);
|
|
74
|
-
|
|
75
|
-
coordinateToHash.add(coordinate, entry.value.hash);
|
|
76
|
-
}
|
|
74
|
+
coordinateToHash.add(entry.value.hashNumber, entry.value.hash);
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
};
|
|
@@ -84,7 +82,7 @@ const getHashesFromSymbols = async (
|
|
|
84
82
|
continue;
|
|
85
83
|
}
|
|
86
84
|
const matchQuery = new IntegerCompare({
|
|
87
|
-
key: "
|
|
85
|
+
key: "hashNumber",
|
|
88
86
|
compare: Compare.Equal,
|
|
89
87
|
value: symbols[i],
|
|
90
88
|
});
|
|
@@ -168,7 +166,7 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
|
|
|
168
166
|
return true;
|
|
169
167
|
} else if (msg instanceof RequestMaybeSyncCoordinate) {
|
|
170
168
|
const hashes = await getHashesFromSymbols(
|
|
171
|
-
msg.
|
|
169
|
+
msg.hashNumbers,
|
|
172
170
|
this.entryIndex,
|
|
173
171
|
this.coordinateToHash,
|
|
174
172
|
);
|
|
@@ -261,7 +259,7 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
|
|
|
261
259
|
|
|
262
260
|
await this.rpc.send(
|
|
263
261
|
isBigInt
|
|
264
|
-
? new RequestMaybeSyncCoordinate({
|
|
262
|
+
? new RequestMaybeSyncCoordinate({ hashNumbers: hashes as bigint[] })
|
|
265
263
|
: new ResponseMaybeSync({ hashes: hashes as string[] }),
|
|
266
264
|
{
|
|
267
265
|
mode: new SilentDelivery({ to, redundancy: 1 }),
|
|
@@ -271,7 +269,7 @@ export class SimpleSyncronizer<R extends "u32" | "u64">
|
|
|
271
269
|
}
|
|
272
270
|
private async checkHasCoordinateOrHash(key: string | bigint) {
|
|
273
271
|
return typeof key === "bigint"
|
|
274
|
-
? (await this.entryIndex.count({ query: {
|
|
272
|
+
? (await this.entryIndex.count({ query: { hashNumber: key } })) > 0
|
|
275
273
|
: this.log.has(key);
|
|
276
274
|
}
|
|
277
275
|
async open() {
|