From 4f7ca0a0dc3361281fce0c6c52033775da428d43 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 12 Nov 2020 20:40:12 +0000 Subject: [PATCH] graph-store: add overwrite field to %add-graph --- pkg/arvo/app/graph-store.hoon | 25 +++++++++++++++---------- pkg/arvo/app/link-store.hoon | 2 +- pkg/arvo/app/publish.hoon | 1 + pkg/arvo/gen/graph-store/add-graph.hoon | 4 ++-- pkg/arvo/lib/graph-store.hoon | 2 ++ pkg/arvo/sur/graph-store.hoon | 2 +- pkg/arvo/ted/graph/create.hoon | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/pkg/arvo/app/graph-store.hoon b/pkg/arvo/app/graph-store.hoon index 42c95da91..b74743e11 100644 --- a/pkg/arvo/app/graph-store.hoon +++ b/pkg/arvo/app/graph-store.hoon @@ -66,8 +66,7 @@ :: update-logs.old %- ~(run by update-logs.old) - |= =update-log:store - *update-log:store + |=(a=* *update-log:store) == :: %1 @@ -77,8 +76,7 @@ :: update-logs.old %- ~(run by update-logs.old) - |= =update-log:store - *update-log:store + |=(a=* *update-log:store) == :: %2 [cards this(state old)] @@ -247,20 +245,27 @@ == :: ++ add-graph - |= [=resource:store =graph:store mark=(unit mark:store)] + |= $: =resource:store + =graph:store + mark=(unit mark:store) + overwrite=? + == ^- (quip card _state) - ?< (~(has by archive) resource) - ?< (~(has by graphs) resource) + ?> ?| overwrite + ?& !(~(has by archive) resource) + !(~(has by graphs) resource) + == == ?> (validate-graph graph mark) :_ %_ state graphs (~(put by graphs) resource [graph mark]) update-logs (~(put by update-logs) resource (gas:orm-log ~ ~)) + archive (~(del by archive) resource) validators ?~ mark validators (~(put in validators) u.mark) == %- zing - :~ (give [/updates /keys ~] [%add-graph resource graph mark]) + :~ (give [/updates /keys ~] [%add-graph resource graph mark overwrite]) ?~ mark ~ ?: (~(has in validators) u.mark) ~ =/ wire /validator/[u.mark] @@ -646,7 +651,7 @@ !> ^- update:store :+ %0 now.bowl - [%add-graph [ship term] `graph:store`p.u.result q.u.result] + [%add-graph [ship term] `graph:store`p.u.result q.u.result %.y] :: :: note: near-duplicate of /x/graph :: @@ -662,7 +667,7 @@ !> ^- update:store :+ %0 now.bowl - [%add-graph [ship term] `graph:store`p.u.result q.u.result] + [%add-graph [ship term] `graph:store`p.u.result q.u.result %.y] :: [%x %graph-subset @ @ @ @ ~] =/ =ship (slav %p i.t.t.path) diff --git a/pkg/arvo/app/link-store.hoon b/pkg/arvo/app/link-store.hoon index 0d8f472cf..d653e7748 100644 --- a/pkg/arvo/app/link-store.hoon +++ b/pkg/arvo/app/link-store.hoon @@ -116,7 +116,7 @@ |= [=resource =graph:gra] ^- card %- poke-graph-store - [%0 now.bowl %add-graph resource graph `%graph-validator-link] + [%0 now.bowl %add-graph resource graph `%graph-validator-link %.y] :: ++ archive-graph |= =resource diff --git a/pkg/arvo/app/publish.hoon b/pkg/arvo/app/publish.hoon index 1ee0c7450..2588be433 100644 --- a/pkg/arvo/app/publish.hoon +++ b/pkg/arvo/app/publish.hoon @@ -271,6 +271,7 @@ rid graph `%graph-validator-publish + %.y == (poke-graph-push %add rid) == diff --git a/pkg/arvo/gen/graph-store/add-graph.hoon b/pkg/arvo/gen/graph-store/add-graph.hoon index a95468928..0192ede89 100644 --- a/pkg/arvo/gen/graph-store/add-graph.hoon +++ b/pkg/arvo/gen/graph-store/add-graph.hoon @@ -3,8 +3,8 @@ /+ *graph-store :- %say |= $: [now=@da eny=@uvJ =beak] - [[=resource mark=(unit mark) ~] ~] + [[=resource mark=(unit mark) overwrite=? ~] ~] == :- %graph-update ^- update -[%0 now [%add-graph resource (gas:orm ~ ~) mark]] +[%0 now [%add-graph resource (gas:orm ~ ~) mark overwrite]] diff --git a/pkg/arvo/lib/graph-store.hoon b/pkg/arvo/lib/graph-store.hoon index 0b339bc76..397637c86 100644 --- a/pkg/arvo/lib/graph-store.hoon +++ b/pkg/arvo/lib/graph-store.hoon @@ -123,6 +123,7 @@ :~ [%resource (enjs:res resource.upd)] [%graph (graph graph.upd)] [%mark ?~(mark.upd ~ s+u.mark.upd)] + [%overwrite b+overwrite.upd] == :: %remove-graph @@ -276,6 +277,7 @@ :~ [%resource dejs:res] [%graph graph] [%mark (mu so)] + [%overwrite bo] == :: ++ graph diff --git a/pkg/arvo/sur/graph-store.hoon b/pkg/arvo/sur/graph-store.hoon index edcfb4135..e2570fed8 100644 --- a/pkg/arvo/sur/graph-store.hoon +++ b/pkg/arvo/sur/graph-store.hoon @@ -42,7 +42,7 @@ :: +$ update-0 $% logged-update-0 - [%add-graph =resource =graph mark=(unit mark)] + [%add-graph =resource =graph mark=(unit mark) overwrite=?] [%remove-graph =resource] :: [%add-tag =term =resource] diff --git a/pkg/arvo/ted/graph/create.hoon b/pkg/arvo/ted/graph/create.hoon index 287121832..e0c544818 100644 --- a/pkg/arvo/ted/graph/create.hoon +++ b/pkg/arvo/ted/graph/create.hoon @@ -38,7 +38,7 @@ ?. =(our.bowl entity.rid.action) (strand-fail:strandio %bad-request ~) =/ =update:graph - [%0 now.bowl %add-graph rid.action *graph:graph mark.action] + [%0 now.bowl %add-graph rid.action *graph:graph mark.action %.n] ;< ~ bind:m (poke-our %graph-store graph-update+!>(update)) ;< ~ bind:m