mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
ethclient: set from block to nil if q.from is nil
This commit is contained in:
parent
2079198ce2
commit
7f90a0fff7
1 changed files with 4 additions and 0 deletions
|
|
@ -479,6 +479,10 @@ func (ec *Client) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuer
|
|||
// TODO(s1na): Log subscription prohibits ToBlock being set.
|
||||
// This will be later re-allowed once it supports historical-only queries.
|
||||
arg["toBlock"] = nil
|
||||
// For subscriptions, if FromBlock is nil, we want only live logs, not historical logs from genesis
|
||||
if q.FromBlock == nil {
|
||||
arg["fromBlock"] = "latest"
|
||||
}
|
||||
sub, err := ec.c.EthSubscribe(ctx, ch, "logs", arg)
|
||||
if err != nil {
|
||||
// Defensively prefer returning nil interface explicitly on error-path, instead
|
||||
|
|
|
|||
Loading…
Reference in a new issue