Skip to content

Commit

Permalink
use helper functions in vatKeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Apr 26, 2023
1 parent 3849751 commit 0a33e8f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions packages/SwingSet/src/kernel/state/vatKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,23 @@ export function makeVatKeeper(
return { totalEntries, snapshottedEntries };
}

function makeSaveSnapshotItem(snapshotID) {
return {
d: /** @type {TDSaveSnapshot} */ ['save-snapshot'],
sc: [],
r: { status: 'ok', snapshotID },
};
}

function makeLoadSnapshotItem(snapshotID) {
const loadConfig = { snapshotID };
return {
d: /** @type {TDLoadSnapshot} */ ['load-snapshot', loadConfig],
sc: [],
r: { status: 'ok' },
};
}

/**
* Store a snapshot, if given a snapStore.
*
Expand All @@ -540,24 +557,15 @@ export function makeVatKeeper(
} = info;

// push a save-snapshot transcript entry
addToTranscript({
d: /** @type {TDSaveSnapshot} */ ['save-snapshot'],
sc: [],
r: { status: 'ok', snapshotID },
});
addToTranscript(makeSaveSnapshotItem(snapshotID));

// then start a new transcript span
transcriptStore.rolloverSpan(vatID);

// then push a load-snapshot entry, so that the current span
// always starts with an initialize-worker or load-snapshot
// pseudo-delivery
const loadConfig = { snapshotID };
addToTranscript({
d: /** @type {TDLoadSnapshot} */ ['load-snapshot', loadConfig],
sc: [],
r: { status: 'ok' },
});
addToTranscript(makeLoadSnapshotItem(snapshotID));

kernelSlog.write({
type: 'heap-snapshot-save',
Expand Down

0 comments on commit 0a33e8f

Please sign in to comment.