summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend.erl33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/frontend.erl b/src/frontend.erl
index f3c72ed..a3ea885 100644
--- a/src/frontend.erl
+++ b/src/frontend.erl
@@ -40,10 +40,39 @@ request(post, ?APPURL_PLOP_FRONTEND, "sendlog", Input) ->
write_or_verify_index(Start, Hashes)
end;
-request(post, ?APPURL_PLOP_FRONTEND, "sendsth", Input) ->
+request(post, ?APPURL_PLOP_FRONTEND, "verify-entries", Input) ->
case (catch mochijson2:decode(Input)) of
{error, E} ->
- html("sendentry: bad input:", E);
+ html("verify-entries: bad input:", E);
+ {struct, PropList} ->
+ VerifiedSize = db:sendsth_verified() + 1,
+ NewSize = proplists:get_value(<<"verify_to">>, PropList),
+ Indexsize = db:indexsize(),
+
+ if
+ NewSize < VerifiedSize ->
+ success({[{result, <<"ok">>}, {verified, VerifiedSize}]});
+ NewSize > Indexsize ->
+ html("Has too few entries", Indexsize);
+ true ->
+ lager:debug("old size: ~p new size: ~p",
+ [VerifiedSize, NewSize]),
+
+ Errors = check_entries(NewSize),
+
+ case Errors of
+ [] ->
+ success({[{result, <<"ok">>}, {verified, NewSize}]});
+ _ ->
+ html("Database not complete", Errors)
+ end
+ end
+ end;
+
+request(post, ?APPURL_PLOP_FRONTEND, "publish-sth", Input) ->
+ case (catch mochijson2:decode(Input)) of
+ {error, E} ->
+ html("publish-sth: bad input:", E);
{struct, PropList} ->
OldSize = db:size(),
Treesize = proplists:get_value(<<"tree_size">>, PropList),