2021-02-26 00:37:11 +03:00
|
|
|
/- spider
|
2021-03-02 22:10:40 +03:00
|
|
|
/+ strandio, store=graph-store, graph, graph-view, sig=signatures
|
2021-02-26 00:37:11 +03:00
|
|
|
=, strand=strand:spider
|
|
|
|
^- thread:spider
|
|
|
|
|= arg=vase
|
|
|
|
=/ m (strand:spider ,vase)
|
|
|
|
^- form:m
|
|
|
|
=+ !<([~ =update:store] arg)
|
|
|
|
?> ?=(%add-nodes -.q.update)
|
|
|
|
=* poke-our poke-our:strandio
|
2021-03-02 22:10:40 +03:00
|
|
|
;< =bowl:spider bind:m get-bowl:strandio
|
2021-02-26 00:37:11 +03:00
|
|
|
|^
|
|
|
|
=. nodes.q.update
|
|
|
|
%- ~(gas by *(map index:store node:store))
|
|
|
|
%+ turn
|
|
|
|
(concat-by-parent (sort-nodes nodes.q.update))
|
|
|
|
add-hash-to-node
|
2021-02-26 23:05:11 +03:00
|
|
|
=/ hashes (nodes-to-pending-indices nodes.q.update)
|
2021-02-26 00:37:11 +03:00
|
|
|
;< ~ bind:m
|
|
|
|
%^ poke-our %graph-push-hook
|
|
|
|
%graph-update
|
|
|
|
!>(update)
|
2021-02-26 23:05:11 +03:00
|
|
|
(pure:m !>(`action:graph-view`[%pending-indices hashes]))
|
2021-02-26 00:37:11 +03:00
|
|
|
::
|
|
|
|
++ sort-nodes
|
|
|
|
|= nodes=(map index:store node:store)
|
|
|
|
^- (list [index:store node:store])
|
|
|
|
%+ sort ~(tap by nodes)
|
|
|
|
|= [p=[=index:store *] q=[=index:store *]]
|
|
|
|
^- ?
|
|
|
|
(lth (lent index.p) (lent index.q))
|
|
|
|
::
|
|
|
|
++ concat-by-parent
|
|
|
|
|= lis=(list [index:store node:store])
|
|
|
|
^- (list [index:store node:store])
|
|
|
|
%~ tap by
|
|
|
|
%+ roll lis
|
|
|
|
|= $: [=index:store =node:store]
|
|
|
|
nds=(map index:store node:store)
|
|
|
|
==
|
|
|
|
?: ?=(~ index) !!
|
|
|
|
?: ?=([@ ~] index)
|
|
|
|
(~(put by nds) index node)
|
|
|
|
=/ ind (snip `(list atom)`index)
|
|
|
|
=/ nod (~(get by nds) ind)
|
|
|
|
?~ nod
|
|
|
|
(~(put by nds) index node)
|
|
|
|
=. children.u.nod
|
|
|
|
:- %graph
|
|
|
|
?: ?=(%empty -.children.u.nod)
|
|
|
|
%+ gas:orm:store *graph:store
|
|
|
|
[(rear index) node]~
|
|
|
|
%^ put:orm:store p.children.u.nod
|
|
|
|
(rear index)
|
|
|
|
node
|
|
|
|
(~(put by nds) ind u.nod)
|
|
|
|
::
|
|
|
|
++ add-hash-to-node
|
|
|
|
=| parent-hash=(unit hash:store)
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
=* loop $
|
|
|
|
:- index
|
|
|
|
=* p post.node
|
2021-03-02 22:10:40 +03:00
|
|
|
=/ =hash:store
|
2021-02-26 00:37:11 +03:00
|
|
|
=- `@ux`(sham -)
|
|
|
|
:^ ?^ parent-hash
|
|
|
|
parent-hash
|
|
|
|
(index-to-parent-hash index)
|
|
|
|
author.p
|
|
|
|
time-sent.p
|
|
|
|
contents.p
|
|
|
|
%_ node
|
2021-03-02 22:10:40 +03:00
|
|
|
hash.post `hash
|
|
|
|
::
|
|
|
|
:: TODO: enable signing our own post as soon as we're ready
|
|
|
|
:: signatures.post
|
|
|
|
:: %- ~(gas in *signatures:store)
|
|
|
|
:: [(sign:sig our.bowl now.bowl hash)]~
|
2021-02-26 00:37:11 +03:00
|
|
|
::
|
|
|
|
children
|
|
|
|
?: ?=(%empty -.children.node)
|
|
|
|
children.node
|
|
|
|
:- %graph
|
|
|
|
%+ gas:orm:store *graph:store
|
|
|
|
%+ turn
|
|
|
|
%+ turn
|
|
|
|
(tap-deep:graph index p.children.node)
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
%_ loop
|
2021-03-02 22:10:40 +03:00
|
|
|
parent-hash `hash
|
2021-02-26 00:37:11 +03:00
|
|
|
index index
|
|
|
|
node node
|
|
|
|
==
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- [atom node:store]
|
|
|
|
[(rear index) node]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ index-to-parent-hash
|
|
|
|
|= =index:store
|
|
|
|
^- (unit hash:store)
|
|
|
|
?: ?=(~ index)
|
|
|
|
!!
|
|
|
|
?: ?=([@ ~] index)
|
|
|
|
~
|
|
|
|
=/ node
|
|
|
|
%+ got-node:graph
|
|
|
|
resource.q.update
|
|
|
|
(snip `(list atom)`index)
|
|
|
|
hash.post.node
|
2021-02-26 23:05:11 +03:00
|
|
|
::
|
|
|
|
++ nodes-to-pending-indices
|
|
|
|
|= nodes=(map index:store node:store)
|
2021-02-27 01:59:13 +03:00
|
|
|
^- (map hash:store index:store)
|
|
|
|
%- ~(gas by *(map hash:store index:store))
|
2021-02-26 23:05:11 +03:00
|
|
|
%+ turn ~(tap by nodes)
|
|
|
|
|= [=index:store =node:store]
|
2021-02-27 01:59:13 +03:00
|
|
|
^- [hash:store index:store]
|
2021-02-26 23:05:11 +03:00
|
|
|
?> ?=(^ hash.post.node)
|
2021-02-27 01:59:13 +03:00
|
|
|
[u.hash.post.node index]
|
2021-02-26 00:37:11 +03:00
|
|
|
--
|