summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2014-09-27 18:36:39 +0200
committerLinus Nordberg <linus@nordberg.se>2014-09-29 10:21:56 +0200
commit6bceff8e5d10eff9ca59571e80a017afae347ced (patch)
tree1f5c06af81dc8d537cea7e73fb1ea0f9f514555b
parentb676b219edbc7f743dc4e186433a48e36424723a (diff)
Fix api problems
-rw-r--r--src/plop.erl19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plop.erl b/src/plop.erl
index b59e19b..c93b26d 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()) ->
@@ -143,19 +146,23 @@ handle_call({get, logid}, _From,
{reply, LogID, Plop};
handle_call({add, {LogEntry, TreeLeafHash, EntryHash}}, _From, Plop) ->
+ {atomic, ok} = db:add(TreeLeafHash, EntryHash, LogEntry, ht:size()),
ok = ht:add(TreeLeafHash),
- 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};
handle_call({inclusion, {Hash, TreeSize}}, _From, Plop) ->
- R = case db:get_by_entry_hash(Hash) of
+ R = case db:get_by_leaf_hash(Hash) of
notfound ->
{notfound, "Unknown hash"}; % FIXME: include Hash
{I, _MTLHash, _Entry} ->