From 90fce8bfa621f8c3be6663d62740783949111ff1 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 5 Oct 2016 22:22:31 +0200 Subject: core/state: rename Delete/IsDeleted to Suicide/HasSuicided The delete/remove naming has caused endless confusion in the past. --- core/vm/environment.go | 7 +++++-- core/vm/instructions.go | 2 +- core/vm/jit.go | 2 +- core/vm/vm.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'core/vm') diff --git a/core/vm/environment.go b/core/vm/environment.go index 1038e69d5..a4b2ac196 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -105,9 +105,12 @@ type Database interface { GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) - Delete(common.Address) bool + Suicide(common.Address) bool + HasSuicided(common.Address) bool + + // Exist reports whether the given account exists in state. + // Notably this should also return true for suicided accounts. Exist(common.Address) bool - IsDeleted(common.Address) bool } // Account represents a contract or basic ethereum account. diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 849a8463c..79aee60d2 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -614,7 +614,7 @@ func opSuicide(instr instruction, pc *uint64, env Environment, contract *Contrac balance := env.Db().GetBalance(contract.Address()) env.Db().AddBalance(common.BigToAddress(stack.pop()), balance) - env.Db().Delete(contract.Address()) + env.Db().Suicide(contract.Address()) } // following functions are used by the instruction jump table diff --git a/core/vm/jit.go b/core/vm/jit.go index 460a68ddd..55d2e0477 100644 --- a/core/vm/jit.go +++ b/core/vm/jit.go @@ -425,7 +425,7 @@ func jitCalculateGasAndSize(env Environment, contract *Contract, instr instructi } gas.Set(g) case SUICIDE: - if !statedb.IsDeleted(contract.Address()) { + if !statedb.HasSuicided(contract.Address()) { statedb.AddRefund(params.SuicideRefundGas) } case MLOAD: diff --git a/core/vm/vm.go b/core/vm/vm.go index 5d78b4a2a..033ada21c 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -303,7 +303,7 @@ func calculateGasAndSize(env Environment, contract *Contract, caller ContractRef } gas.Set(g) case SUICIDE: - if !statedb.IsDeleted(contract.Address()) { + if !statedb.HasSuicided(contract.Address()) { statedb.AddRefund(params.SuicideRefundGas) } case MLOAD: -- cgit v1.2.3