summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2014-06-01 16:22:36 +0200
committerLinus Nordberg <linus@nordberg.se>2014-06-01 16:22:36 +0200
commit73bee488f683aa82c6266081be5c7bae900b5bd2 (patch)
treedc29ad2ad63008f325a58a0a55182fd72c4e20ae
parente2279cc9ac168c3c95e9c399c77888856bdd2362 (diff)
Clean up the mkhash / gethash name mess a bit.
-rw-r--r--src/ht.erl17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ht.erl b/src/ht.erl
index aeea829..a72b9ac 100644
--- a/src/ht.erl
+++ b/src/ht.erl
@@ -104,9 +104,9 @@ audit_path(_, [], Acc) ->
audit_path(#inner{child0 = Left, child1 = Right}, [PathH|PathT], Acc) ->
case PathH of
0 -> % Take a left.
- audit_path(Left, PathT, [gethash2(Right) | Acc]);
+ audit_path(Left, PathT, [gethash(Right) | Acc]);
_ -> % Take a right.
- audit_path(Right, PathT, [gethash2(Left) | Acc])
+ audit_path(Right, PathT, [gethash(Left) | Acc])
end.
%% @doc Return a consistency proof.
@@ -154,19 +154,18 @@ mkinner(Leaf, Tree) ->
child1 = Tree,
hash = mkhash(Leaf, Tree)}.
-%% TODO: merge mkhash/2 and gethash? if so, use it in mkleaf/1.
-spec mkhash(tree(), tree()) -> binary().
mkhash(Tree0, Tree1) ->
- hashfun([<<"\x01">>, gethash(Tree0), gethash(Tree1)]).
+ hashfun([<<"\x01">>, hash(Tree0), hash(Tree1)]).
--spec gethash(tree()) -> binary().
-gethash(#leaf{hash=Hash}) ->
+-spec hash(tree()) -> binary().
+hash(#leaf{hash=Hash}) ->
Hash;
-gethash(#inner{child0=Child0, child1=Child1}) ->
+hash(#inner{child0=Child0, child1=Child1}) ->
mkhash(Child0, Child1).
-gethash2(#leaf{hash = Hash}) -> Hash;
-gethash2(#inner{hash = Hash}) -> Hash.
+gethash(#leaf{hash = Hash}) -> Hash;
+gethash(#inner{hash = Hash}) -> Hash.
%% @doc Unsigned integer -> binary.
-spec ui2b(pos_integer()) -> binary().