Store the whole assertion when crossSpace

This commit is contained in:
Tony Garnock-Jones 2023-06-16 21:31:51 +02:00
parent da29412e91
commit 28dee5f098
2 changed files with 8 additions and 13 deletions

View File

@ -5,12 +5,10 @@ ActionDescription =
/ @spawnActor <spawn-actor @detail OptionalAny @initialAssertions #{protocol.Handle}>
/ @stopActor <stop-actor @error OptionalAny>
/ @inertCheck <inert-check>
/ <assert @target #!any @crossSpacePins CrossSpacePins @handle protocol.Handle @assertion any>
/ <assert @target #!any @crossSpace bool @handle protocol.Handle @assertion any>
/ <retract @target #!any @crossSpace bool @handle protocol.Handle>
/ <message @target #!any @assertion any>
/ <sync @target #!any @callback #!any>
.
CrossSpacePins = @none #f / @some [#!any ...] .
OptionalAny = <none> / <some @value any> .

View File

@ -84,7 +84,7 @@ export function assertionFrom(a: Assertable): Assertion {
}
}
type OutboundAssertion = { handle: Handle, peer: Ref, crossSpacePins: Ref[] | null, established: boolean };
type OutboundAssertion = { handle: Handle, peer: Ref, crossSpace: Assertion | null, established: boolean };
type OutboundMap = Map<Handle, OutboundAssertion>;
let nextActorId = 0;
@ -208,7 +208,7 @@ export class Facet {
const e = {
handle: h,
peer: { relay: other, target: new StopOnRetract() },
crossSpacePins: null,
crossSpace: null,
established: true,
};
this.outbound.set(h, e);
@ -455,8 +455,7 @@ export class Turn {
const a = runRewrites(ref.attenuation, assertion);
if (a !== null) {
const crossSpace = this.activeFacet.actor.space !== ref.relay.actor.space;
const pins = crossSpace ? this.activeFacet.actor.space.extractPins(a) : null;
const e = { handle: h, peer: ref, crossSpacePins: pins, established: false };
const e = { handle: h, peer: ref, crossSpace: crossSpace ? a : null, established: false };
this.activeFacet.outbound.set(h, e);
this.enqueue(ref.relay,
() => {
@ -468,11 +467,9 @@ export class Turn {
},
() => Q.ActionDescription.assert({
target: ref,
crossSpacePins: (pins === null
? Q.CrossSpacePins.none()
: Q.CrossSpacePins.some(pins)),
crossSpace,
handle: h,
assertion,
assertion: a,
}));
}
}
@ -499,13 +496,13 @@ export class Turn {
() => {
if (e.established) {
e.established = false;
if (e.crossSpacePins) e.peer.relay.actor.space.deregisterInbound(e.handle);
if (e.crossSpace) e.peer.relay.actor.space.deregisterInbound(e.handle);
e.peer.target.retract?.(e.handle);
}
},
() => Q.ActionDescription.retract({
target: e.peer,
crossSpace: e.crossSpacePins !== null,
crossSpace: e.crossSpace !== null,
handle: e.handle,
}));
}