Merge pull request #4978 from urbit/la/fast-validate-graph

This commit is contained in:
L 2021-06-03 19:48:56 -05:00 committed by GitHub
commit e6925e7094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 89 deletions

View File

@ -19,7 +19,7 @@
+$ debug-input [%validate-graph =resource:store] +$ debug-input [%validate-graph =resource:store]
:: ::
+$ cache +$ cache
$: validators=(map mark dais:clay) $: validators=(map mark $-(indexed-post:store indexed-post:store))
== ==
:: ::
:: TODO: come back to this and potentially use ford runes or otherwise :: TODO: come back to this and potentially use ford runes or otherwise
@ -627,22 +627,27 @@
|= [=graph:store mark=(unit mark:store)] |= [=graph:store mark=(unit mark:store)]
^- [? _state] ^- [? _state]
?~ mark [%.y state] ?~ mark [%.y state]
=/ has-dais (~(has by validators) u.mark) =/ has-validator (~(has by validators) u.mark)
=/ =dais:clay =/ validate=$-(indexed-post:store indexed-post:store)
?: has-dais ?: has-validator
(~(got by validators) u.mark) (~(got by validators) u.mark)
.^ =dais:clay .^ $-(indexed-post:store indexed-post:store)
%cb %cf
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark] (scot %p our.bowl)
q.byk.bowl
(scot %da now.bowl)
u.mark
%graph-indexed-post
~
== ==
:_ state(validators (~(put by validators) u.mark dais)) :_ state(validators (~(put by validators) u.mark validate))
|- ^- ? |- ^- ?
?~ graph %.y ?~ graph %.y
%+ roll (tap:orm graph) %+ roll (tap:orm graph)
|= [[=atom =node:store] out=?] |= [[=atom =node:store] out=?]
^- ? ^- ?
?& ?| ?=(%| -.post.node) ?& ?| ?=(%| -.post.node)
?=(^ (vale:dais [atom p.post.node])) ?=(^ (validate [atom p.post.node]))
== ==
:: ::
?- -.children.node ?- -.children.node

View File

@ -0,0 +1,14 @@
/- *post
|_ i=indexed-post
++ grow
|%
++ noun i
--
::
++ grab
|%
++ noun indexed-post
--
::
++ grad %noun
--

View File

@ -4,6 +4,11 @@
|% |%
++ noun i ++ noun i
:: ::
++ graph-indexed-post
^- indexed-post
?> ?=([@ ~] index.p.i)
i
::
++ graph-permissions-add ++ graph-permissions-add
|= vip=vip-metadata:met |= vip=vip-metadata:met
^- permissions:graph ^- permissions:graph
@ -30,13 +35,10 @@
=- [- post(index -)] =- [- post(index -)]
[atom ~] [atom ~]
-- --
++ grab ::
++ grab
|% |%
++ noun ++ noun indexed-post
|: p=`*`%*(. *indexed-post index.p [0 ~])
=/ ip ;;(indexed-post p)
?> ?=([@ ~] index.p.ip)
ip
-- --
:: ::
++ grad %noun ++ grad %noun

View File

@ -3,6 +3,13 @@
++ grow ++ grow
|% |%
++ noun i ++ noun i
::
++ graph-indexed-post
^- indexed-post
?> ?=(?([@ ~] [@ @ ~]) index.p.i)
?> (lth i.index.p.i (bex 128))
i
::
++ notification-kind ++ notification-kind
^- (unit notif-kind:hark) ^- (unit notif-kind:hark)
?+ index.p.i ~ ?+ index.p.i ~
@ -12,12 +19,7 @@
-- --
++ grab ++ grab
|% |%
++ noun ++ noun indexed-post
|: p=`*`%*(. *indexed-post index.p [0 0 ~])
=/ ip ;;(indexed-post p)
?> ?=(?([@ ~] [@ @ ~]) index.p.ip)
?> (lth i.index.p.ip (bex 128))
ip
-- --
:: ::
++ grad %noun ++ grad %noun

View File

@ -4,6 +4,28 @@
|% |%
++ noun i ++ noun i
:: ::
++ graph-indexed-post
^- indexed-post
?+ index.p.i ~|(index+index.p.i !!)
:: top-level link post; title and url
::
[@ ~]
?> ?=([[%text @] $%([%url @] [%reference *]) ~] contents.p.i)
i
::
:: comment on link post; container structure
::
[@ @ ~]
?> ?=(~ contents.p.i)
i
::
:: comment on link post; comment text
::
[@ @ @ ~]
?> ?=(^ contents.p.i)
i
==
::
++ graph-permissions-add ++ graph-permissions-add
|= vip=vip-metadata:met |= vip=vip-metadata:met
^- permissions:graph ^- permissions:graph
@ -48,28 +70,7 @@
-- --
++ grab ++ grab
|% |%
++ noun ++ noun indexed-post
|: p=`*`%*(. *indexed-post index.p [0 0 ~])
=/ ip ;;(indexed-post p)
?+ index.p.ip ~|(index+index.p.ip !!)
:: top-level link post; title and url
::
[@ ~]
?> ?=([[%text @] $%([%url @] [%reference *]) ~] contents.p.ip)
ip
::
:: comment on link post; container structure
::
[@ @ ~]
?> ?=(~ contents.p.ip)
ip
::
:: comment on link post; comment text
::
[@ @ @ ~]
?> ?=(^ contents.p.ip)
ip
==
-- --
++ grad %noun ++ grad %noun
-- --

View File

@ -3,6 +3,12 @@
++ grow ++ grow
|% |%
++ noun i ++ noun i
::
++ graph-indexed-post
^- indexed-post
?> ?=(^ contents.p.i)
i
::
++ graph-permissions-add ++ graph-permissions-add
|= vip=vip-metadata:met |= vip=vip-metadata:met
^- permissions:graph ^- permissions:graph
@ -40,13 +46,7 @@
-- --
++ grab ++ grab
|% |%
:: +noun: validate post ++ noun indexed-post
::
++ noun
|: p=`*`%*(. *indexed-post contents.p [%text '']~)
=/ ip ;;(indexed-post p)
?> ?=(^ contents.p.ip)
ip
-- --
:: ::
++ grad %noun ++ grad %noun

View File

@ -3,6 +3,44 @@
++ grow ++ grow
|% |%
++ noun i ++ noun i
::
++ graph-indexed-post
^- indexed-post
?+ index.p.i !!
:: top level post must have no content
[@ ~]
?> ?=(~ contents.p.i)
i
:: container for revisions
::
[@ %1 ~]
?> ?=(~ contents.p.i)
i
:: specific revision
:: first content is the title
:: revisions are numbered by the revision count
:: starting at one
[@ %1 @ ~]
?> ?=([* * *] contents.p.i)
?> ?=(%text -.i.contents.p.i)
i
:: container for comments
::
[@ %2 ~]
?> ?=(~ contents.p.i)
i
:: container for comment revisions
::
[@ %2 @ ~]
?> ?=(~ contents.p.i)
i
:: specific comment revision
::
[@ %2 @ @ ~]
?> ?=(^ contents.p.i)
i
==
::
++ graph-permissions-add ++ graph-permissions-add
|= vip=vip-metadata:met |= vip=vip-metadata:met
^- permissions:graph ^- permissions:graph
@ -55,45 +93,7 @@
-- --
++ grab ++ grab
|% |%
:: +noun: validate publish note ++ noun indexed-post
::
++ noun
|: p=`*`%*(. *indexed-post index.p [0 ~])
=/ ip ;;(indexed-post p)
?+ index.p.ip !!
:: top level post must have no content
[@ ~]
?> ?=(~ contents.p.ip)
ip
:: container for revisions
::
[@ %1 ~]
?> ?=(~ contents.p.ip)
ip
:: specific revision
:: first content is the title
:: revisions are numbered by the revision count
:: starting at one
[@ %1 @ ~]
?> ?=([* * *] contents.p.ip)
?> ?=(%text -.i.contents.p.ip)
ip
:: container for comments
::
[@ %2 ~]
?> ?=(~ contents.p.ip)
ip
:: container for comment revisions
::
[@ %2 @ ~]
?> ?=(~ contents.p.ip)
ip
:: specific comment revision
::
[@ %2 @ @ ~]
?> ?=(^ contents.p.ip)
ip
==
-- --
:: ::
++ grad %noun ++ grad %noun