summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ht.erl17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ht.erl b/src/ht.erl
index 0badb19..8e801b9 100644
--- a/src/ht.erl
+++ b/src/ht.erl
@@ -66,22 +66,21 @@ size(Head) ->
-spec append(head(), leaf() | iolist() | binary()) -> head().
append(#head{version = 0}, Leaf) when is_record(Leaf, leaf) ->
mkhead(1, Leaf);
-append(Head, Leaf) when is_record(Leaf, leaf) ->
- N = Head#head.version,
+append(#head{version = N, tree = Tree}, Leaf) when is_record(Leaf, leaf) ->
Level = fls(N),
- RBD = rightbranchdepth(Head#head.tree),
+ RBD = rightbranchdepth(Tree),
%io:format("N=~p, Level=~p, RBD=~p~n", [N, Level, RBD]),
- #head{version = N + 1, tree = append(Head#head.tree, Leaf, RBD-Level-1)};
+ #head{version = N + 1, tree = append_at(Tree, Leaf, RBD-Level-1)};
append(Head, Data) ->
append(Head, mkleaf(Data)).
--spec append(tree(), tree(), pos_integer()) -> tree().
-append(Dest, Newtree, _) when is_record(Dest, leaf) ->
+-spec append_at(tree(), tree(), pos_integer()) -> tree().
+append_at(Dest, Newtree, _) when is_record(Dest, leaf) ->
mkinner(Dest, Newtree);
-append(Dest, Newtree, 0) when is_record(Dest, inner) ->
+append_at(Dest, Newtree, 0) when is_record(Dest, inner) ->
mkinner(Dest, Newtree);
-append(Dest, Newtree, Depth) when is_record(Dest, inner) ->
- mkinner(Dest#inner.child0, append(Dest#inner.child1, Newtree, Depth - 1)).
+append_at(Dest, Newtree, Depth) when is_record(Dest, inner) ->
+ mkinner(Dest#inner.child0, append_at(Dest#inner.child1, Newtree, Depth - 1)).
%% @doc Return an audit path.
%%