diff options
author | Magnus Ahltorp <map@kth.se> | 2015-11-13 00:22:26 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2015-11-13 00:22:26 +0100 |
commit | b30199902dba22d6191a2eaa719957ee0e76bbff (patch) | |
tree | 096a5b0870b61f22621ef5942df6bb0716bbcfc3 | |
parent | 6eda14bd23c8bdf5ea2064ee9a9c8e92718c5176 (diff) |
Commit changes to entryhash keyvalue store
-rw-r--r-- | src/db.erl | 4 | ||||
-rw-r--r-- | src/frontend.erl | 4 | ||||
-rw-r--r-- | src/storage.erl | 1 |
3 files changed, 8 insertions, 1 deletions
@@ -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 a7ca153..6ce31b0 100644 --- a/src/frontend.erl +++ b/src/frontend.erl @@ -195,7 +195,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 6c38adf..ec70de6 100644 --- a/src/storage.erl +++ b/src/storage.erl @@ -27,6 +27,7 @@ request(post, "plop/v1/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, "plop/v1/storage/fetchnewentries", _Input) -> |