From 71baee406c023a833b97f2c8e62c2648009dca68 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Fri, 13 Nov 2015 00:22:26 +0100 Subject: Commit changes to entryhash keyvalue store --- src/db.erl | 4 ++++ src/frontend.erl | 4 +++- src/storage.erl | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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) -> -- cgit v1.1