Skip to content

Commit

Permalink
bug: The vat.terminated table is not always there. check first.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Mar 4, 2025
1 parent 314ad59 commit dddc01d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/synthetic-chain/src/lib/vat-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const makeSwingstoreTool = db => {
/** @param {string} key */
// @ts-expect-error sqlite typedefs
const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value;
const kvGetSafe = key => sql.get`select * from kvStore where key = ${key}`;
/** @param {string} key */
const kvGetJSON = key => JSON.parse(kvGet(key));

Expand All @@ -48,6 +49,10 @@ const makeSwingstoreTool = db => {
currentSpan: () =>
sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`,
terminated: () => {
const t = kvGetSafe('vat.terminated');
if (!t) {
return false;
}
const terminatedIDs = kvGetJSON('vat.terminated');
return terminatedIDs.some(terminatedID => vatID === terminatedID);
},
Expand Down

0 comments on commit dddc01d

Please sign in to comment.