gall: refactor sub-wire-with-nonce construction
Into +ap-nonce-wire.
^+ same
(^trace verb agent-name print)
::
+ ++ ap-nonce-wire
+ |= [=wire =dock]
+ ^+ wire
+ =/ nonce=@ (~(got by boar.yoke) wire dock)
+ ?: =(0 nonce) wire
+ [(scot %ud nonce) wire]
+ ::
++ ap-core .
:: +ap-abed: initialise state for an agent, with the supplied routes.
::
core(agent-duct agent-duct)
$(in t.in)
::
- =/ out=(list [[=wire =^ship =term] ? =path nonce=@])
- %+ turn ~(tap by boat.yoke)
- |= [key=[wire ^ship term] val=[? path]]
- :- key
- val(+ [+.val (~(got by boar.yoke) key)])
+ =/ out=(list [=wire =^ship =term])
+ ~(tap ^in ~(key by boat.yoke))
|- ^+ ap-core
?~ out
ap-core
=? ap-core =(ship ship.i.out)
=/ core
=. agent-duct system-duct.state
- =/ way
- [%out (scot %p ship) term.i.out (scot %ud nonce.i.out) wire.i.out]
+ =. wire.i.out (ap-nonce-wire i.out)
+ =/ way [%out (scot %p ship) term.i.out wire.i.out]
(ap-specific-take way %kick ~)
core(agent-duct agent-duct)
$(out t.out)
++ ap-kill-down
|= [sub-wire=wire =dock]
^+ ap-core
- :: ensure the nonce is in the kernel-facing wire
- ::
- =/ =wire
- =/ nonce=@ud (~(got by boar.yoke) sub-wire dock)
- ?: =(0 nonce) sub-wire
- [(scot %ud nonce) sub-wire]
- ::
=. ap-core
- (ap-pass wire %agent dock %leave ~)
+ :: we take care to include the nonce in the "kernel-facing" wire
+ ::
+ (ap-pass (ap-nonce-wire sub-wire dock) %agent dock %leave ~)
(ap-pass sub-wire %huck dock %b %huck `sign-arvo`[%gall %unto %kick ~])
:: +ap-mule: run virtualized with intercepted scry, preserving type
::
=/ nonce=@ (~(got by boar.yoke) sub-wire dock)
=. p.move.move
%+ weld sys-wire
- ?: =(nonce 0)
- :: skip adding nonce to pre-nonce subscription wires
- ::
- sub-wire
- [(scot %ud nonce) sub-wire]
+ (ap-nonce-wire sub-wire dock)
=: boat.yoke (~(del by boat.yoke) [sub-wire dock])
boar.yoke (~(del by boar.yoke) [sub-wire dock])
==
