aqua: fix %fine request/response handling

This commit is contained in:
yosoyubik 2023-05-04 14:25:29 +02:00
parent 31426b32f6
commit a2c227c3fc
3 changed files with 44 additions and 22 deletions

View File

@ -662,34 +662,55 @@
(pe ~bud) :: XX why ~bud? need an example
::
%read
?~ pier=(~(get by ships.piers) from.ae)
(pe from.ae)
?~ pier=(~(get by ships.piers) ship.from.ae)
(pe ship.from.ae)
=/ cash (~(get by namespace.u.pier) path.ae)
|-
?^ cash
?: (gth num.ae (lent u.cash))
(pe from.ae)
(pe ship.from.ae)
::TODO depends on /ted/aqua/ames behavior in a weird indirect way
=/ for=@p `@`(tail for.ae) ::NOTE moons & comets not supported
=; task=task-arvo
^$(ae [%event for /a/aqua/fine-response task], thus this)
:+ %hear `lane:ames`[%| `@`from.ae]
=/ for=@p `@`(tail lane.for.ae) ::NOTE moons & comets not supported
%- push-events:(pe for)
%- flop =< events
%+ roll u.cash
|= [=yowl:ames i=@ud events=(list unix-event)]
:- +(i)
:_ events
:- /a/aqua/fine-response/[(scot %ud i)]
^- task-arvo
:+ %hear `lane:ames`[%| `@`ship.from.ae]
^- blob:ames
=/ =shot:ames
::NOTE dec is important! so dumb!!
(sift-shot:ames `@`(snag (dec num.ae) u.cash))
::TODO runtime needs to update rcvr field also
::NOTE rcvr life is allowed to be wrong
(etch-shot:ames shot(sndr from.ae, rcvr for))
%- etch-shot:ames
:* [sndr=ship.from.ae rcvr=for]
req=| sam=|
sndr-tick=life.from.ae
rcvr-tick=life.for.ae
origin=~
content=`@ux`yowl
==
::
=/ pacs=(unit (list yowl:ames))
=/ =path [%fine %hunk (scot %ud num.ae) '512' path.ae]
%+ biff
(peek-once:(pe from.ae) %ax %$ [%fine %message path.ae])
(peek-once:(pe ship.from.ae) %ax %$ path)
(soft (list yowl:ames))
?~ pacs (pe from.ae)
?~ pacs (pe ship.from.ae)
=. u.pacs
:: add request to each response packet payload
::
=+ pat=(spat path.ae)
=+ wid=(met 3 pat)
%- flop =< blobs
%+ roll u.pacs
|= [=yowl:ames num=_1 blobs=(list @ux)]
:- +(num)
:_ blobs
(can 3 4^num 2^wid wid^`@`pat (met 3 yowl)^yowl ~)
=. namespace.u.pier
(~(put by namespace.u.pier) path.ae u.pacs)
=. ships.piers
(~(put by ships.piers) from.ae u.pier)
(~(put by ships.piers) ship.from.ae u.pier)
$(cash pacs, thus this)
::
%event

View File

@ -28,10 +28,11 @@
=/ hear-lane (ship-to-lane sndr)
=/ =shot (sift-shot pac)
?: &(!sam.shot req.shot) :: is fine request
=/ [=peep =meow] (sift-purr `@ux`content.shot)
~& fine-request+peep
=/ [%0 =peep] (sift-wail `@ux`content.shot)
%+ emit-aqua-events our
[%read [rcvr path.peep] [hear-lane num.peep]]~
:_ ~
:- %read
[[[rcvr rcvr-tick.shot] path.peep] [hear-lane sndr-tick.shot] num.peep]
%+ emit-aqua-events our
[%event rcvr /a/newt/0v1n.2m9vh %hear hear-lane pac]~
:: +lane-to-ship: decode a ship from an aqua lane

View File

@ -41,7 +41,7 @@
[%pause-events who=ship]
[%snap-ships lab=term hers=(list ship)]
[%restore-snap lab=term]
[%read [from=ship =path] [for=lane:ames num=@ud]]
[%read [from=[=ship life=@ubC] =path] for=[=lane:ames life=@ubC] num=@ud]
[%event who=ship ue=unix-event]
==
::