From d868b100eb9a25821ff5a5cf0443559c3a98d0e5 Mon Sep 17 00:00:00 2001 From: Chris Hibbert Date: Fri, 10 Jan 2020 14:16:08 -0800 Subject: [PATCH] Add ability to request stats for a Vat. --- packages/SwingSet/src/kernel/kernel.js | 9 +++++++-- packages/SwingSet/src/kernel/state/kernelKeeper.js | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/SwingSet/src/kernel/kernel.js b/packages/SwingSet/src/kernel/kernel.js index aa3bb5d3f324..f180141067b2 100644 --- a/packages/SwingSet/src/kernel/kernel.js +++ b/packages/SwingSet/src/kernel/kernel.js @@ -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'); @@ -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 diff --git a/packages/SwingSet/src/kernel/state/kernelKeeper.js b/packages/SwingSet/src/kernel/state/kernelKeeper.js index 6bf9febd2d3d..d954ff956c59 100644 --- a/packages/SwingSet/src/kernel/state/kernelKeeper.js +++ b/packages/SwingSet/src/kernel/state/kernelKeeper.js @@ -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, @@ -533,6 +542,8 @@ export default function makeKernelKeeper(storage) { provideVatKeeper, getAllVatNames, + vatStats, + getDeviceIDForName, provideDeviceIDForName, provideDeviceKeeper,