diff --git a/desk/app/contacts.hoon b/desk/app/contacts.hoon index 3508c99a..0196b32a 100644 --- a/desk/app/contacts.hoon +++ b/desk/app/contacts.hoon @@ -9,14 +9,13 @@ :: :: .con: a contact :: .rof: our profile -:: .rol: our full rolodex +:: .rol: our full rolodex (v0) :: .far: foreign peer :: .for: foreign profile :: .sag: foreign subscription state :: +| %types +$ card card:agent:gall -+$ state-0 [%0 rof=$@(~ profile-0) rol=rolodex-0] +$ state-1 [%1 rof=$@(~ profile-1) =book =peers] -- %- %^ agent:neg @@ -121,21 +120,21 @@ :: send facts on an empty path. This is no problem, unless :: it is used in ++peer :: - ++ subs-0 - ^- (set path) - %- ~(rep by sup.bowl) - |= [[duct ship pat=path] acc=(set path)] - ?.(?=([%contact *] pat) acc (~(put in acc) pat)) + :: ++ subs-0 + :: ^- (set path) + :: %- ~(rep by sup.bowl) + :: |= [[duct ship pat=path] acc=(set path)] + :: ?.(?=([%contact *] pat) acc (~(put in acc) pat)) ++ subs ^- (set path) %- ~(rep by sup.bowl) |= [[duct ship pat=path] acc=(set path)] ?.(?=([%v1 %contact *] pat) acc (~(put in acc) pat)) :: - ++ fact-0 - |= [pat=(set path) u=update-0] - ^- gift:agent:gall - [%fact ~(tap in pat) %contact-update !>(u)] + :: ++ fact-0 + :: |= [pat=(set path) u=update-0] + :: ^- gift:agent:gall + :: [%fact ~(tap in pat) %contact-update !>(u)] :: ++ fact |= [pat=(set path) u=update-1] @@ -206,8 +205,6 @@ =/ p=profile-1 [?~(rof now.bowl (mono wen.rof now.bowl)) con] =. rof p :: - =. cor - (give (fact-0 subs-0 [%full (to-profile-0 p)])) =. cor (give (fact subs [%full p])) =. cor @@ -253,15 +250,6 @@ (~(put by book) who con mod) (p-news [%page who con mod]) :: - ++ p-init-0 - |= wen=(unit @da) - ?~ rof cor - ?~ wen (give (fact ~ full+rof)) - ?: =(u.wen wen.rof) cor - :: - :: no future subs - ?>((lth u.wen wen.rof) (give (fact-0 ~ full+(to-profile-0 rof)))) - :: ++ p-init |= wen=(unit @da) ?~ rof cor @@ -295,6 +283,9 @@ ++ sub |^ |= who=ship ^+ s-impl + :: XX it seems lib negotiate does not set a correct + :: src.bowl! + :: ?< =(our.bowl who) =/ old (~(get by peers) who) ~(. s-impl who %live ?=(~ old) (fall old *foreign-1)) @@ -451,12 +442,24 @@ ?- -.old %0 =. rof ?~(rof.old ~ (to-profile-1 rof.old)) - =^ cards peers + =^ caz=(list card) peers %+ roll ~(tap by rol.old) |= [[who=ship foreign-0] caz=(list card) =_peers] =/ for-1=$@(~ profile-1) ?~ for ~ (to-profile-1 for) + :: no intent to subscribe + :: + ?: =(~ sag) + :- caz + (~(put by peers) who for-1 ~) + :_ (~(put by peers) who for-1 %want) + ?: (~(has by wex.bowl) [/contact who dap.bowl]) + caz + =/ =path [%v1 %contact ?~(for / /at/(scot %da wen.for))] + :_ caz + [%pass /contact %agent [who dap.bowl] %watch path] + (emil caz) :: in v0, any sag that is not null indicates intent to connect, :: that could fail due to version mismatch or other reasons. :: therefore, a v0 sag not equal to null means we should @@ -468,20 +471,22 @@ :: :: no intent to connect :: - ?: =(~ sag) - :_ (~(put by peers) who for-1 ~) - ?. (~(has by wex.bowl) [/contact who dap.bowl]) - caz + :: ?: =(~ sag) + :: :- caz + :: (~(put by peers) who for-1 ~) :: leave existing v0 connection + :: XX it seems lib-negotiate handles this + :: :_ caz + :: [%pass /contact %agent [who dap.bowl] %leave ~] :: - :_ caz - [%pass /contact %agent [who dap.bowl] %leave ~] - :- :_ caz - =/ =path [%v1 %contact ?~(for / /at/(scot %da wen.for))] - [%pass /contact %agent [who dap.bowl] %watch path] - (~(put by peers) who for-1 %want) + :: XX it seems lib-negotiate will initiate this by + :: simulating a %kick + :: :- :_ caz + :: =/ =path [%v1 %contact ?~(for / /at/(scot %da wen.for))] + :: [%pass /contact %agent [who dap.bowl] %watch path] + :: (~(put by peers) who for-1 %want) :: - (emil cards) + :: (emil cards) :: %1 =. state old @@ -499,7 +504,7 @@ caz (emil cards) == - :: + +$ state-0 [%0 rof=$@(~ profile-0) rol=rolodex-0] +$ versioned-state $% state-0 state-1 @@ -537,7 +542,7 @@ =/ act ?- mark %contact-action-1 - !<(action vase) + !<(action-1 vase) ?(act:base:mar %contact-action-0) (to-action-1 !<(action-0 vase)) == @@ -631,7 +636,7 @@ ``contact-page-1+!>(`^page`u.page) :: [%x %v1 %all ~] - =| all=(map ship contact-1) + =| all=directory :: export all ship contacts :: =. all @@ -674,10 +679,10 @@ |= pat=(pole knot) ^+ cor ?+ pat ~|(bad-watch-path+pat !!) + :: :: v0 - [%contact ~] (p-init-0:pub ~) - [%contact %at wen=@ ~] (p-init-0:pub `(slav %da wen.pat)) [%news ~] ~|(local-news+src.bowl ?>(=(our src):bowl cor)) + :: :: v1 [%v1 %contact ~] (p-init:pub ~) [%v1 %contact %at wen=@ ~] (p-init:pub `(slav %da wen.pat)) @@ -690,7 +695,8 @@ |= [=wire =sign:agent:gall] ^+ cor ?+ wire ~|(evil-agent+wire !!) - [%contact ~] si-abet:(si-take:(sub src.bowl) sign) + [%contact ~] + si-abet:(si-take:(sub src.bowl) sign) [%migrate ~] ?> ?=(%poke-ack -.sign) ?~ p.sign cor diff --git a/desk/lib/negotiate.hoon b/desk/lib/negotiate.hoon index 87b00493..9c90d496 100644 --- a/desk/lib/negotiate.hoon +++ b/desk/lib/negotiate.hoon @@ -514,7 +514,15 @@ =* sub i.suz =. cards (snoc cards [%pass wire.sub %agent gill.sub %leave ~]) =. wex.bowl (~(del by wex.bowl) -.sub) - =^ caz inner (on-agent:og wire.sub %kick ~) + :: XX this seems wrong: src is not set + :: =^ caz inner (on-agent:og wire.sub %kick ~) + :: =^ caz inner + :: =. src.bowl.inner-bowl p.gill.i.suz + :: (on-agent:og wire.sub %kick ~) + =^ caz inner + %. [wire.sub %kick ~] + =. src.bowl p.gill.i.suz + ~(on-agent inner inner-bowl:up) =^ caz state (play-cards:up caz) $(cards (weld cards caz), suz t.suz) :: diff --git a/desk/mar/contact/action-0.hoon b/desk/mar/contact/action-0.hoon index bdff052a..9c9ac701 100644 --- a/desk/mar/contact/action-0.hoon +++ b/desk/mar/contact/action-0.hoon @@ -9,7 +9,7 @@ -- ++ grab |% - ++ noun action:c + ++ noun action-0:c ++ json action:dejs:j -- -- diff --git a/desk/sur/contacts.hoon b/desk/sur/contacts.hoon index f8076a0d..b177218d 100644 --- a/desk/sur/contacts.hoon +++ b/desk/sur/contacts.hoon @@ -40,11 +40,10 @@ groups=(set flag:g) == :: -+$ foreign-0 [for=$@(~ profile-0) sag=$@(~ saga)] ++$ foreign-0 [for=$@(~ profile-0) sag=$@(~ saga-0)] +$ profile-0 [wen=@da con=$@(~ contact-0)] +$ rolodex-0 (map ship foreign-0) :: -:: +$ value-type-1 $? %text %date @@ -90,7 +89,6 @@ :: :: uniform set [%set $|(p=(set value-1) unis)] - :: [%set p=(set value-1)] == :: $contact-1: contact data :: @@ -130,6 +128,14 @@ +$ peers (map ship foreign-1) :: +$ epic epic:e ++$ saga-0 + $@ $? %want :: subscribing + %fail :: %want failed + %lost :: epic %fail + ~ :: none intended + == + saga:e +:: +$ saga $? %want :: subscribing ~ :: none intended @@ -211,14 +217,4 @@ [%wipe =kip] [%peer who=ship con=contact-1] == -+| %version -:: ++ foreign foreign-0 -:: ++ rolodex rolodex-0 -:: ++ contact contact-0 -:: ++ action action- -++ action action-1 -:: ++ profile profile-0 -:: ++ news news-0 -:: ++ update update-0 -:: ++ field field-0 --