From 41412486d1b128057e453ac94c675a83a2f3e1b4 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Tue, 18 Nov 2014 16:45:18 +0100 Subject: Move db size check from db.erl to plop.erl to allow reads past db size. --- src/db.erl | 2 +- src/plop.erl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/db.erl b/src/db.erl index 1c5c21f..526b639 100644 --- a/src/db.erl +++ b/src/db.erl @@ -163,7 +163,7 @@ leafhash_for_entryhash(EntryHash) -> get_by_indices_helper(Start, _End) when Start < 0 -> []; get_by_indices_helper(Start, End) -> - EndBound = min(End, size() - 1), + EndBound = min(End, indexsize() - 1), case Start =< EndBound of true -> lists:map(fun ({LeafHash, Index}) -> diff --git a/src/plop.erl b/src/plop.erl index 6501105..161faf8 100644 --- a/src/plop.erl +++ b/src/plop.erl @@ -217,8 +217,9 @@ handle_call(stop, _From, Plop) -> {stop, normal, stopped, Plop}; handle_call({get, {index, Start, End}}, _From, Plop) -> + EndBound = min(End, db:size() - 1), {reply, lists:map(fun (E) -> fill_in_entry(E) end, - db:get_by_indices(Start, End, {sorted, false})), + db:get_by_indices(Start, EndBound, {sorted, false})), Plop}; handle_call({get, {hash, EntryHash}}, _From, Plop) -> -- cgit v1.1