mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-22 06:11:31 +03:00
dm-hook: add root if nonexistent
This commit is contained in:
parent
097bae6fb7
commit
d490855aaa
@ -54,6 +54,26 @@
|
||||
==
|
||||
==
|
||||
::
|
||||
++ add-node
|
||||
|= [=index:store =node:store]
|
||||
^- update:store
|
||||
:^ now.bowl %add-nodes [our.bowl %inbox]
|
||||
(~(gas by *(map index:store node:store)) [index node] ~)
|
||||
::
|
||||
++ add-missing-root
|
||||
|= =ship
|
||||
^- (list card)
|
||||
=/ =index:store
|
||||
[ship ~]
|
||||
?: (check-node-existence:gra [our.bowl %inbox] index) ~
|
||||
=| =node:store
|
||||
=: author.post.node our.bowl
|
||||
index.post.node index
|
||||
time-sent.post.node now.bowl
|
||||
==
|
||||
=/ =wire /dm/(scot %p ship)
|
||||
(~(poke-our pass wire) %graph-store (update:cg:gra (add-node index node)))^~
|
||||
::
|
||||
++ outgoing-add
|
||||
|= nodes=(map index:store node:store)
|
||||
^- (list card)
|
||||
@ -65,13 +85,12 @@
|
||||
=/ =ship i.index
|
||||
=/ =dock [ship %dm-hook]
|
||||
=/ =wire /dm/(scot %p ship)
|
||||
=; =cage
|
||||
=/ =cage
|
||||
(update:cg:gra (add-node index node))
|
||||
%+ welp (add-missing-root ship)
|
||||
:~ (~(poke pass wire) dock cage)
|
||||
(~(poke-our pass wire) %graph-store cage)
|
||||
==
|
||||
%+ update:cg:gra now.bowl
|
||||
:+ %add-nodes [our.bowl %inbox]
|
||||
(~(gas by *(map index:store node:store)) [index node] ~)
|
||||
::
|
||||
++ incoming-add
|
||||
|= nodes=(map index:store node:store)
|
||||
@ -79,10 +98,10 @@
|
||||
?> =(1 ~(wyt by nodes))
|
||||
=* ship src.bowl
|
||||
=/ =wire /dm/(scot %p ship)
|
||||
:_ ~
|
||||
%+ snoc (add-missing-root ship)
|
||||
%+ ~(poke-our pass wire) %graph-store
|
||||
%+ update:cg:gra now.bowl
|
||||
:+ %add-nodes [ship %inbox]
|
||||
:+ %add-nodes [our.bowl %inbox]
|
||||
%- ~(gas by *(map index:store node:store))
|
||||
%+ turn ~(tap by nodes)
|
||||
|= [=index:store =node:store]
|
||||
|
21
pkg/arvo/gen/dm-hook/dm.hoon
Normal file
21
pkg/arvo/gen/dm-hook/dm.hoon
Normal file
@ -0,0 +1,21 @@
|
||||
:: graph-store|add-post: add post to a graph
|
||||
::
|
||||
/- *graph-store
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ =beak]
|
||||
[[him=ship contents=(list content) ~] ~]
|
||||
==
|
||||
=* our p.beak
|
||||
=/ =post *post
|
||||
=: author.post our
|
||||
index.post ~[him now]
|
||||
time-sent.post now
|
||||
contents.post contents
|
||||
==
|
||||
::
|
||||
:- %graph-update-1
|
||||
^- update
|
||||
:- now
|
||||
:+ %add-nodes [our %inbox]
|
||||
%- ~(gas by *(map index node))
|
||||
~[[~[him now] [post [%empty ~]]]]
|
Loading…
Reference in New Issue
Block a user