2023-02-03 15:57:09 +03:00
|
|
|
:: +stale-flows: prints number of ames flows that can be closed
|
|
|
|
::
|
|
|
|
:: |stale-flows, =veb %1 :: flows from nacking initial subscriptions
|
|
|
|
:: |stale-flows, =veb %2 :: stale flows that keep (re)trying to connect
|
|
|
|
:: |stale-flows, =veb %21 :: ... per app (only forward)
|
|
|
|
:: |stale-flows, =veb %3 :: stale resubscriptions
|
2023-06-08 15:04:13 +03:00
|
|
|
:: |stale-flows, =veb %4 :: print live naxplanation flows
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
|
|
|
=> |%
|
2023-06-08 15:04:13 +03:00
|
|
|
+$ subs (jar path [ship bone @ close=?])
|
2023-02-03 15:57:09 +03:00
|
|
|
+$ pags (jar app=term [dst=term =ship =path]) :: per-agent
|
|
|
|
+$ naks (set [ship bone])
|
2023-02-08 18:20:41 +03:00
|
|
|
:: verbosity
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
2023-06-08 15:04:13 +03:00
|
|
|
+$ veb ?(%0 %1 %2 %21 %3 %4 ~)
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
|
|
|
++ resubs
|
|
|
|
|= [=subs =veb]
|
|
|
|
^- @
|
2023-06-08 15:04:13 +03:00
|
|
|
%+ roll ~(tap by subs)
|
|
|
|
|= [[k=path v=(list [ship bone @ close=?])] num=@]
|
|
|
|
=/ in-close=@
|
|
|
|
(roll v |=([[@ @ @ c=?] n=@] ?:(c +(n) n)))
|
2023-02-03 15:57:09 +03:00
|
|
|
~? &(=(%3 veb) (gth (lent v) 1))
|
2023-06-08 15:04:13 +03:00
|
|
|
%+ weld ?: =(in-close 0) ""
|
|
|
|
"[#{<in-close>} %close] "
|
2023-02-03 15:57:09 +03:00
|
|
|
"#{<(dec (lent v))>} stale resubs on {<k>}"
|
|
|
|
?. (gth (lent v) 1) num
|
2023-02-10 16:37:05 +03:00
|
|
|
(add (dec (lent v)) num)
|
2023-02-03 15:57:09 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
:- %say
|
|
|
|
|= $: [now=@da eny=@uvJ bec=beak]
|
2023-06-08 15:04:13 +03:00
|
|
|
[arg=~ peer=(unit @p) dry=? =veb]
|
2023-02-03 15:57:09 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
=/ peers-map
|
|
|
|
.^((map ship ?(%alien %known)) %ax /(scot %p p.bec)//(scot %da now)/peers)
|
|
|
|
::
|
|
|
|
=/ peers=(list ship)
|
|
|
|
%+ murn ~(tap by peers-map)
|
|
|
|
|= [=ship val=?(%alien %known)]
|
|
|
|
?: =(ship p.bec)
|
|
|
|
~ :: this is weird, but we saw it
|
|
|
|
?- val
|
|
|
|
%alien ~
|
|
|
|
%known (some ship)
|
|
|
|
==
|
|
|
|
::
|
2023-06-08 15:04:13 +03:00
|
|
|
=; [[=subs =pags close=@ incoming=@ outgoing=@ nax=@] =naks]
|
2023-02-08 18:20:41 +03:00
|
|
|
:- %tang %- flop
|
|
|
|
%+ weld
|
|
|
|
:~ leaf+"#{<~(wyt in naks)>} flows from %nacking %watches"
|
2023-06-08 15:04:13 +03:00
|
|
|
leaf+"#{<incoming>} live backward flows"
|
|
|
|
leaf+"#{<outgoing>} live forward flows"
|
|
|
|
leaf+"#{<nax>} live naxplanations"
|
|
|
|
leaf+"#{<close>} flows in closing"
|
2023-02-08 18:20:41 +03:00
|
|
|
leaf+"#{<(resubs subs veb)>} stale resubscriptions"
|
|
|
|
==
|
|
|
|
?. =(%21 veb) ~
|
|
|
|
:- leaf+"----------------------------------"
|
|
|
|
%+ turn %+ sort ~(tap by pags)
|
|
|
|
|= [[* v=(list)] [* w=(list)]]
|
|
|
|
(gth (lent v) (lent w))
|
|
|
|
|= [app=term v=(list [dst=term =ship =path])]
|
|
|
|
:- %leaf
|
2023-06-08 15:04:13 +03:00
|
|
|
%+ weld "#{<(lent v)>} flows for {<app>}"
|
2023-02-08 18:20:41 +03:00
|
|
|
?. =(1 (lent v)) ~
|
|
|
|
?> ?=(^ v)
|
|
|
|
" on {<ship.i.v>} to {<dst.i.v>} at {<path.i.v>}"
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
|
|
|
%+ roll peers
|
2023-06-08 15:04:13 +03:00
|
|
|
|= [=ship [=subs p=pags cl=@ in=@ ou=@ na=@] =naks]
|
|
|
|
?: ?& ?=(^ peer)
|
|
|
|
!=(u.peer ship)
|
|
|
|
==
|
|
|
|
+<+
|
2023-02-03 15:57:09 +03:00
|
|
|
=+ .^ =ship-state:ames
|
|
|
|
%ax /(scot %p p.bec)//(scot %da now)/peers/(scot %p ship)
|
|
|
|
==
|
|
|
|
=/ =peer-state:ames ?>(?=(%known -.ship-state) +.ship-state)
|
|
|
|
::
|
|
|
|
|^ [stale nacks]
|
|
|
|
::
|
|
|
|
++ stale
|
|
|
|
%+ roll ~(tap by snd.peer-state)
|
2023-02-10 18:13:28 +03:00
|
|
|
|= $: [=bone message-pump-state:ames]
|
|
|
|
subs=_subs pags=_p
|
2023-06-08 15:04:13 +03:00
|
|
|
close=_cl
|
|
|
|
incoming=_in outgoing=_ou nax=_na
|
2023-02-10 18:13:28 +03:00
|
|
|
==
|
2023-02-03 15:57:09 +03:00
|
|
|
=, packet-pump-state
|
2023-06-08 15:04:13 +03:00
|
|
|
=+ closing=(~(has ^in closing.peer-state) bone)
|
2023-02-03 15:57:09 +03:00
|
|
|
:- ?~ duct=(~(get by by-bone.ossuary.peer-state) bone) subs
|
2023-06-08 15:04:13 +03:00
|
|
|
?. ?=([* [%gall %use sub=@ @ %out @ @ *] *] u.duct)
|
2023-02-03 15:57:09 +03:00
|
|
|
subs
|
2023-06-08 15:04:13 +03:00
|
|
|
=/ =wire i.t.u.duct
|
|
|
|
=/ nonce=(unit @ud)
|
|
|
|
?~ (slag 7 wire) ~
|
|
|
|
(slaw %ud &8.wire)
|
2023-02-03 15:57:09 +03:00
|
|
|
%- ~(add ja subs)
|
2023-06-08 15:04:13 +03:00
|
|
|
:_ [ship bone ?~(nonce 0 u.nonce) closing] :: 0 = pre-nonce subscriptions
|
|
|
|
?~ nonce
|
|
|
|
wire
|
2023-02-03 15:57:09 +03:00
|
|
|
:: don't include the sub-nonce in the key
|
|
|
|
::
|
|
|
|
(weld (scag 7 wire) (slag 8 wire))
|
2023-06-08 15:04:13 +03:00
|
|
|
?~ live [pags close incoming outgoing nax]
|
2023-02-03 15:57:09 +03:00
|
|
|
:: only forward flows
|
|
|
|
::
|
2023-06-08 15:04:13 +03:00
|
|
|
=? pags =(%0 (mod bone 4))
|
2023-02-03 15:57:09 +03:00
|
|
|
?~ duct=(~(get by by-bone.ossuary.peer-state) bone)
|
|
|
|
pags
|
2023-06-08 15:04:13 +03:00
|
|
|
?. ?=([* [%gall %use sub=@ @ %out @ @ *] *] u.duct)
|
2023-02-03 15:57:09 +03:00
|
|
|
pags
|
|
|
|
=/ =wire i.t.u.duct
|
2023-06-08 15:04:13 +03:00
|
|
|
(~(add ja pags) (snag 2 wire) (snag 6 wire) ship (slag 7 wire))
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
2023-06-08 15:04:13 +03:00
|
|
|
=? close closing +(close)
|
|
|
|
~? =(%2 veb)
|
|
|
|
=/ arrow=tape
|
|
|
|
?+ (mod bone 4) ~|([%odd-bone bone] !!)
|
|
|
|
%0 "<-"
|
|
|
|
%1 "->"
|
|
|
|
%3 "<-"
|
|
|
|
==
|
|
|
|
"{arrow} ({(cite:title ship)}) bone=#{<bone>} closing={<closing>}"
|
|
|
|
::
|
|
|
|
=/ is-nax=? =(%3 (mod bone 4))
|
|
|
|
~? &(=(%4 veb) is-nax)
|
|
|
|
"nax: ({(cite:title ship)}) bone=#{<bone>} closing={<closing>}"
|
|
|
|
:+ pags close
|
|
|
|
?+ (mod bone 4) ~|([%odd-bone bone] !!)
|
|
|
|
%0 [incoming +(outgoing) nax]
|
|
|
|
%1 [+(incoming) outgoing nax]
|
|
|
|
%3 [incoming outgoing +(nax)]
|
|
|
|
==
|
2023-02-03 15:57:09 +03:00
|
|
|
::
|
|
|
|
++ nacks
|
|
|
|
%+ roll ~(tap by rcv.peer-state)
|
2023-06-08 15:04:13 +03:00
|
|
|
|= [[=bone *] n=_naks]
|
2023-02-03 15:57:09 +03:00
|
|
|
?. &(=(0 (end 0 bone)) =(1 (end 0 (rsh 0 bone))))
|
|
|
|
:: not a naxplanation ack bone
|
|
|
|
::
|
2023-06-08 15:04:13 +03:00
|
|
|
n
|
2023-02-03 15:57:09 +03:00
|
|
|
:: by only corking forward flows that have received
|
|
|
|
:: a nack we avoid corking the current subscription
|
|
|
|
::
|
|
|
|
=+ target=(mix 0b10 bone)
|
|
|
|
:: make sure that the nack bone has a forward flow
|
|
|
|
::
|
|
|
|
?~ duct=(~(get by by-bone.ossuary.peer-state) target)
|
2023-06-08 15:04:13 +03:00
|
|
|
n
|
2023-02-03 15:57:09 +03:00
|
|
|
?. ?=([* [%gall %use sub=@ @ %out @ @ nonce=@ pub=@ *] *] u.duct)
|
2023-06-08 15:04:13 +03:00
|
|
|
n
|
2023-02-03 15:57:09 +03:00
|
|
|
=/ =wire i.t.u.duct
|
2023-06-08 15:04:13 +03:00
|
|
|
=+ closing=(~(has ^in closing.peer-state) bone)
|
2023-02-03 15:57:09 +03:00
|
|
|
?> ?=([%gall %use sub=@ @ %out @ @ nonce=@ pub=@ *] wire)
|
|
|
|
=/ app=term i.t.t.wire
|
|
|
|
=/ nonce=@
|
|
|
|
=- ?~(- 0 u.-)
|
2023-06-08 15:04:13 +03:00
|
|
|
(slaw %ud &8.wire)
|
|
|
|
=/ =path |8.wire
|
|
|
|
~? =(%1 veb)
|
|
|
|
"[bone={<target>} nonce={<nonce>} agent={<app>} close={<closing>}] {<path>}"
|
|
|
|
(~(put ^in n) [ship target])
|
2023-02-03 15:57:09 +03:00
|
|
|
--
|