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 27, 2023
1 parent 7cd9127 commit 0c2e6ec
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 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,31 @@ export function makeVatKeeper(
return { totalEntries, snapshottedEntries };
}

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

/**
* @param {string} snapshotID
* @returns {TranscriptEntry}
*/
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 +565,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 0c2e6ec

Please sign in to comment.