summaryrefslogtreecommitdiff
path: root/src/plop.erl
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-09-09 16:29:53 +0200
committerLinus Nordberg <linus@nordberg.se>2014-09-09 16:52:57 +0200
commitfbf64f31f34a12a9fc983f74bec27e5fbbe85f34 (patch)
tree74ba2a26673c4686f0baaad658918e1cf216bc59 /src/plop.erl
parente7a1ca43af470b6e99c0e11d845903f9bf00c723 (diff)
New hash tree implementation, using an ETS table for the hashes.
Also, add an untested entry storage implementation, using multiple DETS tables.
Diffstat (limited to 'src/plop.erl')
-rw-r--r--src/plop.erl31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/plop.erl b/src/plop.erl
index f681898..8377684 100644
--- a/src/plop.erl
+++ b/src/plop.erl
@@ -45,7 +45,7 @@
-record(state, {pubkey :: public_key:rsa_public_key(),
privkey :: public_key:rsa_private_key(),
logid :: binary(),
- hashtree :: ht:head()}).
+ hashtree :: ht:history_tree()}).
%% @doc The parts of an STH which is to be signed. Used as the
%% interface to plop:sth/1, for testing.
@@ -158,20 +158,21 @@ handle_call({test, pubkey}, _From,
{reply, PK, Plop}.
%%%%%%%%%%%%%%%%%%%%
--spec build_tree_from_db() -> ht:head().
+-spec build_tree_from_db() -> ht:history_tree().
build_tree_from_db() ->
- build_tree(ht:create(), lists:seq(0, db:size() - 1)).
--spec build_tree(ht:head(), list()) -> ht:head().
-build_tree(Tree, []) ->
- Tree;
-build_tree(Tree, [H|T]) ->
- Data = db_get_single_entry(H),
- build_tree(ht:append(Tree, Data), T).
-
-db_get_single_entry(N) ->
- [#mtl{entry = #timestamped_entry{entry = #plop_entry{data = Data}}}] =
- db:get_by_index(N, N),
- Data.
+ ht:new(db:size() - 1).
+
+%% -spec build_tree(ht:head(), list()) -> ht:head().
+%% build_tree(Tree, []) ->
+%% Tree;
+%% build_tree(Tree, [H|T]) ->
+%% Data = db_get_single_entry(H),
+%% build_tree(ht:append(Tree, Data), T).
+
+%% db_get_single_entry(N) ->
+%% [#mtl{entry = #timestamped_entry{entry = #plop_entry{data = Data}}}] =
+%% db:get_by_index(N, N),
+%% Data.
-spec do_add(timestamped_entry(), public_key:rsa_private_key(),
binary(), any()) -> {any(), binary()}.
@@ -199,7 +200,7 @@ do_add(TimestampedEntry = #timestamped_entry{entry = PlopEntry},
mtl = MTL,
spt = NewSPT},
{atomic, ok} = db:add(DB_data),
- {ht:append(Tree, serialise(MTL)), % New tree.
+ {ht:add(Tree, serialise(MTL)), % New tree.
NewSPT}; % New SPT.
Err -> {error, Err}
end.