From f5951fdc069dc4c15b2c42d139d074ed55386e05 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Sat, 27 Sep 2014 18:36:39 +0200 Subject: Fix api problems --- src/plop.erl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/plop.erl') 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}; -- cgit v1.1