Skip to content

Commit

Permalink
Add ability to request stats for a Vat.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jan 13, 2020
1 parent 74edca7 commit d868b10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,11 @@ export default function buildKernel(kernelEndowments) {
return vatId;
}

function collectVatStats(vatID) {
insistVatID(vatID);
return kernelKeeper.vatStats(vatID);
}

async function start(bootstrapVatName, argvString) {
if (started) {
throw new Error('kernel.start already called');
Expand Down Expand Up @@ -674,8 +679,8 @@ export default function buildKernel(kernelEndowments) {
}

if (vatAdminVatSetup) {
// register createVatDynamically with the vatAdmin Device.
registerVatCreationFunction(createVatDynamically);
// register createVatDynamically and others with the vatAdmin Device.
registerVatCreationFunction(createVatDynamically, collectVatStats);
}

// And enqueue the bootstrap() call. If we're reloading from an
Expand Down
11 changes: 11 additions & 0 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,15 @@ export default function makeKernelKeeper(storage) {
});
}

function vatStats(vatID) {
return harden({
nextObjectId: storage.get(`${vatID}.o.nextID`),
nextPromiseId: storage.get(`${vatID}.p.nextID`),
nextDeviceId: storage.get(`${vatID}.d.nextID`),
nextTranscriptId: storage.get(`${vatID}.t.nextID`),
});
}

return harden({
getInitialized,
setInitialized,
Expand Down Expand Up @@ -533,6 +542,8 @@ export default function makeKernelKeeper(storage) {
provideVatKeeper,
getAllVatNames,

vatStats,

getDeviceIDForName,
provideDeviceIDForName,
provideDeviceKeeper,
Expand Down

0 comments on commit d868b10

Please sign in to comment.