aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app/pagestore.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/app/pagestore.ex')
-rw-r--r--shard/lib/app/pagestore.ex14
1 files changed, 14 insertions, 0 deletions
diff --git a/shard/lib/app/pagestore.ex b/shard/lib/app/pagestore.ex
index 7962084..f093ed4 100644
--- a/shard/lib/app/pagestore.ex
+++ b/shard/lib/app/pagestore.ex
@@ -66,6 +66,10 @@ defmodule SApp.PageStore do
{:reply, hash, state}
end
+ def handle_call({:have_rec, root}, _from, state) do
+ {:reply, have_rec(state, root), state}
+ end
+
defp add_request(state, key, from) do
reqs_key = case state.reqs[key] do
nil ->
@@ -89,6 +93,16 @@ defmodule SApp.PageStore do
end
end
+ defp have_rec(state, root) do
+ case :dets.lookup state.store, root do
+ [{_, _, bin}] ->
+ pg = SData.term_unbin bin
+ pg |> SData.Page.refs |> Enum.map(&(have_rec(state, &1))) |> Enum.all?
+ _ ->
+ false
+ end
+ end
+
defp init_rec_pull(state, key, why, prefer_ask) do
case prefer_ask do
[_|_] ->