From 80516f797f89b4b3aced2fa2a7c51cc9b108db8a Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Tue, 20 Feb 2024 12:09:23 -0800 Subject: [PATCH] refactor(daemon): Make makeControllerForFormula synchronous Makes `makeControllerForFormula` and its dependent functions synchronous. Also performs some unused parameter cleanup. --- packages/daemon/src/daemon.js | 24 ++++++++++-------------- packages/daemon/src/host.js | 1 - 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/daemon/src/daemon.js b/packages/daemon/src/daemon.js index b929dac396..08f7e888ad 100644 --- a/packages/daemon/src/daemon.js +++ b/packages/daemon/src/daemon.js @@ -49,7 +49,6 @@ const makeInspector = (type, number, record) => * @param {import('./types.js').DaemonicPowers} powers * @param {Promise} webletPortP * @param {object} args - * @param {Promise} args.cancelled * @param {(error: Error) => void} args.cancel * @param {number} args.gracePeriodMs * @param {Promise} args.gracePeriodElapsed @@ -57,7 +56,7 @@ const makeInspector = (type, number, record) => const makeDaemonCore = async ( powers, webletPortP, - { cancelled, cancel, gracePeriodMs, gracePeriodElapsed }, + { cancel, gracePeriodMs, gracePeriodElapsed }, ) => { const { crypto: cryptoPowers, @@ -336,7 +335,7 @@ const makeDaemonCore = async ( * @param {import('./types.js').Formula} formula * @param {import('./types.js').Context} context */ - const makeControllerForFormula = async ( + const makeControllerForFormula = ( formulaIdentifier, formulaNumber, formula, @@ -622,15 +621,16 @@ const makeDaemonCore = async ( }; /** @type {import('./types.js').ProvideValueForFormulaIdentifier} */ - const provideValueForFormulaIdentifier = async formulaIdentifier => { + const provideValueForFormulaIdentifier = formulaIdentifier => { const controller = /** @type {import('./types.js').Controller<>} */ ( provideControllerForFormulaIdentifier(formulaIdentifier) ); - const value = await controller.external; - if (typeof value === 'object' && value !== null) { - formulaIdentifierForRef.set(value, formulaIdentifier); - } - return value; + return controller.external.then(value => { + if (typeof value === 'object' && value !== null) { + formulaIdentifierForRef.set(value, formulaIdentifier); + } + return value; + }); }; /** @type {import('./types.js').ProvideControllerForFormulaIdentifierAndResolveHandle} */ @@ -1010,7 +1010,6 @@ const makeDaemonCore = async ( incarnateWebBundle, incarnateHandle, storeReaderRef, - randomHex512, makeMailbox, }); @@ -1159,7 +1158,6 @@ const makeDaemonCore = async ( * @param {import('./types.js').DaemonicPowers} powers * @param {Promise} webletPortP * @param {object} args - * @param {Promise} args.cancelled * @param {(error: Error) => void} args.cancel * @param {number} args.gracePeriodMs * @param {Promise} args.gracePeriodElapsed @@ -1168,12 +1166,11 @@ const makeDaemonCore = async ( const provideEndoBootstrap = async ( powers, webletPortP, - { cancelled, cancel, gracePeriodMs, gracePeriodElapsed }, + { cancel, gracePeriodMs, gracePeriodElapsed }, ) => { const { persistence: persistencePowers } = powers; const daemonCore = await makeDaemonCore(powers, webletPortP, { - cancelled, cancel, gracePeriodMs, gracePeriodElapsed, @@ -1228,7 +1225,6 @@ export const makeDaemon = async (powers, daemonLabel, cancel, cancelled) => { powers, assignedWebletPortP, { - cancelled, cancel, gracePeriodMs, gracePeriodElapsed, diff --git a/packages/daemon/src/host.js b/packages/daemon/src/host.js index c0cf74bc42..cc9fbec9f8 100644 --- a/packages/daemon/src/host.js +++ b/packages/daemon/src/host.js @@ -17,7 +17,6 @@ export const makeHostMaker = ({ incarnateWebBundle, incarnateHandle, storeReaderRef, - randomHex512, makeMailbox, }) => { /**