mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
fix null result unmarshal
This commit is contained in:
parent
d8d8669271
commit
e7dd1a2730
1 changed files with 11 additions and 11 deletions
|
|
@ -80,12 +80,12 @@ type BatchElem struct {
|
||||||
// A value of this type can a JSON-RPC request, notification, successful response or
|
// A value of this type can a JSON-RPC request, notification, successful response or
|
||||||
// error response. Which one it is depends on the fields.
|
// error response. Which one it is depends on the fields.
|
||||||
type jsonrpcMessage struct {
|
type jsonrpcMessage struct {
|
||||||
Version string `json:"jsonrpc"`
|
Version string `json:"jsonrpc"`
|
||||||
ID json.RawMessage `json:"id,omitempty"`
|
ID json.RawMessage `json:"id,omitempty"`
|
||||||
Method string `json:"method,omitempty"`
|
Method string `json:"method,omitempty"`
|
||||||
Params json.RawMessage `json:"params,omitempty"`
|
Params json.RawMessage `json:"params,omitempty"`
|
||||||
Error *jsonError `json:"error,omitempty"`
|
Error *jsonError `json:"error,omitempty"`
|
||||||
Result json.RawMessage `json:"result,omitempty"`
|
Result *json.RawMessage `json:"result,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg *jsonrpcMessage) isNotification() bool {
|
func (msg *jsonrpcMessage) isNotification() bool {
|
||||||
|
|
@ -310,10 +310,10 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str
|
||||||
return err
|
return err
|
||||||
case resp.Error != nil:
|
case resp.Error != nil:
|
||||||
return resp.Error
|
return resp.Error
|
||||||
case len(resp.Result) == 0:
|
case resp.Result == nil:
|
||||||
return ErrNoResult
|
return ErrNoResult
|
||||||
default:
|
default:
|
||||||
return json.Unmarshal(resp.Result, &result)
|
return json.Unmarshal(*resp.Result, &result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -381,11 +381,11 @@ func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
|
||||||
elem.Error = resp.Error
|
elem.Error = resp.Error
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(resp.Result) == 0 {
|
if resp.Result == nil {
|
||||||
elem.Error = ErrNoResult
|
elem.Error = ErrNoResult
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
elem.Error = json.Unmarshal(resp.Result, elem.Result)
|
elem.Error = json.Unmarshal(*resp.Result, elem.Result)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -665,7 +665,7 @@ func (c *Client) handleResponse(msg *jsonrpcMessage) {
|
||||||
op.err = msg.Error
|
op.err = msg.Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if op.err = json.Unmarshal(msg.Result, &op.sub.subid); op.err == nil {
|
if op.err = json.Unmarshal(*msg.Result, &op.sub.subid); op.err == nil {
|
||||||
go op.sub.start()
|
go op.sub.start()
|
||||||
c.subs[op.sub.subid] = op.sub
|
c.subs[op.sub.subid] = op.sub
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue