aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/data/merkletree.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/data/merkletree.ex')
-rw-r--r--shard/lib/data/merkletree.ex14
1 files changed, 11 insertions, 3 deletions
diff --git a/shard/lib/data/merkletree.ex b/shard/lib/data/merkletree.ex
index 73679cf..94bd443 100644
--- a/shard/lib/data/merkletree.ex
+++ b/shard/lib/data/merkletree.ex
@@ -92,9 +92,17 @@ defmodule SData.MerkleTree do
end
@doc"""
- Get the hashes of all blocks in a range
+ Get the hashes of all blocks
"""
- def get_range(mt, range) do
- range |> Enum.map(&(get(mt, &1))) # TODO: do this efficiently
+ def get_all(mt) do
+ %Page{child_nblk: cn, list: list} = Store.get(mt.store, mt.root)
+ if cn == 1 do
+ list
+ else
+ list
+ |> Enum.map(&(%{mt | root: &1}))
+ |> Enum.map(&get_all/1)
+ |> Enum.reduce([], &(&2++&1))
+ end
end
end