mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
rm reorg param, re-use liveOnly
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
743cd0bc32
commit
be43dcebac
1 changed files with 11 additions and 13 deletions
|
|
@ -359,8 +359,12 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
|
|||
}()
|
||||
var (
|
||||
delivered uint64
|
||||
liveOnly bool
|
||||
reorged bool
|
||||
// liveOnly is true when all historical logs are delivered
|
||||
// and we switch-over to solely returning live logs.
|
||||
liveOnly bool
|
||||
// reorged is true when a reorg is detected.
|
||||
// Question is if its enough to keep one flag (liveMode).
|
||||
//reorged bool
|
||||
staleHash common.Hash
|
||||
)
|
||||
for {
|
||||
|
|
@ -379,20 +383,14 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
|
|||
if len(logs) == 0 {
|
||||
continue
|
||||
}
|
||||
if liveOnly {
|
||||
notifyLogsIf(notifier, rpcSub.ID, logs, nil)
|
||||
continue
|
||||
}
|
||||
reorgBlock := logs[0].BlockNumber
|
||||
if !reorged && reorgBlock <= delivered {
|
||||
if !liveOnly && reorgBlock <= delivered {
|
||||
logger.Info("Reorg detected", "reorgBlock", reorgBlock, "delivered", delivered)
|
||||
reorged = true
|
||||
liveOnly = true
|
||||
}
|
||||
if !reorged {
|
||||
if !liveOnly && logs[0].Removed && staleHash == (common.Hash{}) {
|
||||
// Reorg in future. Remember fork point.
|
||||
if logs[0].Removed && staleHash == (common.Hash{}) {
|
||||
staleHash = logs[0].BlockHash
|
||||
}
|
||||
staleHash = logs[0].BlockHash
|
||||
continue
|
||||
}
|
||||
if logs[0].Removed {
|
||||
|
|
@ -411,7 +409,7 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
|
|||
if len(logs) == 0 {
|
||||
continue
|
||||
}
|
||||
if reorged {
|
||||
if liveOnly {
|
||||
continue
|
||||
}
|
||||
if logs[0].BlockHash == staleHash {
|
||||
|
|
|
|||
Loading…
Reference in a new issue