@agoric/cache 0.3.3-other-dev-fbe72e7.0.fbe72e7 → 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 +7 -7
- package/src/cache.js +2 -1
- package/src/main.js +1 -1
- package/src/state.js +5 -1
- package/src/store.js +19 -15
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",
|
|
@@ -19,15 +19,15 @@
|
|
|
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-
|
|
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
26
|
"@endo/far": "^1.1.14",
|
|
27
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
32
|
"c8": "^10.1.3"
|
|
33
33
|
},
|
|
@@ -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
|
@@ -7,6 +7,7 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
9
9
|
* @import {Key, Pattern} from '@endo/patterns';
|
|
10
|
+
* @import {Coordinator} from './types.js';
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -17,7 +18,7 @@ import { makeScalarStoreCoordinator } from './store.js';
|
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* @param {ERef<
|
|
21
|
+
* @param {ERef<Coordinator>} [coordinator]
|
|
21
22
|
*/
|
|
22
23
|
export const makeCache = (coordinator = makeScalarStoreCoordinator()) => {
|
|
23
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
|
@@ -6,8 +6,12 @@ import { untilTrue } from '@agoric/internal';
|
|
|
6
6
|
import { withGroundState, makeState } from './state.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
+
* @import {ERemote} from '@agoric/internal'
|
|
10
|
+
* @import {EMarshaller} from '@agoric/internal/src/marshal/wrap-marshaller.js';
|
|
9
11
|
* @import {Passable, RemotableObject} from '@endo/pass-style';
|
|
10
12
|
* @import {Key, Pattern} from '@endo/patterns';
|
|
13
|
+
* @import {State} from './state.js';
|
|
14
|
+
* @import {Coordinator} from './types.js';
|
|
11
15
|
*/
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -45,9 +49,9 @@ const makeKeyToString = (sanitize = obj => obj) => {
|
|
|
45
49
|
* @param {(obj: Passable) => Passable} sanitize Process keys and values with
|
|
46
50
|
* this function before storing them
|
|
47
51
|
* @param {{
|
|
48
|
-
* get(key: string):
|
|
49
|
-
* set(key: string, value:
|
|
50
|
-
* init(key: string, value:
|
|
52
|
+
* get(key: string): State;
|
|
53
|
+
* set(key: string, value: State): void;
|
|
54
|
+
* init(key: string, value: State): void;
|
|
51
55
|
* }} stateStore
|
|
52
56
|
* @returns {Promise<Passable>} the value of the updated state
|
|
53
57
|
*/
|
|
@@ -61,8 +65,8 @@ const applyCacheTransaction = async (
|
|
|
61
65
|
/**
|
|
62
66
|
* Retrieve a potential updated state from the transaction.
|
|
63
67
|
*
|
|
64
|
-
* @param {
|
|
65
|
-
* @returns {Promise<
|
|
68
|
+
* @param {State} basisState
|
|
69
|
+
* @returns {Promise<State | null>} the updated state, or null if no longer applicable
|
|
66
70
|
*/
|
|
67
71
|
const getUpdatedState = async basisState => {
|
|
68
72
|
const { value } = basisState;
|
|
@@ -111,8 +115,8 @@ const applyCacheTransaction = async (
|
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
/**
|
|
114
|
-
* @param {MapStore<string,
|
|
115
|
-
* @param {
|
|
118
|
+
* @param {MapStore<string, State>} stateStore
|
|
119
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
116
120
|
* @returns {Promise<string>}
|
|
117
121
|
*/
|
|
118
122
|
const stringifyStateStore = async (stateStore, marshaller) => {
|
|
@@ -130,7 +134,7 @@ const stringifyStateStore = async (stateStore, marshaller) => {
|
|
|
130
134
|
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
|
|
131
135
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
132
136
|
*
|
|
133
|
-
* @param {MapStore<string,
|
|
137
|
+
* @param {MapStore<string, State>} [stateStore]
|
|
134
138
|
* @param {(obj: Passable) => Passable} [sanitize] Process keys and values with
|
|
135
139
|
* this function before storing them. Defaults to deeplyFulfilled.
|
|
136
140
|
*/
|
|
@@ -142,7 +146,7 @@ export const makeScalarStoreCoordinator = (
|
|
|
142
146
|
|
|
143
147
|
const defaultStateStore = withGroundState(stateStore);
|
|
144
148
|
|
|
145
|
-
/** @type {
|
|
149
|
+
/** @type {Coordinator} */
|
|
146
150
|
const coord = Far('store cache coordinator', {
|
|
147
151
|
getRecentValue: async key => {
|
|
148
152
|
const keyStr = await serializePassable(key);
|
|
@@ -175,9 +179,9 @@ export const makeScalarStoreCoordinator = (
|
|
|
175
179
|
/**
|
|
176
180
|
* Don't write any marshalled value that's older than what's already pushed
|
|
177
181
|
*
|
|
178
|
-
* @param {MapStore<string,
|
|
179
|
-
* @param {
|
|
180
|
-
* @param {
|
|
182
|
+
* @param {MapStore<string, State>} stateStore
|
|
183
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
184
|
+
* @param {ERemote<StorageNode>} storageNode
|
|
181
185
|
* @returns {<T>(storedValue: T) => Promise<T>}
|
|
182
186
|
*/
|
|
183
187
|
const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
|
|
@@ -205,8 +209,8 @@ const makeLastWinsUpdater = (stateStore, marshaller, storageNode) => {
|
|
|
205
209
|
* Make a cache coordinator backed by a MapStore. This coordinator doesn't
|
|
206
210
|
* currently enforce any cache eviction, but that would be a useful feature.
|
|
207
211
|
*
|
|
208
|
-
* @param {
|
|
209
|
-
* @param {
|
|
212
|
+
* @param {ERemote<StorageNode>} storageNode
|
|
213
|
+
* @param {ERemote<EMarshaller>} marshaller
|
|
210
214
|
*/
|
|
211
215
|
export const makeChainStorageCoordinator = (storageNode, marshaller) => {
|
|
212
216
|
const stateStore = makeScalarBigMapStore('stateKey');
|
|
@@ -222,7 +226,7 @@ export const makeChainStorageCoordinator = (storageNode, marshaller) => {
|
|
|
222
226
|
storageNode,
|
|
223
227
|
);
|
|
224
228
|
|
|
225
|
-
/** @type {
|
|
229
|
+
/** @type {Coordinator} */
|
|
226
230
|
const coord = Far('store cache coordinator', {
|
|
227
231
|
getRecentValue: async key => {
|
|
228
232
|
const keyStr = await serializePassable(key);
|