summaryrefslogtreecommitdiff
path: root/src/plop.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2014-09-27 18:36:39 +0200
committerMagnus Ahltorp <map@kth.se>2014-09-27 18:36:39 +0200
commitf5951fdc069dc4c15b2c42d139d074ed55386e05 (patch)
treed48b53d052cb2d077cee194a498a80e20e6b09da /src/plop.erl
parentdc6b383aa4a9cc1e2793c4d9f3be81bd676b7a20 (diff)
Fix api problems
Diffstat (limited to 'src/plop.erl')
-rw-r--r--src/plop.erl17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plop.erl b/src/plop.erl
index b59e19b..9ea6aec 100644
--- a/src/plop.erl
+++ b/src/plop.erl
@@ -26,7 +26,7 @@
%% API.
-export([start_link/2, stop/0]).
-export([get_logid/0, serialise/1]).
--export([add/4, sth/0, get/1, get/2, spt/2, consistency/2, inclusion/2, inclusion_and_entry/2]).
+-export([add/3, sth/0, get/1, get/2, spt/1, consistency/2, inclusion/2, inclusion_and_entry/2]).
-export([generate_timestamp/0]).
%% API for tests.
-export([read_keyfile_rsa/2, read_keyfiles_ec/2]).
@@ -97,10 +97,10 @@ terminate(_Reason, _State) ->
ok.
%%%%%%%%%%%%%%%%%%%%
--spec add(binary(), binary(), binary(), binary()) -> ok.
-add(LogEntry, TreeLeafHash, EntryHash, DataToSign) ->
+-spec add(binary(), binary(), binary()) -> ok.
+add(LogEntry, TreeLeafHash, EntryHash) ->
gen_server:call(?MODULE,
- {add, {LogEntry, TreeLeafHash, EntryHash, DataToSign}}).
+ {add, {LogEntry, TreeLeafHash, EntryHash}}).
sth() ->
gen_server:call(?MODULE, {sth, []}).
@@ -113,6 +113,9 @@ get(Start, End) ->
get(Hash) ->
gen_server:call(?MODULE, {get, {hash, Hash}}).
+spt(Data) ->
+ gen_server:call(?MODULE, {spt, Data}).
+
consistency(TreeSizeFirst, TreeSizeSecond) ->
gen_server:call(?MODULE, {consistency, {TreeSizeFirst, TreeSizeSecond}}).
-spec inclusion(binary(), non_neg_integer()) ->
@@ -144,13 +147,17 @@ handle_call({get, logid}, _From,
handle_call({add, {LogEntry, TreeLeafHash, EntryHash}}, _From, Plop) ->
ok = ht:add(TreeLeafHash),
- ok = db:add(TreeLeafHash, EntryHash, LogEntry, ht:size()),
+ {atomic, ok} = db:add(TreeLeafHash, EntryHash, LogEntry, ht:size()),
{reply, ok, Plop};
handle_call({sth, Data}, _From,
Plop = #state{privkey = PrivKey}) ->
{reply, sth(PrivKey, Data), Plop};
+handle_call({spt, Data}, _From,
+ Plop = #state{privkey = PrivKey}) ->
+ {reply, spt(PrivKey, Data), Plop};
+
handle_call({consistency, {First, Second}}, _From, Plop) ->
{reply, ht:consistency(First - 1, Second - 1), Plop};