Skip to content

Commit 5c6953c

Browse files
committed
refactor(ocap-kernel): remove dead kslot branches, widen initKernelObject to accept 'kernel' owner
1 parent 63b2ec3 commit 5c6953c

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/ocap-kernel/src/KernelServiceManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { Logger } from '@metamask/logger';
44
import type { KernelQueue } from './KernelQueue.ts';
55
import { kser, kunser } from './liveslots/kernel-marshal.ts';
66
import type { KernelStore } from './store/index.ts';
7-
import type { KRef, EndpointId, KernelMessage } from './types.ts';
7+
import type { KRef, KernelMessage } from './types.ts';
88
import { assert } from './utils/assert.ts';
99

1010
export type KernelService = {
@@ -77,7 +77,7 @@ export class KernelServiceManager {
7777
}
7878
let kref = this.#kernelStore.getKernelServiceKref(name);
7979
if (!kref) {
80-
kref = this.#kernelStore.initKernelObject('kernel' as EndpointId);
80+
kref = this.#kernelStore.initKernelObject('kernel');
8181
this.#kernelStore.setKernelServiceKref(name, kref);
8282
this.#kernelStore.pinObject(kref);
8383
}

packages/ocap-kernel/src/liveslots/kernel-marshal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function kslot(kref: KRef, iface: string = 'undefined'): SlotValue {
7272
// eslint-disable-next-line no-param-reassign
7373
iface = iface.slice(9);
7474
}
75-
if (kref.startsWith('p') || kref.startsWith('kp') || kref.startsWith('rp')) {
75+
if (kref.startsWith('kp')) {
7676
return makeStandinPromise(kref);
7777
}
7878
const standinObject = makeDefaultExo(iface, {

packages/ocap-kernel/src/store/methods/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export function getObjectMethods(ctx: StoreContext) {
2525
* corresponds to an object that has just been imported from somewhere. The
2626
* object is initially unrevoked.
2727
*
28-
* @param owner - The endpoint that is the owner of the new object.
28+
* @param owner - The endpoint or 'kernel' that is the owner of the new object.
2929
* @returns The new object's KRef.
3030
*/
31-
function initKernelObject(owner: EndpointId): KRef {
31+
function initKernelObject(owner: EndpointId | 'kernel'): KRef {
3232
const koId = getNextObjectId();
3333
ctx.kv.set(getOwnerKey(koId), owner);
3434
setObjectRefCount(koId, { reachable: 1, recognizable: 1 });

0 commit comments

Comments
 (0)