diff options
Diffstat (limited to 'eth')
-rw-r--r-- | eth/api.go | 15 | ||||
-rw-r--r-- | eth/filters/filter_system.go | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/eth/api.go b/eth/api.go index 4ebc9b2a0..2c84cf471 100644 --- a/eth/api.go +++ b/eth/api.go @@ -52,6 +52,15 @@ import ( "golang.org/x/net/context" ) +// ErrNoCode is returned by call and transact operations for which the requested +// recipient contract to operate on does not exist in the state db or does not +// have any code associated with it (i.e. suicided). +// +// Please note, this error string is part of the RPC API and is expected by the +// native contract bindings to signal this particular error. Do not change this +// as it will break all dependent code! +var ErrNoCode = errors.New("no contract code at given address") + const defaultGas = uint64(90000) // blockByNumber is a commonly used helper function which retrieves and returns @@ -705,6 +714,12 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st } stateDb = stateDb.Copy() + // If there's no code to interact with, respond with an appropriate error + if args.To != nil { + if code := stateDb.GetCode(*args.To); len(code) == 0 { + return "0x", nil, ErrNoCode + } + } // Retrieve the account state object to interact with var from *state.StateObject if args.From == (common.Address{}) { diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index 29968530a..4343dfa21 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -164,7 +164,7 @@ func (fs *FilterSystem) filterLoop() { fs.filterMu.RLock() for _, filter := range fs.logFilters { if filter.LogCallback != nil && !filter.created.After(event.Time) { - for _, removedLog := range ev.Logs { + for _, removedLog := range filter.FilterLogs(ev.Logs) { filter.LogCallback(removedLog, true) } } |