Class: Hashtastic::MerkleTree::LayersCreator
- Inherits:
-
Object
- Object
- Hashtastic::MerkleTree::LayersCreator
- Defined in:
- lib/hashtastic/merkle_tree/layers_creator.rb
Class Method Summary collapse
Class Method Details
.call(leafs, hashfunc = EthereumSHA3) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hashtastic/merkle_tree/layers_creator.rb', line 7 def call(leafs, hashfunc = EthereumSHA3) @hashfunc = hashfunc @leafs = leafs return [['']] if @leafs.empty? layers = [] layers.push(@leafs) while layers[layers.length - 1].length > 1 layers.push(next_layer(layers[layers.length - 1])) end layers end |