Skip to content

Commit

Permalink
Merge pull request #6783 from Agoric/5285-durable-publishkits
Browse files Browse the repository at this point in the history
5285 durable publishkits
  • Loading branch information
mergify[bot] authored Jan 15, 2023
2 parents 8f9e16b + 6f61cea commit 8ed2bf6
Show file tree
Hide file tree
Showing 9 changed files with 1,702 additions and 1,583 deletions.
43 changes: 42 additions & 1 deletion packages/inter-protocol/src/contractSupport.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { AmountMath } from '@agoric/ertp';
import { makeStoredPublisherKit, makeStoredPublishKit } from '@agoric/notifier';
import { M } from '@agoric/store';
import {
makeScalarBigMapStore,
provide,
provideDurableSetStore,
} from '@agoric/vat-data';
import { E } from '@endo/eventual-send';
import { Far } from '@endo/marshal';

const { Fail, quote: q } = assert;

Expand Down Expand Up @@ -78,7 +84,7 @@ export const checkDebtLimit = (debtLimit, totalDebt, toMint) => {
};

/**
* @deprecated use makeMetricsPublishKit
* @deprecated incompatible with durability; instead handle vstorage ephemerally on a durable PublishKit
* @template T
* @param {ERef<StorageNode>} storageNode
* @param {ERef<Marshaller>} marshaller
Expand Down Expand Up @@ -113,6 +119,7 @@ harden(makeMetricsPublisherKit);
*/

/**
* @deprecated incompatible with durability; instead handle vstorage ephemerally on a durable PublishKit
* @template T
* @param {ERef<StorageNode>} storageNode
* @param {ERef<Marshaller>} marshaller
Expand Down Expand Up @@ -158,3 +165,37 @@ export const makeEphemeraProvider = init => {
};
};
harden(makeEphemeraProvider);

export const provideEmptySeat = (zcf, baggage, name) => {
return provide(baggage, name, () => zcf.makeEmptySeatKit().zcfSeat);
};
harden(provideEmptySeat);

/**
* For making singletons, so that each baggage carries a separate kind definition (albeit of the definer)
*
* @param {import('@agoric/vat-data').Baggage} baggage
* @param {string} category diagnostic tag
* @returns {import('@agoric/vat-data').Baggage}
*/
export const provideChildBaggage = (baggage, category) => {
const baggageSet = provideDurableSetStore(baggage, `${category}Set`);
return Far('childBaggageManager', {
/**
* @template {(baggage: import('@agoric/ertp').Baggage) => any} M Maker function
* @param {string} childName diagnostic tag
* @param {M} makeChild
* @returns {ReturnType<M>}
*/
addChild: (childName, makeChild) => {
const childStore = makeScalarBigMapStore(`${childName}${category}`, {
durable: true,
});
const result = makeChild(childStore);
baggageSet.add(childStore);
return result;
},
children: () => baggageSet.values(),
});
};
harden(provideChildBaggage);
Loading

0 comments on commit 8ed2bf6

Please sign in to comment.