summaryrefslogtreecommitdiff
path: root/src/frontend.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend.erl')
-rw-r--r--src/frontend.erl30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/frontend.erl b/src/frontend.erl
index a3ea885..80cd9d2 100644
--- a/src/frontend.erl
+++ b/src/frontend.erl
@@ -15,11 +15,11 @@ request(post, ?APPURL_PLOP_FRONTEND, "sendentry", Input) ->
{error, E} ->
html("sendentry: bad input:", E);
Entries when is_list(Entries) ->
- lists:map(fun ({struct, PropList}) ->
- LogEntry = base64:decode(proplists:get_value(<<"entry">>, PropList)),
- TreeLeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
- ok = db:add_entry_nosync(TreeLeafHash, LogEntry)
- end, Entries),
+ ok = db:add_entries_nosync(lists:map(fun ({struct, PropList}) ->
+ LogEntry = base64:decode(proplists:get_value(<<"entry">>, PropList)),
+ TreeLeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
+ {TreeLeafHash, LogEntry}
+ end, Entries)),
ok = db:sync_entry_db(),
success({[{result, <<"ok">>}]});
{struct, PropList} ->
@@ -124,11 +124,11 @@ request(post, ?APPURL_PLOP_MERGE, "sendentry", Input) ->
{error, E} ->
html("sendentry: bad input:", E);
Entries when is_list(Entries) ->
- lists:map(fun ({struct, PropList}) ->
- LogEntry = base64:decode(proplists:get_value(<<"entry">>, PropList)),
- TreeLeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
- ok = db:add_entry_nosync(TreeLeafHash, LogEntry)
- end, Entries),
+ ok = db:add_entries_nosync(lists:map(fun ({struct, PropList}) ->
+ LogEntry = base64:decode(proplists:get_value(<<"entry">>, PropList)),
+ TreeLeafHash = base64:decode(proplists:get_value(<<"treeleafhash">>, PropList)),
+ {TreeLeafHash, LogEntry}
+ end, Entries)),
ok = db:sync_entry_db(),
success({[{result, <<"ok">>}]});
{struct, PropList} ->
@@ -273,14 +273,18 @@ check_entries_onechunk(Start, End) ->
end.
check_entries_int(Entries, Start, End) ->
- lists:foldl(fun ({Hash, Index}, Acc) ->
- case check_entry(Hash, Index) of
+ ParallelTasks = application:get_env(plop, check_entries_parallel_tasks, 1),
+ Results = util:parallel_map(fun ({Hash, Index}) ->
+ check_entry(Hash, Index)
+ end, lists:zip(Entries, lists:seq(Start, End)), ParallelTasks),
+ lists:foldl(fun (Result, Acc) ->
+ case Result of
ok ->
Acc;
Error ->
[Error | Acc]
end
- end, [], lists:zip(Entries, lists:seq(Start, End))).
+ end, [], Results).
check_entries_noreverse(Entries, Start, End) ->
ParallelTasks = application:get_env(plop, check_entries_parallel_tasks, 1),