aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/bind/backends/simulated.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-05-20 17:29:28 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-05-20 17:29:28 +0800
commit1580ec180414bce1e37acc614bc2445f778efb75 (patch)
tree7c8276f3f1558b5ce62edd0bff87745956084a4c /accounts/abi/bind/backends/simulated.go
parente798e4fd750745cec99c5a531e42998d9a7be85e (diff)
downloadgo-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar.gz
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar.bz2
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar.lz
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar.xz
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.tar.zst
go-tangerine-1580ec180414bce1e37acc614bc2445f778efb75.zip
accounts/abi/bind, eth: rely on getCode for sanity checks, not estimate and call
Diffstat (limited to 'accounts/abi/bind/backends/simulated.go')
-rw-r--r--accounts/abi/bind/backends/simulated.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
index 4866c4f58..54b1ce603 100644
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -78,6 +78,16 @@ func (b *SimulatedBackend) Rollback() {
b.pendingState, _ = state.New(b.pendingBlock.Root(), b.database)
}
+// HasCode implements ContractVerifier.HasCode, checking whether there is any
+// code associated with a certain account in the blockchain.
+func (b *SimulatedBackend) HasCode(contract common.Address, pending bool) (bool, error) {
+ if pending {
+ return len(b.pendingState.GetCode(contract)) > 0, nil
+ }
+ statedb, _ := b.blockchain.State()
+ return len(statedb.GetCode(contract)) > 0, nil
+}
+
// ContractCall implements ContractCaller.ContractCall, executing the specified
// contract with the given input data.
func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pending bool) ([]byte, error) {