diff options
author | Linus Nordberg <linus@nordberg.se> | 2014-09-15 14:08:50 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2014-09-15 14:08:50 +0200 |
commit | 4515b324035c1b3969973ebeeeaf96223fe53aa1 (patch) | |
tree | aa93c30481138adc2ceebe2b055f2fce1b56fdb5 | |
parent | d5246146c7e8fb3da6ccb7163aaa4d501b55e5b6 (diff) |
Add inclusion/2.
-rw-r--r-- | src/plop.erl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/plop.erl b/src/plop.erl index f99d45d..bbfb687 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/1, sth/0, get/2, consistency/2]). +-export([add/1, sth/0, get/2, consistency/2, inclusion/2]). %% API for tests. -export([read_keyfile_rsa/2, read_keyfiles_ec/2]). -export([testing_get_pubkey/0]). @@ -112,6 +112,8 @@ get(Start, End) -> gen_server:call(?MODULE, {get, {Start, End}}). consistency(TreeSizeFirst, TreeSizeSecond) -> gen_server:call(?MODULE, {consistency, {TreeSizeFirst, TreeSizeSecond}}). +inclusion(Hash, TreeSize) -> + gen_server:call(?MODULE, {inclusion, {Hash, TreeSize}}). get_logid() -> gen_server:call(?MODULE, {get, logid}). testing_get_pubkey() -> @@ -148,6 +150,14 @@ handle_call({get, logid}, _From, handle_call({consistency, {First, Second}}, _From, Plop) -> {reply, ht:consistency(First - 1, Second - 1), Plop}; +handle_call({inclusion, {Hash, TreeSize}}, _From, Plop) -> + Proof = case db:find(Hash) of + [] -> []; + {plop, Index, _Hash, _MTL, _SPT} -> + ht:path(Index, TreeSize - 1) + end, + {reply, Proof, Plop}; + handle_call({test, pubkey}, _From, Plop = #state{pubkey = PK}) -> {reply, PK, Plop}. |