Skip to content

Commit

Permalink
feat(daemon): add incarnateBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Feb 19, 2024
1 parent b391c25 commit 41fa16b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
23 changes: 23 additions & 0 deletions packages/daemon/src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,28 @@ const makeDaemonCore = async (
return provideValueForNumberedFormula(formula.type, formulaNumber, formula);
};

/**
* @param {string} powersFormulaIdentifier
* @param {string} workerFormulaIdentifier
* @param {string} bundleFormulaIdentifier
* @returns {Promise<{ formulaIdentifier: string, value: unknown }>}
*/
const incarnateBundle = async (
powersFormulaIdentifier,
workerFormulaIdentifier,
bundleFormulaIdentifier,
) => {
const formulaNumber = await randomHex512();
/** @type {import('./types.js').MakeBundleFormula} */
const formula = {
type: 'make-bundle',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifier,
bundle: bundleFormulaIdentifier,
};
return provideValueForNumberedFormula(formula.type, formulaNumber, formula);
};

/**
* @param {string} [specifiedFormulaNumber]
* @returns {Promise<{ formulaIdentifier: string, value: import('./types').EndoBootstrap }>}
Expand Down Expand Up @@ -901,6 +923,7 @@ const makeDaemonCore = async (
incarnateGuest,
incarnateEval,
incarnateUnconfined,
incarnateBundle,
incarnateHandle,
storeReaderRef,
randomHex512,
Expand Down
16 changes: 5 additions & 11 deletions packages/daemon/src/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const makeHostMaker = ({
incarnateGuest,
incarnateEval,
incarnateUnconfined,
incarnateBundle,
incarnateHandle,
storeReaderRef,
makeSha512,
Expand Down Expand Up @@ -354,19 +355,12 @@ export const makeHostMaker = ({
powersName,
);

const formula = {
/** @type {'make-bundle'} */
type: 'make-bundle',
worker: workerFormulaIdentifier,
powers: powersFormulaIdentifier,
bundle: bundleFormulaIdentifier,
};

// Behold, recursion:
// eslint-disable-next-line no-use-before-define
const { value, formulaIdentifier } = await provideValueForFormula(
formula,
'make-bundle',
const { value, formulaIdentifier } = await incarnateBundle(
powersFormulaIdentifier,
workerFormulaIdentifier,
bundleFormulaIdentifier,
);

if (resultName !== undefined) {
Expand Down

0 comments on commit 41fa16b

Please sign in to comment.