diff options
author | kiel barry <kiel.j.barry@gmail.com> | 2018-05-29 18:42:21 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-29 18:42:21 +0800 |
commit | 84f8c0cc1fbe1ab9c128555392a82ba609820fef (patch) | |
tree | 4859fe37105cc88d4d338a9f5bc55e42a017a29f /core | |
parent | 998f6564b28ea9241d0052c2abee090d2b9a8b63 (diff) | |
download | go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.gz go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.tar.zst go-tangerine-84f8c0cc1fbe1ab9c128555392a82ba609820fef.zip |
common: improve documentation comments (#16701)
This commit adds many comments and removes unused code.
It also removes the EmptyHash function, which had some uses
but was silly.
Diffstat (limited to 'core')
-rw-r--r-- | core/state/state_test.go | 2 | ||||
-rw-r--r-- | core/vm/gas_table.go | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/core/state/state_test.go b/core/state/state_test.go index 12778f6f1..123559ea9 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -99,7 +99,7 @@ func (s *StateSuite) TestNull(c *checker.C) { s.state.SetState(address, common.Hash{}, value) s.state.Commit(false) value = s.state.GetState(address, common.Hash{}) - if !common.EmptyHash(value) { + if value != (common.Hash{}) { c.Errorf("expected empty hash. got %x", value) } } diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 83adba428..0764c67a4 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -124,12 +124,12 @@ func gasSStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m // 1. From a zero-value address to a non-zero value (NEW VALUE) // 2. From a non-zero value address to a zero-value address (DELETE) // 3. From a non-zero to a non-zero (CHANGE) - if common.EmptyHash(val) && !common.EmptyHash(common.BigToHash(y)) { + if val == (common.Hash{}) && y.Sign() != 0 { // 0 => non 0 return params.SstoreSetGas, nil - } else if !common.EmptyHash(val) && common.EmptyHash(common.BigToHash(y)) { + } else if val != (common.Hash{}) && y.Sign() == 0 { + // non 0 => 0 evm.StateDB.AddRefund(params.SstoreRefundGas) - return params.SstoreClearGas, nil } else { // non 0 => non 0 (or 0 => 0) |