summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-09-14 23:46:09 +0200
committerLinus Nordberg <linus@nordberg.se>2014-09-14 23:46:09 +0200
commit7e67fc389bdfae2961062f1ebd4a81d91355f169 (patch)
treed91ef650e6637c8cba8fa8058f172f25e7b1c38f /src
parent4a86c60c415cc9b0790bb6bf1a8dcac6f802cae8 (diff)
Implement get-sth-consistency.
Diffstat (limited to 'src')
-rw-r--r--src/v1.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/v1.erl b/src/v1.erl
index 7e9e46d..781032b 100644
--- a/src/v1.erl
+++ b/src/v1.erl
@@ -49,11 +49,25 @@
plop:serialise(Signature))}],
deliver(SessionID, binary_to_list(jiffy:encode({R}))).
-'get-sth-consistency'(SessionID, _Env, _Input) ->
- niy(SessionID).
+'get-sth-consistency'(SessionID, _Env, Input) ->
+ %% TODO: move argument parsing to a generic function
+ R = case lists:sort(httpd:parse_query(Input)) of
+ [{"first", FirstInput}, {"second", SecondInput}] ->
+ {First, _} = string:to_integer(FirstInput),
+ {Second, _} = string:to_integer(SecondInput),
+ case lists:member(error, [First, Second]) of
+ true -> html("get-sth-consistency: bad input:",
+ [First, Second]);
+ _ -> [base64:encode(X) ||
+ X <- plop:consistency_proof(First, Second)]
+ end;
+ _ -> html("get-sth-consistency: bad input:", Input)
+ end,
+ deliver(SessionID, binary_to_list(jiffy:encode(R))).
'get-proof-by-hash'(SessionID, _Env, _Input) ->
niy(SessionID).
'get-entries'(SessionID, _Env, Input) ->
+ %% TODO: move argument parsing to a generic function
R = case lists:sort(httpd:parse_query(Input)) of
[{"end", EndInput}, {"start", StartInput}] ->
{Start, _} = string:to_integer(StartInput),