ames: factor out is-corked logic into a gate

This commit is contained in:
yosoyubik 2023-04-14 09:12:16 +02:00
parent 898ed99863
commit 69a5c5e6df

View File

@ -2332,6 +2332,13 @@
:: ::
++ pump-core |=(=bone (mu bone *message-pump-state)) ++ pump-core |=(=bone (mu bone *message-pump-state))
++ sink-core |=(=bone (mi bone *message-sink-state)) ++ sink-core |=(=bone (mi bone *message-sink-state))
++ is-corked
|= =bone
?| (~(has in corked.peer-state) bone)
?& =(1 (end 0 bone))
=(1 (end 0 (rsh 0 bone)))
(~(has in corked.peer-state) (mix 0b10 bone))
== ==
:: ::
+| %tasks +| %tasks
:: ::
@ -2381,12 +2388,7 @@
abet:(call:abed:(sink-core bone) %hear lane shut-packet ?=(~ dud)) abet:(call:abed:(sink-core bone) %hear lane shut-packet ?=(~ dud))
:: benign ack on corked bone (also for naxplanation acks) :: benign ack on corked bone (also for naxplanation acks)
:: ::
?: ?| (~(has in corked.peer-state) bone) ?: (is-corked bone) peer-core
?& =(1 (end 0 bone))
=(1 (end 0 (rsh 0 bone)))
(~(has in corked.peer-state) (mix 0b10 bone))
== ==
peer-core
:: Just try again on error, printing trace :: Just try again on error, printing trace
:: ::
:: Note this implies that vanes should never crash on %done, :: Note this implies that vanes should never crash on %done,
@ -2487,11 +2489,7 @@
=(1 current:(~(got by snd.peer-state) bone)) =(1 current:(~(got by snd.peer-state) bone))
== ==
(send-blob | her (attestation-packet [her her-life]:channel)) (send-blob | her (attestation-packet [her her-life]:channel))
?: ?| (~(has in corked.peer-state) bone) ?: (is-corked bone)
?& =(1 (end 0 bone))
=(1 (end 0 (rsh 0 bone)))
(~(has in corked.peer-state) (mix 0b10 bone))
== ==
:: no-op if the bone (or, if a naxplanation, the reference bone) :: no-op if the bone (or, if a naxplanation, the reference bone)
:: was corked, because the flow doesn't exist anymore :: was corked, because the flow doesn't exist anymore
:: TODO: clean up corked bones? :: TODO: clean up corked bones?