@agoric/cache 0.3.3-other-dev-3eb1a1d.0 → 0.3.3-other-dev-d15096d.0.d15096d
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/package.json +15 -15
- package/src/cache.js +3 -1
- package/src/main.js +1 -1
- package/src/state.js +5 -1
- package/src/store.js +24 -16
- package/src/types.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cache",
|
|
3
|
-
"version": "0.3.3-other-dev-
|
|
3
|
+
"version": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
4
4
|
"description": "Agoric's simple cache interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -8,34 +8,34 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
10
|
"test": "ava",
|
|
11
|
-
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
11
|
+
"test:c8": "c8 --all ${C8_OPTIONS:-} ava",
|
|
12
12
|
"test:xs": "exit 0",
|
|
13
13
|
"lint-fix": "yarn lint:eslint --fix",
|
|
14
|
-
"lint": "run-s --continue-on-error lint:*",
|
|
15
|
-
"lint:types": "tsc",
|
|
16
|
-
"lint:eslint": "
|
|
14
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
15
|
+
"lint:types": "yarn run -T tsc",
|
|
16
|
+
"lint:eslint": "yarn run -T eslint ."
|
|
17
17
|
},
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "Agoric",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@agoric/internal": "0.3.3-other-dev-
|
|
23
|
-
"@agoric/notifier": "0.6.3-other-dev-
|
|
24
|
-
"@agoric/store": "0.9.3-other-dev-
|
|
25
|
-
"@agoric/vat-data": "0.5.3-other-dev-
|
|
26
|
-
"@endo/far": "^1.1.
|
|
27
|
-
"@endo/marshal": "^1.
|
|
22
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
23
|
+
"@agoric/notifier": "0.6.3-other-dev-d15096d.0.d15096d",
|
|
24
|
+
"@agoric/store": "0.9.3-other-dev-d15096d.0.d15096d",
|
|
25
|
+
"@agoric/vat-data": "0.5.3-other-dev-d15096d.0.d15096d",
|
|
26
|
+
"@endo/far": "^1.1.14",
|
|
27
|
+
"@endo/marshal": "^1.8.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@agoric/zoe": "0.26.3-other-dev-
|
|
30
|
+
"@agoric/zoe": "0.26.3-other-dev-d15096d.0.d15096d",
|
|
31
31
|
"ava": "^5.3.0",
|
|
32
|
-
"c8": "^10.1.
|
|
32
|
+
"c8": "^10.1.3"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": "^
|
|
38
|
+
"node": "^20.9 || ^22.11"
|
|
39
39
|
},
|
|
40
40
|
"ava": {
|
|
41
41
|
"files": [
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"typeCoverage": {
|
|
50
50
|
"atLeast": 94.13
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
53
53
|
}
|
package/src/cache.js
CHANGED
|
@@ -6,6 +6,8 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
9
|
+
* @import {Key, Pattern} from '@endo/patterns';
|
|
10
|
+
* @import {Coordinator} from './types.js';
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -16,7 +18,7 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
* @param {ERef<
|
|
21
|
+
* @param {ERef<Coordinator>} [coordinator]
|
|
20
22
|
*/
|
|
21
23
|
export const makeCache = (coordinator = makeScalarStoreCoordinator()) => {
|
|
22
24
|
/**
|
package/src/main.js
CHANGED
package/src/state.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// @jessie-check
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @import {State} from './state.js';
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* @typedef {object} State
|
|
5
9
|
* @property {bigint} generation
|
|
@@ -30,7 +34,7 @@ export const makeState = (value, priorState = GROUND_STATE) =>
|
|
|
30
34
|
/**
|
|
31
35
|
* Wrap a state store to have a default value using the GROUND_STATE
|
|
32
36
|
*
|
|
33
|
-
* @param {MapStore<string,
|
|
37
|
+
* @param {MapStore<string, State>} stateStore
|
|
34
38
|
*/
|
|
35
39
|
export const withGroundState = stateStore => ({
|
|
36
40
|
...stateStore,
|
package/src/store.js
CHANGED
|
@@ -4,7 +4,15 @@ import { matches, makeScalarMapStore } from '@agoric/store';
|
|
|
4
4
|
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
5
5
|
import { untilTrue } from '@agoric/internal';
|
|
6
6
|
import { withGroundState, makeState } from './state.js';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {ERemote} from '@agoric/internal'
|
|
10
|
+
* @import {EMarshaller} from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
11
|
+
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
12
|
+
* @import {Key, Pattern} from '@endo/patterns';
|
|
13
|
+
* @import {State} from './state.js';
|
|
14
|
+
* @import {Coordinator} from './types.js';
|
|
15
|
+
*/
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
18
|
* @param {(obj: Passable) => Passable} [sanitize]
|
|
@@ -41,9 +49,9 @@ const makeKeyToString = (sanitize = obj => obj) => {
|
|
|
41
49
|
* @param {(obj: Passable) => Passable} sanitize Process keys and values with
|
|
42
50
|
* this function before storing them
|
|
43
51
|
* @param {{
|
|
44
|
-
* get(key: string):
|
|
45
|
-
* set(key: string, value:
|
|
46
|
-
* init(key: string, value:
|
|
52
|
+
* get(key: string): State;
|
|
53
|
+
* set(key: string, value: State): void;
|
|
54
|
+
* init(key: string, value: State): void;
|
|
47
55
|
* }} stateStore
|
|
48
56
|
* @returns {Promise<Passable>} the value of the updated state
|
|
49
57
|
*/
|
|
@@ -57,8 +65,8 @@ const applyCacheTransaction = async (
|
|
|
57
65
|
/**
|
|
58
66
|
* Retrieve a potential updated state from the transaction.
|
|
59
67
|
*
|
|
60
|
-
* @param {
|
|
61
|
-
* @returns {Promise<
|
|
68
|
+
* @param {State} basisState
|
|
69
|
+
* @returns {Promise<State | null>} the updated state, or null if no longer applicable
|
|
62
70
|
*/
|
|
63
71
|
const getUpdatedState = async basisState => {
|
|
64
72
|
const { value } = basisState;
|
|
@@ -107,8 +115,8 @@ const applyCacheTransaction = async (
|
|
|
107
115
|
};
|
|
108
116
|
|
|
109
117
|
/**
|
|
110
|
-
* @param {MapStore<string,
|
|
111
|
-
* @param {
|
|
118
|
+
* @param {MapStore<string, State>} stateStore
|
|
119
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
112
120
|
* @returns {Promise<string>}
|
|
113
121
|
*/
|
|
114
122
|
const stringifyStateStore = async (stateStore, marshaller) => {
|
|
@@ -126,7 +134,7 @@ const stringifyStateStore = async (stateStore, marshaller) => {
|
|
|
126
134
|
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
|
|
127
135
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
128
136
|
*
|
|
129
|
-
* @param {MapStore<string,
|
|
137
|
+
* @param {MapStore<string, State>} [stateStore]
|
|
130
138
|
* @param {(obj: Passable) => Passable} [sanitize] Process keys and values with
|
|
131
139
|
* this function before storing them. Defaults to deeplyFulfilled.
|
|
132
140
|
*/
|
|
@@ -138,7 +146,7 @@ export const makeScalarStoreCoordinator = (
|
|
|
138
146
|
|
|
139
147
|
const defaultStateStore = withGroundState(stateStore);
|
|
140
148
|
|
|
141
|
-
/** @type {
|
|
149
|
+
/** @type {Coordinator} */
|
|
142
150
|
const coord = Far('store cache coordinator', {
|
|
143
151
|
getRecentValue: async key => {
|
|
144
152
|
const keyStr = await serializePassable(key);
|
|
@@ -171,9 +179,9 @@ export const makeScalarStoreCoordinator = (
|
|
|
171
179
|
/**
|
|
172
180
|
* Don't write any marshalled value that's older than what's already pushed
|
|
173
181
|
*
|
|
174
|
-
* @param {MapStore<string,
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
182
|
+
* @param {MapStore<string, State>} stateStore
|
|
183
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
184
|
+
* @param {ERemote<StorageNode>} storageNode
|
|
177
185
|
* @returns {<T>(storedValue: T) => Promise<T>}
|
|
178
186
|
*/
|
|
179
187
|
const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
|
|
@@ -201,8 +209,8 @@ const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
|
|
|
201
209
|
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
|
|
202
210
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
203
211
|
*
|
|
204
|
-
* @param {
|
|
205
|
-
* @param {
|
|
212
|
+
* @param {ERemote<StorageNode>} storageNode
|
|
213
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
206
214
|
*/
|
|
207
215
|
export const makeChainStorageCoordinator = (storageNode, marshaller) => {
|
|
208
216
|
const stateStore = makeScalarBigMapStore('stateKey');
|
|
@@ -218,7 +226,7 @@ export const makeChainStorageCoordinator = (storageNode, marshaller) => {
|
|
|
218
226
|
storageNode,
|
|
219
227
|
);
|
|
220
228
|
|
|
221
|
-
/** @type {
|
|
229
|
+
/** @type {Coordinator} */
|
|
222
230
|
const coord = Far('store cache coordinator', {
|
|
223
231
|
getRecentValue: async key => {
|
|
224
232
|
const keyStr = await serializePassable(key);
|