class Ethereum::SecureTrie

Public Class Methods

new(trie) click to toggle source
# File lib/ethereum/secure_trie.rb, line 10
def initialize(trie)
  @trie = trie
  @db = trie.db
end

Public Instance Methods

[](k) click to toggle source
# File lib/ethereum/secure_trie.rb, line 15
def [](k)
  @trie[Utils.keccak256(k)]
end
Also aliased as: get
[]=(k, v) click to toggle source
# File lib/ethereum/secure_trie.rb, line 20
def []=(k, v)
  h = Utils.keccak256 k
  @db.put h, k
  @trie[h] = v
end
Also aliased as: set
delete(k) click to toggle source
# File lib/ethereum/secure_trie.rb, line 27
def delete(k)
  @trie.delete Utils.keccak256(k)
end
each(&block) click to toggle source
# File lib/ethereum/secure_trie.rb, line 40
def each(&block)
  @trie.each do |h, v|
    k = @db.get h
    block.call k, v
  end
end
get(k)
Alias for: []
set(k, v)
Alias for: []=
to_h() click to toggle source
# File lib/ethereum/secure_trie.rb, line 31
def to_h
  o = {}
  @trie.to_h.each do |h, v|
    k = @db.get h
    o[k] = v
  end
  o
end