lib/sp_store/storage/hash_tree_storage.rb
# Calls empty_store_without_hash
# Then initializes disk hash tree and stores into disk
#
Calls empty_store_without_hash
Then initializes disk hash tree and stores into disk
Calls empty_store_without_hash Then initializes disk hash tree and stores into disk
def empty_store( block_size, block_count, disk_directory )
      store     = empty_store_without_hash( block_size, block_count, disk_directory )
      empty_block_hash = SpStore::Crypto.crypto_hash empty_block(block_size)
      tree_size        = SpStore::Merkle::HashTreeHelper.full_tree_node_count block_count
      hash_tree        = SpStore::Mocks::SoftHashTree.new block_count, empty_block_hash
      File.open( File.join( disk_path(disk_directory), 'disk_hash_tree' ), 'wb') do |file|
        file.seek(empty_block_hash.size, IO::SEEK_SET)
        (1..tree_size).each do |node|
           file.write hash_tree.node_hash(node)
        end
      end
      store
    end
def empty_store ( block_size , block_count , disk_directory ) store = empty_store_without_hash ( block_size , block_count , disk_directory ) empty_block_hash = SpStore :: Crypto . crypto_hash empty_block ( block_size ) tree_size = SpStore :: Merkle :: HashTreeHelper . full_tree_node_count block_count hash_tree = SpStore :: Mocks :: SoftHashTree . new block_count , empty_block_hash File . open ( File . join ( disk_path ( disk_directory ) , 'disk_hash_tree' ) , 'wb' ) do | file | file . seek ( empty_block_hash . size , IO :: SEEK_SET ) ( 1 .. tree_size ) . each do | node | file . write hash_tree . node_hash ( node ) end end store end
Calls empty_store_without_hash
Then initializes disk hash tree and stores into disk
Calls empty_store_without_hash Then initializes disk hash tree and stores into disk
#initialize disk hash tree
block_size
block_count
disk_directory