Skip to content

Commit

Permalink
Merge pull request #236 from tloncorp/ns/outstanding-pokes-timer
Browse files Browse the repository at this point in the history
Expire outstanding pokes after 1hr
  • Loading branch information
midsum-salrux authored Oct 24, 2023
2 parents c0d040f + f350471 commit c7bd3f5
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions desk/app/reel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$% state-0
state-1
state-2
state-3
==
::
:: vic: URL of bait service
Expand All @@ -32,11 +33,18 @@
our-metadata=(map cord metadata:reel)
outstanding-pokes=(set (pair ship cord))
==
+$ state-3
$: %3
vic=@t
civ=ship
our-metadata=(map cord metadata:reel)
outstanding-pokes=(set (pair ship cord))
==
++ url-for-token
|= [vic=cord our=ship token=cord]
(crip "{(trip vic)}{(trip (scot %p our))}/{(trip token)}")
--
=| state-2
=| state-3
=* state -
::
%- agent:dbug
Expand All @@ -55,12 +63,14 @@
^- (quip card _this)
=/ old !<(versioned-state old-state)
?- -.old
%2
%3
`this(state old)
%2
`this(state [%3 vic.old civ.old our-metadata.old ~])
%1
`this(state [%2 'https://tlon.network/lure/' ~loshut-lonreg ~ ~])
`this(state [%3 'https://tlon.network/lure/' ~loshut-lonreg ~ ~])
%0
`this(state [%2 'https://tlon.network/lure/' ~loshut-lonreg ~ ~])
`this(state [%3 'https://tlon.network/lure/' ~loshut-lonreg ~ ~])
==
::
++ on-poke
Expand Down Expand Up @@ -130,7 +140,9 @@
=/ group i.t.t.path
?~ (~(has in outstanding-pokes) [target group]) `this
:_ this(outstanding-pokes (~(put in outstanding-pokes) [target group]))
~[[%pass path %agent [target %reel] %poke %reel-want-token-link !>(group)]]
:~ [%pass path %agent [target %reel] %poke %reel-want-token-link !>(group)]
[%pass /expire/(scot %p our.bowl)/[group] %arvo %b [%wait (add ~h1 now.bowl)]]
==
==
::
++ on-leave on-leave:def
Expand All @@ -150,12 +162,24 @@
==
::
++ on-arvo
|= [=wire sign=sign-arvo]
|= [=wire =sign-arvo]
^- (quip card:agent:gall _this)
?> ?=([%set-ship ~] wire)
?> ?=([%khan %arow *] sign)
?: ?=(%.n -.p.sign)
((slog 'reel: fetch bait ship failed' p.p.sign) `this)
`this
?+ wire (on-arvo:def wire sign-arvo)
[%set-ship ~]
?> ?=([%khan %arow *] sign-arvo)
?: ?=(%.n -.p.sign-arvo)
((slog 'reel: fetch bait ship failed' p.p.sign-arvo) `this)
`this
::
[%expire @ @ ~]
?+ sign-arvo (on-arvo:def wire sign-arvo)
[%behn %wake *]
=/ target (slav %p i.t.wire)
=/ group i.t.t.wire
?~ error.sign-arvo
`this(outstanding-pokes (~(del in outstanding-pokes) [target group]))
(on-arvo:def wire sign-arvo)
==
==
++ on-fail on-fail:def
--

0 comments on commit c7bd3f5

Please sign in to comment.