Patch for concurrent iterator & others (onto v1.11.6) #386
@ -320,7 +320,14 @@ func (ec *Client) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, err
|
|||||||
// SubscribeNewHead subscribes to notifications about the current blockchain head
|
// SubscribeNewHead subscribes to notifications about the current blockchain head
|
||||||
// on the given channel.
|
// on the given channel.
|
||||||
func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
|
func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) {
|
||||||
return ec.c.EthSubscribe(ctx, ch, "newHeads")
|
sub, err := ec.c.EthSubscribe(ctx, ch, "newHeads")
|
||||||
|
if err != nil {
|
||||||
|
// Defensively prefer returning nil interface explicitly on error-path, instead
|
||||||
|
// of letting default golang behavior wrap it with non-nil interface that stores
|
||||||
|
// nil concrete type value.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sub, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// State Access
|
// State Access
|
||||||
@ -389,7 +396,14 @@ func (ec *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuer
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return ec.c.EthSubscribe(ctx, ch, "logs", arg)
|
sub, err := ec.c.EthSubscribe(ctx, ch, "logs", arg)
|
||||||
|
if err != nil {
|
||||||
|
// Defensively prefer returning nil interface explicitly on error-path, instead
|
||||||
|
// of letting default golang behavior wrap it with non-nil interface that stores
|
||||||
|
// nil concrete type value.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return sub, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
|
func toFilterArg(q ethereum.FilterQuery) (interface{}, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user