eth/filters: history logs should be requested > head

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2023-07-25 15:50:43 +08:00
parent b9f695cef8
commit 77aa3cc663

View file

@ -366,6 +366,7 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
return return
} }
// Else historical logs are all delivered, let's switch to live mode // Else historical logs are all delivered, let's switch to live mode
logger.Info("History logs delivery finished, and now enter into live mode", "delivered", delivered)
liveOnly = true liveOnly = true
histLogs = nil histLogs = nil
case logs := <-liveLogs: case logs := <-liveLogs:
@ -441,7 +442,8 @@ func (api *FilterAPI) doHistLogs(from int64, crit FilterCriteria, histLogs chan<
return errors.New("unexpected error: no header block found") return errors.New("unexpected error: no header block found")
} }
head := header.Number.Int64() head := header.Number.Int64()
if from >= head { if from > head {
logger.Info("Finish historical sync", "from", from, "head", head)
return nil return nil
} }
@ -459,7 +461,7 @@ func (api *FilterAPI) doHistLogs(from int64, crit FilterCriteria, histLogs chan<
case err := <-errChan: case err := <-errChan:
// Range filter is done or error, let's also stop the reorgLogs subscribe // Range filter is done or error, let's also stop the reorgLogs subscribe
if err != nil { if err != nil {
logger.Error("error while fetching historical logs", "err", err) logger.Error("Error while fetching historical logs", "err", err)
return err return err
} }
break FORLOOP break FORLOOP