diff options
| author | Magnus Ahltorp <map@kth.se> | 2015-02-06 19:14:54 +0100 |
|---|---|---|
| committer | Magnus Ahltorp <map@kth.se> | 2015-02-06 19:14:54 +0100 |
| commit | b1849d0a40a6b44400bf0a833bf03b3ceb659c9b (patch) | |
| tree | c0efdc3b3afc7fdc0d1337f4b0aebe5a30efab5c | |
| parent | ed62e966bd47ee8cf84487a718799fe2bcef188c (diff) | |
Implement fetching of multiple entries in storage/getentry
| -rw-r--r-- | src/storage.erl | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/storage.erl b/src/storage.erl index b7acfd7..64f4ded 100644 --- a/src/storage.erl +++ b/src/storage.erl @@ -38,11 +38,15 @@ request(get, "ct/storage/fetchnewentries", _Input) -> success({[{result, <<"ok">>}, {entries, Entries}]}); request(get, "ct/storage/getentry", Query) -> - Hash = base64:decode(proplists:get_value("hash", Query)), - Hashes = [Hash], + Hashes = [base64:decode(Value) || {Key, Value} <- Query, Key == "hash"], Entries = lists:map(fun(LeafHash) -> {[{hash, base64:encode(LeafHash)}, - {entry, base64:encode(db:entry_for_leafhash(LeafHash))}]} + {entry, base64:encode(case db:entry_for_leafhash(LeafHash) of + noentry -> + <<>>; + Entry -> + Entry + end)}]} end, Hashes), success({[{result, <<"ok">>}, {entries, Entries}]}). |
