summaryrefslogtreecommitdiff
path: root/src/db.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-10-01 12:39:28 +0200
committerLinus Nordberg <linus@nordu.net>2015-11-11 13:32:37 +0100
commit0a3e6aafee314eaf9e5343c4cad89a9e2ae1d913 (patch)
tree2ceb97ebf656a26ac384e0e550dc2070d1b7ec72 /src/db.erl
parent55820add0bda7ac926f11ee49b232dc11d6fe39c (diff)
Change index.erl to use gen_server and named databases.
Prefetch indices in frontend:fetchmissingentries/2.
Diffstat (limited to 'src/db.erl')
-rw-r--r--src/db.erl17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/db.erl b/src/db.erl
index f204f76..5ad49ec 100644
--- a/src/db.erl
+++ b/src/db.erl
@@ -52,7 +52,7 @@ sendsth_verified() ->
end.
indexsize() ->
- index:indexsize(index_path()).
+ index:indexsize(index_db).
init(_Args) ->
{ok, []}.
@@ -182,11 +182,6 @@ terminate(_Reason, _State) ->
%%%%%%%%%%%%%%%%%%%%
%% The meat.
-% Table for Index -> Leaf hash
-index_path() ->
- {ok, Value} = application:get_env(plop, index_path),
- Value.
-
% File that stores the number of verified entries
verifiedsize_path() ->
{ok, Value} = application:get_env(plop, verifiedsize_path),
@@ -209,10 +204,10 @@ index_for_leafhash(LeafHash) ->
end.
leafhash_for_index(Index) ->
- index:get(index_path(), Index).
+ index:get(index_db, Index).
leafhash_for_indices(Start, End) ->
- index:getrange(index_path(), Start, End).
+ index:getrange(index_db, Start, End).
leafhash_for_entryhash(EntryHash) ->
perm:getvalue(entryhash_db, EntryHash).
@@ -235,7 +230,7 @@ handle_call(stop, _From, State) ->
{stop, normal, stopped, State};
handle_call({add_index_nosync_noreverse, {LeafHash, Index}}, _From, State) ->
- ok = index:add_nosync(index_path(), Index, LeafHash),
+ ok = index:add_nosync(index_db, Index, LeafHash),
{reply, ok, State}.
indexforhash_nosync(LeafHash, Index) ->
@@ -248,6 +243,4 @@ indexforhash_dosync() ->
ok.
index_sync() ->
- Basepath = index_path(),
- ok = util:fsync([Basepath, filename:dirname(Basepath)]),
- ok.
+ index:sync(index_db).