Class: Ethereum::SpecialContract::SHA256

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/special_contract.rb

Instance Method Summary collapse

Instance Method Details

#call(ext, msg) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/ethereum/special_contract.rb', line 43

def call(ext, msg)
  gas_cost = Opcodes::GSHA256BASE +
    (Utils.ceil32(msg.data.size) / 32) * Opcodes::GSHA256WORD
  return 0, 0, [] if msg.gas < gas_cost

  d = msg.data.extract_all
  o = Utils.bytes_to_int_array Utils.sha256(d)

  return 1, msg.gas - gas_cost, o
end