Skip to content

Commit

Permalink
refactor(cosmic-swingset): factor out common blockingSend steps
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Jul 28, 2023
1 parent 655133e commit 2e06f25
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,8 @@ export async function launch({
// Handle block related actions
// Some actions that are integration specific may be handled by the caller
// For example COSMOS_SNAPSHOT is handled in chain-main.js
async function blockingSend(action) {
if (decohered) {
throw decohered;
}

await afterCommitWorkDone;

async function doBlockingSend(action) {
await null;
// blockManagerConsole.warn(
// 'FIGME: blockHeight',
// action.blockHeight,
Expand Down Expand Up @@ -842,7 +837,7 @@ export async function launch({

// We write out our on-chain state as a number of chainSends.
const start = Date.now();
await Promise.all([saveChainState(), pendingSwingStoreExport]);
await saveChainState();
chainTime = Date.now() - start;

// Advance our saved state variables.
Expand All @@ -865,6 +860,15 @@ export async function launch({
}
}
}
async function blockingSend(action) {
if (decohered) {
throw decohered;
}

await afterCommitWorkDone;

return doBlockingSend(action).finally(() => pendingSwingStoreExport);
}

async function shutdown() {
return controller.shutdown();
Expand Down

0 comments on commit 2e06f25

Please sign in to comment.