@aztec/kv-store 0.0.0-test.1 → 0.0.1-commit.b655e406
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/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +5 -3
- package/dest/indexeddb/array.d.ts +2 -1
- package/dest/indexeddb/array.d.ts.map +1 -1
- package/dest/indexeddb/array.js +3 -0
- package/dest/indexeddb/index.js +1 -1
- package/dest/indexeddb/map.d.ts +11 -5
- package/dest/indexeddb/map.d.ts.map +1 -1
- package/dest/indexeddb/map.js +38 -60
- package/dest/indexeddb/multi_map.d.ts +12 -0
- package/dest/indexeddb/multi_map.d.ts.map +1 -0
- package/dest/indexeddb/multi_map.js +78 -0
- package/dest/indexeddb/singleton.d.ts +2 -1
- package/dest/indexeddb/singleton.d.ts.map +1 -1
- package/dest/indexeddb/singleton.js +3 -1
- package/dest/indexeddb/store.d.ts +12 -13
- package/dest/indexeddb/store.d.ts.map +1 -1
- package/dest/indexeddb/store.js +45 -42
- package/dest/interfaces/array.d.ts +4 -3
- package/dest/interfaces/array.d.ts.map +1 -1
- package/dest/interfaces/array.js +1 -3
- package/dest/interfaces/common.d.ts +10 -8
- package/dest/interfaces/common.d.ts.map +1 -1
- package/dest/interfaces/common.js +8 -3
- package/dest/interfaces/index.d.ts +3 -1
- package/dest/interfaces/index.d.ts.map +1 -1
- package/dest/interfaces/index.js +2 -0
- package/dest/interfaces/map.d.ts +20 -48
- package/dest/interfaces/map.d.ts.map +1 -1
- package/dest/interfaces/map.js +1 -1
- package/dest/interfaces/map_test_suite.d.ts.map +1 -1
- package/dest/interfaces/map_test_suite.js +135 -70
- package/dest/interfaces/multi_map.d.ts +35 -0
- package/dest/interfaces/multi_map.d.ts.map +1 -0
- package/dest/interfaces/multi_map.js +3 -0
- package/dest/interfaces/multi_map_test_suite.d.ts +3 -0
- package/dest/interfaces/multi_map_test_suite.d.ts.map +1 -0
- package/dest/interfaces/multi_map_test_suite.js +245 -0
- package/dest/interfaces/store.d.ts +17 -42
- package/dest/interfaces/store.d.ts.map +1 -1
- package/dest/interfaces/utils.d.ts +1 -0
- package/dest/interfaces/utils.d.ts.map +1 -1
- package/dest/interfaces/utils.js +2 -1
- package/dest/lmdb/array.d.ts +2 -1
- package/dest/lmdb/array.d.ts.map +1 -1
- package/dest/lmdb/index.js +2 -2
- package/dest/lmdb/map.d.ts +10 -22
- package/dest/lmdb/map.d.ts.map +1 -1
- package/dest/lmdb/map.js +15 -81
- package/dest/lmdb/multi_map.d.ts +12 -0
- package/dest/lmdb/multi_map.d.ts.map +1 -0
- package/dest/lmdb/multi_map.js +29 -0
- package/dest/lmdb/store.d.ts +7 -22
- package/dest/lmdb/store.d.ts.map +1 -1
- package/dest/lmdb/store.js +11 -31
- package/dest/lmdb-v2/array.d.ts +2 -1
- package/dest/lmdb-v2/array.d.ts.map +1 -1
- package/dest/lmdb-v2/array.js +1 -0
- package/dest/lmdb-v2/factory.d.ts +1 -1
- package/dest/lmdb-v2/factory.d.ts.map +1 -1
- package/dest/lmdb-v2/factory.js +16 -6
- package/dest/lmdb-v2/map.d.ts +10 -43
- package/dest/lmdb-v2/map.d.ts.map +1 -1
- package/dest/lmdb-v2/map.js +17 -103
- package/dest/lmdb-v2/message.d.ts +23 -4
- package/dest/lmdb-v2/message.d.ts.map +1 -1
- package/dest/lmdb-v2/message.js +6 -4
- package/dest/lmdb-v2/multi_map.d.ts +51 -0
- package/dest/lmdb-v2/multi_map.d.ts.map +1 -0
- package/dest/lmdb-v2/multi_map.js +113 -0
- package/dest/lmdb-v2/read_transaction.d.ts +2 -0
- package/dest/lmdb-v2/read_transaction.d.ts.map +1 -1
- package/dest/lmdb-v2/read_transaction.js +34 -0
- package/dest/lmdb-v2/set.d.ts +15 -0
- package/dest/lmdb-v2/set.d.ts.map +1 -0
- package/dest/lmdb-v2/set.js +23 -0
- package/dest/lmdb-v2/singleton.d.ts.map +1 -1
- package/dest/lmdb-v2/singleton.js +1 -0
- package/dest/lmdb-v2/store.d.ts +9 -8
- package/dest/lmdb-v2/store.d.ts.map +1 -1
- package/dest/lmdb-v2/store.js +19 -7
- package/dest/lmdb-v2/utils.d.ts +2 -4
- package/dest/lmdb-v2/utils.d.ts.map +1 -1
- package/dest/lmdb-v2/write_transaction.d.ts +2 -4
- package/dest/lmdb-v2/write_transaction.d.ts.map +1 -1
- package/dest/stores/index.d.ts +1 -0
- package/dest/stores/index.d.ts.map +1 -1
- package/dest/stores/index.js +1 -0
- package/dest/stores/l2_tips_store.d.ts +2 -1
- package/dest/stores/l2_tips_store.d.ts.map +1 -1
- package/dest/stores/l2_tips_store.js +18 -9
- package/package.json +18 -14
- package/src/config.ts +6 -4
- package/src/indexeddb/array.ts +5 -1
- package/src/indexeddb/index.ts +2 -2
- package/src/indexeddb/map.ts +35 -53
- package/src/indexeddb/multi_map.ts +79 -0
- package/src/indexeddb/singleton.ts +4 -1
- package/src/indexeddb/store.ts +66 -56
- package/src/interfaces/array.ts +5 -3
- package/src/interfaces/common.ts +20 -9
- package/src/interfaces/index.ts +3 -1
- package/src/interfaces/map.ts +19 -53
- package/src/interfaces/map_test_suite.ts +73 -44
- package/src/interfaces/multi_map.ts +38 -0
- package/src/interfaces/multi_map_test_suite.ts +242 -0
- package/src/interfaces/store.ts +18 -53
- package/src/interfaces/utils.ts +1 -0
- package/src/lmdb/array.ts +2 -1
- package/src/lmdb/index.ts +3 -3
- package/src/lmdb/map.ts +23 -94
- package/src/lmdb/multi_map.ts +35 -0
- package/src/lmdb/store.ts +23 -47
- package/src/lmdb-v2/array.ts +7 -2
- package/src/lmdb-v2/factory.ts +17 -10
- package/src/lmdb-v2/map.ts +29 -126
- package/src/lmdb-v2/message.ts +23 -0
- package/src/lmdb-v2/multi_map.ts +141 -0
- package/src/lmdb-v2/read_transaction.ts +40 -0
- package/src/lmdb-v2/set.ts +33 -0
- package/src/lmdb-v2/singleton.ts +5 -1
- package/src/lmdb-v2/store.ts +22 -14
- package/src/lmdb-v2/write_transaction.ts +2 -2
- package/src/stores/index.ts +2 -0
- package/src/stores/l2_tips_store.ts +18 -9
- package/dest/interfaces/store_test_suite.d.ts +0 -3
- package/dest/interfaces/store_test_suite.d.ts.map +0 -1
- package/dest/interfaces/store_test_suite.js +0 -37
- package/src/interfaces/store_test_suite.ts +0 -56
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Key, Value } from './common.js';
|
|
2
|
+
import type { AztecAsyncMap, AztecMap } from './map.js';
|
|
3
|
+
/**
|
|
4
|
+
* A map backed by a persistent store that can have multiple values for a single key.
|
|
5
|
+
*/
|
|
6
|
+
export interface AztecMultiMap<K extends Key, V extends Value> extends AztecMap<K, V> {
|
|
7
|
+
/**
|
|
8
|
+
* Gets all the values at the given key.
|
|
9
|
+
* @param key - The key to get the values from
|
|
10
|
+
*/
|
|
11
|
+
getValues(key: K): IterableIterator<V>;
|
|
12
|
+
/**
|
|
13
|
+
* Deletes a specific value at the given key.
|
|
14
|
+
* @param key - The key to delete the value at
|
|
15
|
+
* @param val - The value to delete
|
|
16
|
+
*/
|
|
17
|
+
deleteValue(key: K, val: V): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A map backed by a persistent store that can have multiple values for a single key.
|
|
21
|
+
*/
|
|
22
|
+
export interface AztecAsyncMultiMap<K extends Key, V extends Value> extends AztecAsyncMap<K, V> {
|
|
23
|
+
/**
|
|
24
|
+
* Gets all the values at the given key.
|
|
25
|
+
* @param key - The key to get the values from
|
|
26
|
+
*/
|
|
27
|
+
getValuesAsync(key: K): AsyncIterableIterator<V>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a specific value at the given key.
|
|
30
|
+
* @param key - The key to delete the value at
|
|
31
|
+
* @param val - The value to delete
|
|
32
|
+
*/
|
|
33
|
+
deleteValue(key: K, val: V): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=multi_map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi_map.d.ts","sourceRoot":"","sources":["../../src/interfaces/multi_map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,KAAK,CAAE,SAAQ,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACnF;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAEvC;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,KAAK,CAAE,SAAQ,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7F;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAEjD;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi_map_test_suite.d.ts","sourceRoot":"","sources":["../../src/interfaces/multi_map_test_suite.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlE,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,EACzD,UAAU,GAAE,OAAe,QAqO5B"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { toArray } from '@aztec/foundation/iterable';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { isSyncStore } from './utils.js';
|
|
4
|
+
export function describeAztecMultiMap(testName, getStore, forceAsync = false) {
|
|
5
|
+
describe(testName, ()=>{
|
|
6
|
+
let store;
|
|
7
|
+
let multiMap;
|
|
8
|
+
beforeEach(async ()=>{
|
|
9
|
+
store = await getStore();
|
|
10
|
+
multiMap = store.openMultiMap('test');
|
|
11
|
+
});
|
|
12
|
+
afterEach(async ()=>{
|
|
13
|
+
await store.delete();
|
|
14
|
+
});
|
|
15
|
+
async function get(key, sut = multiMap) {
|
|
16
|
+
return isSyncStore(store) && !forceAsync ? sut.get(key) : await sut.getAsync(key);
|
|
17
|
+
}
|
|
18
|
+
async function size(sut = multiMap) {
|
|
19
|
+
return isSyncStore(store) && !forceAsync ? sut.size() : await sut.sizeAsync();
|
|
20
|
+
}
|
|
21
|
+
async function entries() {
|
|
22
|
+
return isSyncStore(store) && !forceAsync ? await toArray(multiMap.entries()) : await toArray(multiMap.entriesAsync());
|
|
23
|
+
}
|
|
24
|
+
async function values() {
|
|
25
|
+
return isSyncStore(store) && !forceAsync ? await toArray(multiMap.values()) : await toArray(multiMap.valuesAsync());
|
|
26
|
+
}
|
|
27
|
+
async function keys(range, sut = multiMap) {
|
|
28
|
+
return isSyncStore(store) && !forceAsync ? await toArray(sut.keys(range)) : await toArray(sut.keysAsync(range));
|
|
29
|
+
}
|
|
30
|
+
async function getValues(key) {
|
|
31
|
+
return isSyncStore(store) && !forceAsync ? await toArray(multiMap.getValues(key)) : await toArray(multiMap.getValuesAsync(key));
|
|
32
|
+
}
|
|
33
|
+
it('should be able to set and get values', async ()=>{
|
|
34
|
+
await multiMap.set('foo', 'bar');
|
|
35
|
+
await multiMap.set('baz', 'qux');
|
|
36
|
+
expect(await get('foo')).to.equal('bar');
|
|
37
|
+
expect(await get('baz')).to.equal('qux');
|
|
38
|
+
expect(await get('quux')).to.equal(undefined);
|
|
39
|
+
});
|
|
40
|
+
it('should be able to set values if they do not exist', async ()=>{
|
|
41
|
+
expect(await multiMap.setIfNotExists('foo', 'bar')).to.equal(true);
|
|
42
|
+
expect(await multiMap.setIfNotExists('foo', 'baz')).to.equal(false);
|
|
43
|
+
expect(await get('foo')).to.equal('bar');
|
|
44
|
+
});
|
|
45
|
+
it('should be able to delete values', async ()=>{
|
|
46
|
+
await multiMap.set('foo', 'bar');
|
|
47
|
+
await multiMap.set('baz', 'qux');
|
|
48
|
+
await multiMap.delete('foo');
|
|
49
|
+
expect(await get('foo')).to.equal(undefined);
|
|
50
|
+
expect(await get('baz')).to.equal('qux');
|
|
51
|
+
});
|
|
52
|
+
it('should be able to get size of the map', async ()=>{
|
|
53
|
+
await multiMap.set('foo', 'bar');
|
|
54
|
+
expect(await size()).to.equal(1);
|
|
55
|
+
await multiMap.set('baz', 'qux');
|
|
56
|
+
expect(await size()).to.equal(2);
|
|
57
|
+
await multiMap.delete('foo');
|
|
58
|
+
expect(await size()).to.equal(1);
|
|
59
|
+
});
|
|
60
|
+
it('should be able to iterate over entries when there are no keys', async ()=>{
|
|
61
|
+
expect(await entries()).to.deep.equal([]);
|
|
62
|
+
});
|
|
63
|
+
it('should be able to iterate over entries', async ()=>{
|
|
64
|
+
await multiMap.set('foo', 'bar');
|
|
65
|
+
await multiMap.set('baz', 'qux');
|
|
66
|
+
expect(await entries()).to.deep.equal([
|
|
67
|
+
[
|
|
68
|
+
'baz',
|
|
69
|
+
'qux'
|
|
70
|
+
],
|
|
71
|
+
[
|
|
72
|
+
'foo',
|
|
73
|
+
'bar'
|
|
74
|
+
]
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
it('should be able to iterate over values', async ()=>{
|
|
78
|
+
await multiMap.set('foo', 'bar');
|
|
79
|
+
await multiMap.set('baz', 'quux');
|
|
80
|
+
expect(await values()).to.deep.equal([
|
|
81
|
+
'quux',
|
|
82
|
+
'bar'
|
|
83
|
+
]);
|
|
84
|
+
});
|
|
85
|
+
it('should be able to iterate over keys', async ()=>{
|
|
86
|
+
await multiMap.set('foo', 'bar');
|
|
87
|
+
await multiMap.set('baz', 'qux');
|
|
88
|
+
expect(await keys()).to.deep.equal([
|
|
89
|
+
'baz',
|
|
90
|
+
'foo'
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
it('should be able to get multiple values for a single key', async ()=>{
|
|
94
|
+
await multiMap.set('foo', 'bar');
|
|
95
|
+
await multiMap.set('foo', 'baz');
|
|
96
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
97
|
+
'bar',
|
|
98
|
+
'baz'
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
it('should ignore multiple identical values', async ()=>{
|
|
102
|
+
await multiMap.set('foo', 'bar');
|
|
103
|
+
await multiMap.set('foo', 'bar');
|
|
104
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
105
|
+
'bar'
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
it('should be able to delete individual values for a single key', async ()=>{
|
|
109
|
+
await multiMap.set('foo', '1');
|
|
110
|
+
await multiMap.set('foo', '2');
|
|
111
|
+
await multiMap.set('foo', '3');
|
|
112
|
+
await multiMap.deleteValue('foo', '2');
|
|
113
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
114
|
+
'1',
|
|
115
|
+
'3'
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
it('should be able to get size of the map with duplicate keys', async ()=>{
|
|
119
|
+
await multiMap.set('foo', '1');
|
|
120
|
+
await multiMap.set('foo', '2');
|
|
121
|
+
await multiMap.set('foo', '3');
|
|
122
|
+
expect(await size()).to.equal(3);
|
|
123
|
+
await multiMap.set('bar', '1');
|
|
124
|
+
await multiMap.set('bar', '2');
|
|
125
|
+
await multiMap.set('bar', '3');
|
|
126
|
+
expect(await size()).to.equal(6);
|
|
127
|
+
await multiMap.deleteValue('foo', '2');
|
|
128
|
+
expect(await size()).to.equal(5);
|
|
129
|
+
});
|
|
130
|
+
it('should be able to delete the last and first values for a key', async ()=>{
|
|
131
|
+
await multiMap.set('foo', '1');
|
|
132
|
+
await multiMap.set('foo', '2');
|
|
133
|
+
await multiMap.set('foo', '3');
|
|
134
|
+
await multiMap.deleteValue('foo', '1');
|
|
135
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
136
|
+
'2',
|
|
137
|
+
'3'
|
|
138
|
+
]);
|
|
139
|
+
await multiMap.deleteValue('foo', '3');
|
|
140
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
141
|
+
'2'
|
|
142
|
+
]);
|
|
143
|
+
});
|
|
144
|
+
it('should be able to fully clear a key', async ()=>{
|
|
145
|
+
await multiMap.set('foo', '1');
|
|
146
|
+
await multiMap.set('foo', '2');
|
|
147
|
+
await multiMap.set('foo', '3');
|
|
148
|
+
await multiMap.deleteValue('foo', '1');
|
|
149
|
+
await multiMap.deleteValue('foo', '3');
|
|
150
|
+
await multiMap.deleteValue('foo', '2');
|
|
151
|
+
expect(await getValues('foo')).to.deep.equal([]);
|
|
152
|
+
});
|
|
153
|
+
it('should be able to insert after deletion', async ()=>{
|
|
154
|
+
await multiMap.set('foo', '1');
|
|
155
|
+
await multiMap.set('foo', '2');
|
|
156
|
+
await multiMap.set('foo', '3');
|
|
157
|
+
await multiMap.deleteValue('foo', '2');
|
|
158
|
+
await multiMap.set('foo', 'bar');
|
|
159
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
160
|
+
'1',
|
|
161
|
+
'3',
|
|
162
|
+
'bar'
|
|
163
|
+
]);
|
|
164
|
+
// Delete the just-added entry
|
|
165
|
+
await multiMap.deleteValue('foo', 'bar');
|
|
166
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
167
|
+
'1',
|
|
168
|
+
'3'
|
|
169
|
+
]);
|
|
170
|
+
// Reinsert the initially deleted key
|
|
171
|
+
await multiMap.set('foo', '2');
|
|
172
|
+
// LMDB and IndexedDB behave differently here, the former ordering by value and the latter by insertion. This is
|
|
173
|
+
// fine because there is no expectation for values in a multimap to be ordered.
|
|
174
|
+
const values = (await getValues('foo')).sort((a, b)=>a.localeCompare(b));
|
|
175
|
+
expect(values).to.deep.equal([
|
|
176
|
+
'1',
|
|
177
|
+
'2',
|
|
178
|
+
'3'
|
|
179
|
+
]);
|
|
180
|
+
// Fully clear the key
|
|
181
|
+
await multiMap.deleteValue('foo', '1');
|
|
182
|
+
await multiMap.deleteValue('foo', '3');
|
|
183
|
+
await multiMap.deleteValue('foo', '2');
|
|
184
|
+
// Insert some more
|
|
185
|
+
await multiMap.set('foo', 'baz');
|
|
186
|
+
await multiMap.set('foo', 'qux');
|
|
187
|
+
expect(await getValues('foo')).to.deep.equal([
|
|
188
|
+
'baz',
|
|
189
|
+
'qux'
|
|
190
|
+
]);
|
|
191
|
+
});
|
|
192
|
+
it('supports range queries', async ()=>{
|
|
193
|
+
await multiMap.set('a', 'a');
|
|
194
|
+
await multiMap.set('b', 'b');
|
|
195
|
+
await multiMap.set('c', 'c');
|
|
196
|
+
await multiMap.set('d', 'd');
|
|
197
|
+
expect(await keys({
|
|
198
|
+
start: 'b',
|
|
199
|
+
end: 'c'
|
|
200
|
+
})).to.deep.equal([
|
|
201
|
+
'b'
|
|
202
|
+
]);
|
|
203
|
+
expect(await keys({
|
|
204
|
+
start: 'b'
|
|
205
|
+
})).to.deep.equal([
|
|
206
|
+
'b',
|
|
207
|
+
'c',
|
|
208
|
+
'd'
|
|
209
|
+
]);
|
|
210
|
+
expect(await keys({
|
|
211
|
+
end: 'c'
|
|
212
|
+
})).to.deep.equal([
|
|
213
|
+
'a',
|
|
214
|
+
'b'
|
|
215
|
+
]);
|
|
216
|
+
expect(await keys({
|
|
217
|
+
start: 'b',
|
|
218
|
+
end: 'c',
|
|
219
|
+
reverse: true
|
|
220
|
+
})).to.deep.equal([
|
|
221
|
+
'c'
|
|
222
|
+
]);
|
|
223
|
+
expect(await keys({
|
|
224
|
+
start: 'b',
|
|
225
|
+
limit: 1
|
|
226
|
+
})).to.deep.equal([
|
|
227
|
+
'b'
|
|
228
|
+
]);
|
|
229
|
+
expect(await keys({
|
|
230
|
+
start: 'b',
|
|
231
|
+
reverse: true
|
|
232
|
+
})).to.deep.equal([
|
|
233
|
+
'd',
|
|
234
|
+
'c'
|
|
235
|
+
]);
|
|
236
|
+
expect(await keys({
|
|
237
|
+
end: 'b',
|
|
238
|
+
reverse: true
|
|
239
|
+
})).to.deep.equal([
|
|
240
|
+
'b',
|
|
241
|
+
'a'
|
|
242
|
+
]);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AztecArray, AztecAsyncArray } from './array.js';
|
|
2
|
-
import type { Key, StoreSize } from './common.js';
|
|
2
|
+
import type { Key, StoreSize, Value } from './common.js';
|
|
3
3
|
import type { AztecAsyncCounter, AztecCounter } from './counter.js';
|
|
4
|
-
import type { AztecAsyncMap,
|
|
4
|
+
import type { AztecAsyncMap, AztecMap } from './map.js';
|
|
5
|
+
import type { AztecAsyncMultiMap, AztecMultiMap } from './multi_map.js';
|
|
5
6
|
import type { AztecAsyncSet, AztecSet } from './set.js';
|
|
6
7
|
import type { AztecAsyncSingleton, AztecSingleton } from './singleton.js';
|
|
7
8
|
/** A key-value store */
|
|
@@ -12,7 +13,7 @@ export interface AztecKVStore {
|
|
|
12
13
|
* @param name - The name of the map
|
|
13
14
|
* @returns The map
|
|
14
15
|
*/
|
|
15
|
-
openMap<K extends Key, V>(name: string): AztecMap<K, V>;
|
|
16
|
+
openMap<K extends Key, V extends Value>(name: string): AztecMap<K, V>;
|
|
16
17
|
/**
|
|
17
18
|
* Creates a new set.
|
|
18
19
|
* @param name - The name of the set
|
|
@@ -24,31 +25,19 @@ export interface AztecKVStore {
|
|
|
24
25
|
* @param name - The name of the multi-map
|
|
25
26
|
* @returns The multi-map
|
|
26
27
|
*/
|
|
27
|
-
openMultiMap<K extends Key, V>(name: string): AztecMultiMap<K, V>;
|
|
28
|
-
/**
|
|
29
|
-
* Creates a new multi-map with size.
|
|
30
|
-
* @param name - The name of the multi-map
|
|
31
|
-
* @returns The multi-map
|
|
32
|
-
*/
|
|
33
|
-
openMultiMapWithSize<K extends Key, V>(name: string): AztecMultiMapWithSize<K, V>;
|
|
34
|
-
/**
|
|
35
|
-
* Creates a new map with size.
|
|
36
|
-
* @param name - The name of the map
|
|
37
|
-
* @returns The map
|
|
38
|
-
*/
|
|
39
|
-
openMapWithSize<K extends Key, V>(name: string): AztecMapWithSize<K, V>;
|
|
28
|
+
openMultiMap<K extends Key, V extends Value>(name: string): AztecMultiMap<K, V>;
|
|
40
29
|
/**
|
|
41
30
|
* Creates a new array.
|
|
42
31
|
* @param name - The name of the array
|
|
43
32
|
* @returns The array
|
|
44
33
|
*/
|
|
45
|
-
openArray<T>(name: string): AztecArray<T>;
|
|
34
|
+
openArray<T extends Value>(name: string): AztecArray<T>;
|
|
46
35
|
/**
|
|
47
36
|
* Creates a new singleton.
|
|
48
37
|
* @param name - The name of the singleton
|
|
49
38
|
* @returns The singleton
|
|
50
39
|
*/
|
|
51
|
-
openSingleton<T>(name: string): AztecSingleton<T>;
|
|
40
|
+
openSingleton<T extends Value>(name: string): AztecSingleton<T>;
|
|
52
41
|
/**
|
|
53
42
|
* Creates a new count map.
|
|
54
43
|
* @param name - name of the counter
|
|
@@ -63,10 +52,6 @@ export interface AztecKVStore {
|
|
|
63
52
|
* Clears all entries in the store
|
|
64
53
|
*/
|
|
65
54
|
clear(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Forks the store.
|
|
68
|
-
*/
|
|
69
|
-
fork(): Promise<AztecKVStore>;
|
|
70
55
|
/**
|
|
71
56
|
* Deletes the store
|
|
72
57
|
*/
|
|
@@ -86,7 +71,7 @@ export interface AztecAsyncKVStore {
|
|
|
86
71
|
* @param name - The name of the map
|
|
87
72
|
* @returns The map
|
|
88
73
|
*/
|
|
89
|
-
openMap<K extends Key, V>(name: string): AztecAsyncMap<K, V>;
|
|
74
|
+
openMap<K extends Key, V extends Value>(name: string): AztecAsyncMap<K, V>;
|
|
90
75
|
/**
|
|
91
76
|
* Creates a new set.
|
|
92
77
|
* @param name - The name of the set
|
|
@@ -98,19 +83,19 @@ export interface AztecAsyncKVStore {
|
|
|
98
83
|
* @param name - The name of the multi-map
|
|
99
84
|
* @returns The multi-map
|
|
100
85
|
*/
|
|
101
|
-
openMultiMap<K extends Key, V>(name: string): AztecAsyncMultiMap<K, V>;
|
|
86
|
+
openMultiMap<K extends Key, V extends Value>(name: string): AztecAsyncMultiMap<K, V>;
|
|
102
87
|
/**
|
|
103
88
|
* Creates a new array.
|
|
104
89
|
* @param name - The name of the array
|
|
105
90
|
* @returns The array
|
|
106
91
|
*/
|
|
107
|
-
openArray<T>(name: string): AztecAsyncArray<T>;
|
|
92
|
+
openArray<T extends Value>(name: string): AztecAsyncArray<T>;
|
|
108
93
|
/**
|
|
109
94
|
* Creates a new singleton.
|
|
110
95
|
* @param name - The name of the singleton
|
|
111
96
|
* @returns The singleton
|
|
112
97
|
*/
|
|
113
|
-
openSingleton<T>(name: string): AztecAsyncSingleton<T>;
|
|
98
|
+
openSingleton<T extends Value>(name: string): AztecAsyncSingleton<T>;
|
|
114
99
|
/**
|
|
115
100
|
* Creates a new count map.
|
|
116
101
|
* @param name - name of the counter
|
|
@@ -121,25 +106,15 @@ export interface AztecAsyncKVStore {
|
|
|
121
106
|
* @param callback - The callback to execute in a transaction
|
|
122
107
|
*/
|
|
123
108
|
transactionAsync<T extends Exclude<any, Promise<any>>>(callback: () => Promise<T>): Promise<T>;
|
|
124
|
-
/**
|
|
125
|
-
* Clears all entries in the store
|
|
126
|
-
*/
|
|
109
|
+
/** Clears all entries in the store */
|
|
127
110
|
clear(): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Forks the store.
|
|
130
|
-
*/
|
|
131
|
-
fork(): Promise<AztecAsyncKVStore>;
|
|
132
|
-
/**
|
|
133
|
-
* Deletes the store
|
|
134
|
-
*/
|
|
111
|
+
/** Deletes the store */
|
|
135
112
|
delete(): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Estimates the size of the store in bytes.
|
|
138
|
-
*/
|
|
113
|
+
/** Estimates the size of the store in bytes. */
|
|
139
114
|
estimateSize(): Promise<StoreSize>;
|
|
140
|
-
/**
|
|
141
|
-
* Closes the store
|
|
142
|
-
*/
|
|
115
|
+
/** Closes the store */
|
|
143
116
|
close(): Promise<void>;
|
|
117
|
+
/** Backups the store to the target folder.*/
|
|
118
|
+
backupTo(dstPath: string, compact?: boolean): Promise<void>;
|
|
144
119
|
}
|
|
145
120
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/interfaces/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/interfaces/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAA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AEvB,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D"}
|
|
@@ -11,6 +11,7 @@ export declare const mockLogger: {
|
|
|
11
11
|
level: "trace";
|
|
12
12
|
isLevelEnabled: (_level: string) => boolean;
|
|
13
13
|
module: string;
|
|
14
|
+
createChild: () => /*elided*/ any;
|
|
14
15
|
};
|
|
15
16
|
export declare function isSyncStore(store: AztecKVStore | AztecAsyncKVStore): store is AztecAsyncKVStore;
|
|
16
17
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/interfaces/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlE,eAAO,MAAM,UAAU;iBACR,MAAM,QAAQ,GAAG;gBAClB,MAAM,QAAQ,GAAG;gBACjB,MAAM,QAAQ,GAAG;iBAChB,MAAM,QAAQ,GAAG;iBACjB,MAAM,QAAQ,GAAG;mBACf,MAAM,SAAS,GAAG;mBAClB,MAAM,QAAQ,GAAG;iBACnB,MAAM,QAAQ,GAAG;;6BAEL,MAAM
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/interfaces/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGlE,eAAO,MAAM,UAAU;iBACR,MAAM,QAAQ,GAAG;gBAClB,MAAM,QAAQ,GAAG;gBACjB,MAAM,QAAQ,GAAG;iBAChB,MAAM,QAAQ,GAAG;iBACjB,MAAM,QAAQ,GAAG;mBACf,MAAM,SAAS,GAAG;mBAClB,MAAM,QAAQ,GAAG;iBACnB,MAAM,QAAQ,GAAG;;6BAEL,MAAM;;;CAGhC,CAAC;AAGF,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,iBAAiB,GAAG,KAAK,IAAI,iBAAiB,CAE/F"}
|
package/dest/interfaces/utils.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
trace: (msg, data)=>console.log(msg, data),
|
|
10
10
|
level: 'trace',
|
|
11
11
|
isLevelEnabled: (_level)=>true,
|
|
12
|
-
module: 'kv-store:mock-logger'
|
|
12
|
+
module: 'kv-store:mock-logger',
|
|
13
|
+
createChild: ()=>mockLogger
|
|
13
14
|
};
|
|
14
15
|
/* eslint-enable no-console */ export function isSyncStore(store) {
|
|
15
16
|
return store.syncGetters === true;
|
package/dest/lmdb/array.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Database, Key } from 'lmdb';
|
|
2
2
|
import type { AztecArray, AztecAsyncArray } from '../interfaces/array.js';
|
|
3
|
+
import type { Value } from '../interfaces/common.js';
|
|
3
4
|
/**
|
|
4
5
|
* An persistent array backed by LMDB.
|
|
5
6
|
*/
|
|
6
|
-
export declare class LmdbAztecArray<T> implements AztecArray<T>, AztecAsyncArray<T> {
|
|
7
|
+
export declare class LmdbAztecArray<T extends Value> implements AztecArray<T>, AztecAsyncArray<T> {
|
|
7
8
|
#private;
|
|
8
9
|
constructor(db: Database<unknown, Key>, arrName: string);
|
|
9
10
|
get length(): number;
|
package/dest/lmdb/array.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/lmdb/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/lmdb/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAA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@ -8,8 +8,8 @@ export function createStore(name, config, log = createLogger('kv-store')) {
|
|
|
8
8
|
if (typeof dataDirectory !== 'undefined') {
|
|
9
9
|
dataDirectory = join(dataDirectory, name);
|
|
10
10
|
}
|
|
11
|
-
log.info(dataDirectory ? `Creating ${name} data store at directory ${dataDirectory} with map size ${config.
|
|
12
|
-
const store = AztecLmdbStore.open(dataDirectory, config.
|
|
11
|
+
log.info(dataDirectory ? `Creating ${name} data store at directory ${dataDirectory} with map size ${config.dataStoreMapSizeKb} KB` : `Creating ${name} ephemeral data store with map size ${config.dataStoreMapSizeKb} KB`);
|
|
12
|
+
const store = AztecLmdbStore.open(dataDirectory, config.dataStoreMapSizeKb, false);
|
|
13
13
|
if (config.l1Contracts?.rollupAddress) {
|
|
14
14
|
return initStoreForRollup(store, config.l1Contracts.rollupAddress, log);
|
|
15
15
|
}
|
package/dest/lmdb/map.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import type { Database } from 'lmdb';
|
|
4
|
-
import type { Key, Range } from '../interfaces/common.js';
|
|
5
|
-
import type {
|
|
2
|
+
import type { Key, Range, Value } from '../interfaces/common.js';
|
|
3
|
+
import type { AztecAsyncMap, AztecMap } from '../interfaces/map.js';
|
|
6
4
|
/** The slot where a key-value entry would be stored */
|
|
7
5
|
type MapValueSlot<K extends Key | Buffer> = ['map', string, 'slot', K];
|
|
8
6
|
/**
|
|
9
7
|
* A map backed by LMDB.
|
|
10
8
|
*/
|
|
11
|
-
export declare class LmdbAztecMap<K extends Key, V> implements
|
|
9
|
+
export declare class LmdbAztecMap<K extends Key, V extends Value> implements AztecMap<K, V>, AztecAsyncMap<K, V> {
|
|
12
10
|
protected db: Database<[K, V], MapValueSlot<K>>;
|
|
13
11
|
protected name: string;
|
|
14
12
|
protected startSentinel: MapValueSlot<Buffer>;
|
|
@@ -17,36 +15,26 @@ export declare class LmdbAztecMap<K extends Key, V> implements AztecMultiMap<K,
|
|
|
17
15
|
close(): Promise<void>;
|
|
18
16
|
get(key: K): V | undefined;
|
|
19
17
|
getAsync(key: K): Promise<V | undefined>;
|
|
20
|
-
getValues(key: K): IterableIterator<V>;
|
|
21
|
-
getValuesAsync(key: K): AsyncIterableIterator<V>;
|
|
22
18
|
has(key: K): boolean;
|
|
23
19
|
hasAsync(key: K): Promise<boolean>;
|
|
24
20
|
set(key: K, val: V): Promise<void>;
|
|
21
|
+
setMany(entries: {
|
|
22
|
+
key: K;
|
|
23
|
+
value: V;
|
|
24
|
+
}[]): Promise<void>;
|
|
25
25
|
swap(key: K, fn: (val: V | undefined) => V): Promise<void>;
|
|
26
26
|
setIfNotExists(key: K, val: V): Promise<boolean>;
|
|
27
27
|
delete(key: K): Promise<void>;
|
|
28
|
-
deleteValue(key: K, val: V): Promise<void>;
|
|
29
28
|
entries(range?: Range<K>): IterableIterator<[K, V]>;
|
|
30
|
-
entriesAsync(range?: Range<K>
|
|
29
|
+
entriesAsync(range?: Range<K>): AsyncIterableIterator<[K, V]>;
|
|
31
30
|
values(range?: Range<K>): IterableIterator<V>;
|
|
32
31
|
valuesAsync(range?: Range<K>): AsyncIterableIterator<V>;
|
|
32
|
+
size(): number;
|
|
33
|
+
sizeAsync(): Promise<number>;
|
|
33
34
|
keys(range?: Range<K>): IterableIterator<K>;
|
|
34
35
|
keysAsync(range?: Range<K>): AsyncIterableIterator<K>;
|
|
35
36
|
protected slot(key: K): MapValueSlot<K>;
|
|
36
37
|
clear(): Promise<void>;
|
|
37
38
|
}
|
|
38
|
-
export declare class LmdbAztecMapWithSize<K extends Key, V> extends LmdbAztecMap<K, V> implements AztecMapWithSize<K, V>, AztecAsyncMultiMap<K, V> {
|
|
39
|
-
#private;
|
|
40
|
-
constructor(rootDb: Database, mapName: string);
|
|
41
|
-
set(key: K, val: V): Promise<void>;
|
|
42
|
-
delete(key: K): Promise<void>;
|
|
43
|
-
deleteValue(key: K, val: V): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Gets the size of the map by counting entries.
|
|
46
|
-
* @returns The number of entries in the map
|
|
47
|
-
*/
|
|
48
|
-
size(): number;
|
|
49
|
-
clearCache(): void;
|
|
50
|
-
}
|
|
51
39
|
export {};
|
|
52
40
|
//# sourceMappingURL=map.d.ts.map
|
package/dest/lmdb/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/lmdb/map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/lmdb/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,MAAM,CAAC;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEpE,uDAAuD;AACvD,KAAK,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAEvE;;GAEG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,KAAK,CAAE,YAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;IACtG,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9C,SAAS,CAAC,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;gBAEh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