summaryrefslogtreecommitdiff
path: root/src/db.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-10-29 16:35:44 +0100
committerLinus Nordberg <linus@nordberg.se>2014-10-29 16:56:48 +0100
commit92f681e1cbb444317d2603994c60c02feeab32be (patch)
treeef62cdfece8c1f063cb27cf299094e1f4d7eed1a /src/db.erl
parentb15f4636337c45b487651e8d442afed0d4141725 (diff)
parentcc2aaa2807bb13f4683c2d74a414d39d5b29a372 (diff)
Merge remote-tracking branch 'refs/remotes/map/external-merge3' into merging-external-merge
Conflicts: src/db.erl src/frontend.erl src/index.erl src/plop.erl src/storage.erl src/ts.erl
Diffstat (limited to 'src/db.erl')
-rw-r--r--src/db.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/db.erl b/src/db.erl
index cb1e618..60c4d30 100644
--- a/src/db.erl
+++ b/src/db.erl
@@ -9,6 +9,7 @@
-export([add/4, add/2, add_entryhash/2, add_index/2, set_treesize/1, size/0]).
-export([get_by_index/1, get_by_indices/3, get_by_leaf_hash/1]).
-export([get_by_entry_hash/1, entry_for_leafhash/1, leafhash_for_index/1]).
+-export([leafhash_for_indices/2, indexsize/0]).
%% gen_server callbacks.
-export([init/1, handle_call/3, terminate/2, handle_cast/2, handle_info/2,
code_change/3]).
@@ -19,6 +20,9 @@
size() ->
binary_to_integer(atomic:readfile(treesize_path())).
+indexsize() ->
+ index:indexsize(index_path()).
+
init(_Args) ->
{ok, []}.
@@ -159,11 +163,13 @@ handle_call({add, {LeafHash, EntryHash, Data, Index}}, _From, State) ->
ok = perm:ensurefile(indexforhash_root_path(),
LeafHash, integer_to_binary(Index)),
ok = index:add(index_path(), Index, LeafHash),
- ok = atomic:replacefile(treesize_path(), integer_to_list(Index+1)),
+ ok = atomic:replacefile(treesize_path(), integer_to_binary(Index+1)),
{reply, ok, State};
handle_call({add, {LeafHash, Data}}, _From, State) ->
+ lager:debug("add leafhash ~p", [LeafHash]),
ok = perm:ensurefile(entry_root_path(), LeafHash, Data),
+ lager:debug("leafhash ~p added", [LeafHash]),
{reply, ok, State};
handle_call({add_entryhash, {LeafHash, EntryHash}}, _From, State) ->
@@ -177,7 +183,7 @@ handle_call({add_index, {LeafHash, Index}}, _From, State) ->
{reply, ok, State};
handle_call({set_treesize, Size}, _From, State) ->
- ok = atomic:replacefile(treesize_path(), integer_to_list(Size)),
+ ok = atomic:replacefile(treesize_path(), integer_to_binary(Size)),
{reply, ok, State};
handle_call({get_by_indices, {Start, End, _Sorted}}, _From, State) ->