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}> / @spawnActor <spawn-actor @detail OptionalAny @initialAssertions #{protocol.Handle}>
/ @stopActor <stop-actor @error OptionalAny> / @stopActor <stop-actor @error OptionalAny>
/ @inertCheck <inert-check> / @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> / <retract @target #!any @crossSpace bool @handle protocol.Handle>
/ <message @target #!any @assertion any> / <message @target #!any @assertion any>
/ <sync @target #!any @callback #!any> / <sync @target #!any @callback #!any>
. .
CrossSpacePins = @none #f / @some [#!any ...] .
OptionalAny = <none> / <some @value 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>; type OutboundMap = Map<Handle, OutboundAssertion>;
let nextActorId = 0; let nextActorId = 0;
@ -208,7 +208,7 @@ export class Facet {
const e = { const e = {
handle: h, handle: h,
peer: { relay: other, target: new StopOnRetract() }, peer: { relay: other, target: new StopOnRetract() },
crossSpacePins: null, crossSpace: null,
established: true, established: true,
}; };
this.outbound.set(h, e); this.outbound.set(h, e);
@ -455,8 +455,7 @@ export class Turn {
const a = runRewrites(ref.attenuation, assertion); const a = runRewrites(ref.attenuation, assertion);
if (a !== null) { if (a !== null) {
const crossSpace = this.activeFacet.actor.space !== ref.relay.actor.space; 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, crossSpace: crossSpace ? a : null, established: false };
const e = { handle: h, peer: ref, crossSpacePins: pins, established: false };
this.activeFacet.outbound.set(h, e); this.activeFacet.outbound.set(h, e);
this.enqueue(ref.relay, this.enqueue(ref.relay,
() => { () => {
@ -468,11 +467,9 @@ export class Turn {
}, },
() => Q.ActionDescription.assert({ () => Q.ActionDescription.assert({
target: ref, target: ref,
crossSpacePins: (pins === null crossSpace,
? Q.CrossSpacePins.none()
: Q.CrossSpacePins.some(pins)),
handle: h, handle: h,
assertion, assertion: a,
})); }));
} }
} }
@ -499,13 +496,13 @@ export class Turn {
() => { () => {
if (e.established) { if (e.established) {
e.established = false; 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); e.peer.target.retract?.(e.handle);
} }
}, },
() => Q.ActionDescription.retract({ () => Q.ActionDescription.retract({
target: e.peer, target: e.peer,
crossSpace: e.crossSpacePins !== null, crossSpace: e.crossSpace !== null,
handle: e.handle, handle: e.handle,
})); }));
} }