summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-11-13 00:22:26 +0100
committerLinus Nordberg <linus@nordu.net>2015-12-09 14:46:37 +0100
commit71baee406c023a833b97f2c8e62c2648009dca68 (patch)
tree2b2d7b280f420c53e162cff870ce3a2ddf19b34f /src
parentac53699656776f3fe8757e4fe96d1101c5c56681 (diff)
Commit changes to entryhash keyvalue store
Diffstat (limited to 'src')
-rw-r--r--src/db.erl4
-rw-r--r--src/frontend.erl4
-rw-r--r--src/storage.erl1
3 files changed, 8 insertions, 1 deletions
diff --git a/src/db.erl b/src/db.erl
index 25d2fc0..85ed5d8 100644
--- a/src/db.erl
+++ b/src/db.erl
@@ -15,6 +15,7 @@
-export([get_by_entry_hash/1, entry_for_leafhash/1, leafhash_for_index/1]).
-export([leafhash_for_indices/2, indexsize/0]).
-export([indexforhash_nosync/2, indexforhash_dosync/0, index_sync/0]).
+-export([commit_entryhash/0]).
%% gen_server callbacks.
-export([init/1, handle_call/3, terminate/2, handle_cast/2, handle_info/2,
code_change/3]).
@@ -101,6 +102,9 @@ sync_entry_db() ->
add_entryhash(LeafHash, EntryHash) ->
perm:addvalue(entryhash_db, EntryHash, LeafHash).
+commit_entryhash() ->
+ perm:commit(entryhash_db).
+
-spec add_index_nosync_noreverse(binary(), non_neg_integer()) -> ok.
add_index_nosync_noreverse(LeafHash, Index) ->
call(?MODULE, {add_index_nosync_noreverse, {LeafHash, Index}}).
diff --git a/src/frontend.erl b/src/frontend.erl
index 60f588a..707af0c 100644
--- a/src/frontend.erl
+++ b/src/frontend.erl
@@ -198,7 +198,9 @@ check_entries(Treesize) ->
End = Treesize - 1,
Start = db:sendsth_verified() + 1,
lager:debug("Top level checking entries ~p-~p", [Start, End]),
- check_entries_chunked(Start, End).
+ Errors = check_entries_chunked(Start, End),
+ db:commit_entryhash(),
+ Errors.
check_entries_chunked(Start, End) ->
lager:debug("Checking entries ~p-~p", [Start, End]),
diff --git a/src/storage.erl b/src/storage.erl
index a1f62f9..efe4768 100644
--- a/src/storage.erl
+++ b/src/storage.erl
@@ -29,6 +29,7 @@ request(post, ?APPURL_PLOP_STORAGE, "entrycommitted", Input) ->
EntryHash = base64:decode(proplists:get_value(<<"entryhash">>, PropList)),
LeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
db:add_entryhash(LeafHash, EntryHash),
+ db:commit_entryhash(),
success({[{result, <<"ok">>}]})
end;
request(get, ?APPURL_PLOP_STORAGE, "fetchnewentries", _Input) ->