mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
eth/filters: fix the issue of wrong check on from block
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
a43785332f
commit
a374b1b6ea
1 changed files with 19 additions and 15 deletions
|
|
@ -288,18 +288,25 @@ func (api *FilterAPI) logs(ctx context.Context, notifier notifier, rpcSub *rpc.S
|
|||
return errInvalidToBlock
|
||||
}
|
||||
|
||||
switch from {
|
||||
case rpc.LatestBlockNumber:
|
||||
// do live filter only
|
||||
if from == rpc.LatestBlockNumber {
|
||||
return api.liveLogs(ctx, notifier, rpcSub, crit)
|
||||
case rpc.SafeBlockNumber, rpc.FinalizedBlockNumber:
|
||||
}
|
||||
|
||||
if from == rpc.SafeBlockNumber || from == rpc.FinalizedBlockNumber {
|
||||
header, err := api.sys.backend.HeaderByNumber(ctx, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
from = rpc.BlockNumber(header.Number.Int64())
|
||||
}
|
||||
if from < 0 {
|
||||
return errInvalidFromBlock
|
||||
}
|
||||
|
||||
go func() {
|
||||
// do historical sync first
|
||||
_, err := api.histLogs(ctx, notifier, rpcSub, header.Number.Int64(), crit)
|
||||
_, err := api.histLogs(ctx, notifier, rpcSub, int64(from), crit)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -307,9 +314,6 @@ func (api *FilterAPI) logs(ctx context.Context, notifier notifier, rpcSub *rpc.S
|
|||
api.liveLogs(ctx, notifier, rpcSub, crit)
|
||||
}()
|
||||
return nil
|
||||
default:
|
||||
return errInvalidFromBlock
|
||||
}
|
||||
}
|
||||
|
||||
// liveLogs only retrieves live logs
|
||||
|
|
|
|||
Loading…
Reference in a new issue