diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/db.erl | 4 | ||||
-rw-r--r-- | src/ht.erl | 12 | ||||
-rw-r--r-- | src/ts.erl | 17 |
3 files changed, 21 insertions, 12 deletions
@@ -7,7 +7,9 @@ %% API. -export([start_link/0, stop/0]). -export([add/4, add/2, add_entryhash/2, add_index/2, set_treesize/1, size/0]). --export([get_by_index/1, get_by_indices/3, get_by_leaf_hash/1, get_by_entry_hash/1, entry_for_leafhash/1, leafhash_for_index/1, leafhash_for_indices/2, indexsize/0]). +-export([get_by_index/1, get_by_indices/3, get_by_leaf_hash/1]). +-export([get_by_entry_hash/1, entry_for_leafhash/1, leafhash_for_index/1]). +-export([leafhash_for_indices/2, indexsize/0]). %% gen_server callbacks. -export([init/1, handle_call/3, terminate/2, handle_cast/2, handle_info/2, code_change/3]). @@ -423,12 +423,12 @@ test_init(L) -> add_test() -> lists:foreach( fun(X) -> L = lists:sublist(?TEST_VECTOR_LEAVES, X), - test_init(L), + test_init(lists:map(fun mkleafhash/1, L)), ?assertEqual(mth(L), root()) end, random_entries(length(?TEST_VECTOR_LEAVES))). old_versions_test() -> - test_init(?TEST_VECTOR_LEAVES), + test_init(lists:map(fun mkleafhash/1, (?TEST_VECTOR_LEAVES))), ?assertEqual(mth(?TEST_VECTOR_LEAVES), root()), lists:foreach( fun(X) -> ?assertEqual(mth(lists:sublist(?TEST_VECTOR_LEAVES, X)), @@ -437,7 +437,7 @@ old_versions_test() -> old_versions_bigger_test() -> LEAVES = [<<X:32>> || X <- lists:seq(0, 64)], % 1024 is not unreasonable - test_init(LEAVES), + test_init(lists:map(fun mkleafhash/1, LEAVES)), ?assertEqual(mth(LEAVES), root()), lists:foreach( fun(X) -> ?assertEqual(mth(lists:sublist(LEAVES, X)), @@ -467,7 +467,7 @@ old_versions_bigger_test() -> %% @doc Test paths on a single version 7 tree. path_test() -> - test_init(?TEST_VECTOR_LEAVES), + test_init(lists:map(fun mkleafhash/1, ?TEST_VECTOR_LEAVES)), foreach( fun(N) -> Test = lists:nth(N, ?TEST_VECTOR_PATHS), @@ -484,7 +484,7 @@ path_inc_test() -> fun(N) -> Test = lists:nth(N, ?TEST_VECTOR_PATHS), Leaves = lists:sublist(?TEST_VECTOR_LEAVES, element(2, Test)), - test_init(Leaves), + test_init(lists:map(fun mkleafhash/1, Leaves)), ?assertEqual( path_ref(element(1, Test) - 1, Leaves), path(element(1, Test) - 1, element(2, Test) - 1)) @@ -523,7 +523,7 @@ path_inc_test() -> %% @doc Test proofs on a single version 7 tree. consistency_test() -> - test_init(?TEST_VECTOR_LEAVES), + test_init(lists:map(fun mkleafhash/1, ?TEST_VECTOR_LEAVES)), foreach( fun(N) -> Test = lists:nth(N, ?TEST_VECTOR_PROOFS), @@ -9,7 +9,10 @@ -export_type([tree_store/0]). -export([new/0, add/3, delete/2, retrieve/2, count/2]). --record(tree_store, {layers :: array:array(array:array(binary()))}). % array of arrays, keyed on layer. +%% #tree_store{} has one member, layers, holding an array of arrays +%% with binaries, keyed on layer. +%% TODO R17: -record(tree_store, {layers :: array:array(array:array(binary()))}). +-record(tree_store, {layers}). -type tree_store() :: #tree_store{}. %%%%%%%%%%%%%%%%%%%% @@ -44,18 +47,22 @@ count(#tree_store{layers = Layers}, Layer) -> %%%%%%%%%%%%%%%%%%%% %% Private. --spec layer_ro(array:array(array:array(binary())), non_neg_integer()) -> array:array(binary). +%% TODO: R17 +%% -spec layer_ro(array:array(array:array(binary())), non_neg_integer()) -> +%% array:array(binary). layer_ro(Layers, Layer) -> case array:get(Layer, Layers) of undefined -> array:new(); - List -> List + Array -> Array end. --spec layer_rw(array:array(array:array(binary())), non_neg_integer()) -> {array:array(), array:array(binary)}. +%% TODO: R17 +%% -spec layer_rw(array:array(array:array(binary())), non_neg_integer()) -> +%% {array:array(), array:array(binary)}. layer_rw(Layers, Layer) -> case array:get(Layer, Layers) of undefined -> {array:set(Layer, array:new(), Layers), array:new()}; - List -> {Layers, List} + Array -> {Layers, Array} end. %%%%%%%%%%%%%%%%%%%% |