From 4f0e599cb10209016cf88fae90a456393c3e38c2 Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:04 -0800 Subject: [PATCH] contacts: import/export --- pkg/arvo/app/contact-hook.hoon | 57 +++++++++++++++++++++++++++++++-- pkg/arvo/app/contact-store.hoon | 17 ++++++++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/pkg/arvo/app/contact-hook.hoon b/pkg/arvo/app/contact-hook.hoon index 0871201839..379b8fdc10 100644 --- a/pkg/arvo/app/contact-hook.hoon +++ b/pkg/arvo/app/contact-hook.hoon @@ -132,6 +132,10 @@ :: %contact-hook-action (poke-hook-action:cc !<(contact-hook-action vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -170,8 +174,27 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -260,6 +283,26 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ contact-path [%contacts path] + ?: =(our.bol ship) + [%pass contact-path %agent [our.bol %contact-store] %watch contact-path] + (try-rejoin ship contact-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %contact-hook] %watch pax] +:: ++ watch-contacts |= pax=path ^- (list card) @@ -282,6 +325,13 @@ ^- (quip card _state) ?~ saw [~ state] + ?: ?=([%try-rejoin @ *] wir) + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ + :: ?> ?=(^ wir) [~ state(synced (~(del by synced) t.wir))] :: @@ -295,6 +345,9 @@ |= wir=wire ^- (list card) ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%inv ~] [%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~ :: diff --git a/pkg/arvo/app/contact-store.hoon b/pkg/arvo/app/contact-store.hoon index 6089cae80c..8ed19228a0 100644 --- a/pkg/arvo/app/contact-store.hoon +++ b/pkg/arvo/app/contact-store.hoon @@ -121,8 +121,12 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - ::%json (poke-json:cc !<(json vase)) - %contact-action (poke-contact-action:cc !<(contact-action vase)) + ::%json (poke-json:cc !<(json vase)) + %contact-action + (poke-contact-action:cc !<(contact-action vase)) + :: + %import + (poke-import:cc q.vase) == [cards this] :: @@ -169,6 +173,9 @@ ?~ contacts ~ ``noun+!>((~(get by u.contacts) ship)) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -197,6 +204,12 @@ %edit (handle-edit +.action) == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-three ;;(state-three arc) + [~ sty] +:: ++ handle-create |= =path ^- (quip card _state)