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
committerJeffrey Wilcke <geffobscura@gmail.com>2016-05-24 15:33:15 +0800
commit1776c717bfb540f95e1b2233f35ea6f4cc8f57d5 (patch)
tree5926f97eb049e55d7aeb8cb338bf1b9f0892d008 /accounts/abi/bind/backends/simulated.go
parent0f6e3e873ab378e8ef997adcf5b0a0d78b6c90cc (diff)
downloadgo-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar.gz
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar.bz2
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar.lz
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar.xz
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.tar.zst
go-tangerine-1776c717bfb540f95e1b2233f35ea6f4cc8f57d5.zip
[release 1.4.5] accounts/abi/bind, eth: rely on getCode for sanity checks, not estimate and call
(cherry picked from commit 1580ec180414bce1e37acc614bc2445f778efb75)
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) {