Skip to content

Commit

Permalink
Merge pull request #249 from sidnym-ladrut/sl/vitals-connection-check…
Browse files Browse the repository at this point in the history
…-fixes

patch many minor issues with `vitals/connection-check.hoon` thread
  • Loading branch information
arthyn authored Feb 15, 2024
2 parents 4fe50ce + cc3384c commit 9044733
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
11 changes: 3 additions & 8 deletions desk/app/vitals.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
%landscape
%vitals-connection-check
%noun
!>(ship)
!>((some ship))
==
?: ?=(%pending -.status.u.stat)
cor
Expand All @@ -153,17 +153,14 @@
%landscape
%vitals-connection-check
%noun
!>(ship)
!>((some ship))
==
::
:: public pokes
::
%ship
=+ !<(=ship vase)
?< =(our ship)
?< =(~ (find ~[our] (saxo:title our now ship)))
?. ?=([%live *] (scry-qos:lib our now ship))
!!
?> ?=([%live *] (scry-qos:lib our now ship))
cor
==
++ watch
Expand All @@ -187,14 +184,12 @@
?+ path [~ ~]
::
[%x %sponsor ~]
?< ?=(%czar (clan:title our))
%- some
%- some
:- %vitals-qos
!> (scry-qos:lib our now (sein:title our now our))
::
[%x %galaxy ~]
?< ?=(%czar (clan:title our))
%- some
%- some
:- %vitals-qos
Expand Down
22 changes: 12 additions & 10 deletions desk/lib/vitals.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
++ scry-qos
|= [=ship =time peer=ship]
^- qos:ames
%- simplify-qos
.^ ship-state:ames
%ax
(scot %p ship)
%$
(scot %da time)
%peers
(scot %p peer)
~
==
:: a ship is not guaranteed by %ames to know itself, so we fake it
?: =(ship peer)
[%live time]
:: .^(* /ax/=//=/peers/[peer]) crashes if the peer is unknown, so we
:: check the source map beforehand and fake an %unborn if we can see
:: a crash coming
=/ ames-peers=path /ax/(scot %p ship)//(scot %da time)/peers
=/ peers .^((map ^ship ?(%alien %known)) ames-peers)
?. (~(has by peers) peer)
[%unborn time]
=/ pqos .^(ship-state:ames (snoc ames-peers (scot %p peer)))
(simplify-qos pqos)
--
19 changes: 13 additions & 6 deletions desk/ted/vitals/connection-check.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<(target=ship arg)
=+ !<([~ target=ship] arg)
;< our=@p bind:m get-our:io
|^
:: early exit; check if we have live path to target
;< now=@da bind:m get-time:io
;< tqos=qos:ames bind:m (get-qos target)
;< now=@da bind:m get-time:io
?: ?& ?=(%live -.tqos)
(gth last-contact.tqos (sub now info-timeout:vitals))
==
Expand Down Expand Up @@ -103,13 +103,20 @@
!>
^- update:vitals
[target now %pending pending]
:: thread version of +scry-qos in /=landscape=/lib/vitals/hoon
++ get-qos
|= =ship
|= peer=ship
=/ m (strand ,qos:ames)
^- form:m
;< state=ship-state:ames
bind:m
(scry:io ship-state:ames ~[%ax %$ %peers (scot %p ship)])
;< now=@da bind:m get-time:io
?: =(our peer)
(pure:m [%live now])
;< peers=(map ship ?(%alien %known)) bind:m
(scry:io (map ship ?(%alien %known)) ~[%ax %$ %peers])
?. (~(has by peers) peer)
(pure:m [%unborn now])
;< state=ship-state:ames bind:m
(scry:io ship-state:ames ~[%ax %$ %peers (scot %p peer)])
(pure:m (simplify-qos:lib-vitals state))
++ galaxy-down
|= galaxy=ship
Expand Down

0 comments on commit 9044733

Please sign in to comment.