mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
accounts/abi/bind: now using pending state of code for pending calls
This commit is contained in:
parent
79de990d2e
commit
2f5413bbce
1 changed files with 16 additions and 11 deletions
|
|
@ -119,17 +119,22 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
|
||||||
opts = new(CallOpts)
|
opts = new(CallOpts)
|
||||||
}
|
}
|
||||||
// Make sure we have a contract to operate on, and bail out otherwise
|
// Make sure we have a contract to operate on, and bail out otherwise
|
||||||
if (opts.Pending && atomic.LoadUint32(&c.pendingHasCode) == 0) || (!opts.Pending && atomic.LoadUint32(&c.latestHasCode) == 0) {
|
var code []byte
|
||||||
if code, err := c.backend.CodeAt(opts.Context, c.address, nil); err != nil {
|
var err error
|
||||||
return err
|
if opts.Pending && atomic.LoadUint32(&c.pendingHasCode) == 0 {
|
||||||
} else if len(code) == 0 {
|
code, err = c.backend.PendingCodeAt(opts.Context, c.address)
|
||||||
return ErrNoCode
|
} else if !opts.Pending && atomic.LoadUint32(&c.latestHasCode) == 0 {
|
||||||
}
|
code, err = c.backend.CodeAt(opts.Context, c.address, nil)
|
||||||
if opts.Pending {
|
}
|
||||||
atomic.StoreUint32(&c.pendingHasCode, 1)
|
if err != nil {
|
||||||
} else {
|
return err
|
||||||
atomic.StoreUint32(&c.latestHasCode, 1)
|
} else if len(code) == 0 {
|
||||||
}
|
return ErrNoCode
|
||||||
|
}
|
||||||
|
if opts.Pending {
|
||||||
|
atomic.StoreUint32(&c.pendingHasCode, 1)
|
||||||
|
} else {
|
||||||
|
atomic.StoreUint32(&c.latestHasCode, 1)
|
||||||
}
|
}
|
||||||
// Pack the input, call and unpack the results
|
// Pack the input, call and unpack the results
|
||||||
input, err := c.abi.Pack(method, params...)
|
input, err := c.abi.Pack(method, params...)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue