ames: refactor +on-krock
~% %event-gate ..per-event ~
|= [[now=@da eny=@ rof=roof] =duct =ames-state]
=* veb veb.bug.ames-state
+ =| cork-bone=(unit bone) :: modified by +on-kroc
~% %event-core ..$ ~
|%
++ event-core .
=/ =peer-state +.u.ship-state
=/ =channel [[our ship] now channel-state -.peer-state]
::
- =^ =bone ossuary.peer-state (bind-duct ossuary.peer-state duct)
+ =/ [=bone ossuary=_ossuary.peer-state]
+ ?^ cork-bone [u.cork-bone ossuary.peer-state]
+ (bind-duct ossuary.peer-state duct)
+ =. ossuary.peer-state ossuary
+ ::
+ ?. (~(has by by-bone.ossuary.peer-state) bone)
+ %. event-core
+ %^ trace odd.veb ship
+ |.("trying to cork {<bone=bone>}, not in the ossuary, ignoring")
::
=. closing.peer-state (~(put in closing.peer-state) bone)
%- %^ trace msg.veb ship
++ on-kroc
|= [=ship =bone]
^+ event-core
- =/ =plea [%$ /flow [%cork ~]]
- =/ ship-state (~(get by peers.ames-state) ship)
- ?. ?=([~ %known *] ship-state)
- %+ enqueue-alien-todo ship
- |= todos=alien-agenda
- todos(messages [[duct plea] messages.todos])
- =/ =peer-state +.u.ship-state
- ?. (~(has by by-bone.ossuary.peer-state) bone)
- ~& >>> %dont-have-it^ship^bone
- event-core
- =/ =channel [[our ship] now channel-state -.peer-state]
- ::
- =. closing.peer-state (~(put in closing.peer-state) bone)
- %- %^ trace msg.veb ship
- |. ^- tape
- =/ sndr [our our-life.channel]
- =/ rcvr [ship her-life.channel]
- "cork plea {<sndr^rcvr^bone=bone^vane.plea^path.plea>}"
- abet:(on-memo:(make-peer-core peer-state channel) bone plea %plea)
+ (%*(on-cork . cork-bone `bone) ship)
:: +on-take-wake: receive wakeup or error notification from behn
::
++ on-take-wake
