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 (
|
var (
|
||||||
delivered uint64
|
delivered uint64
|
||||||
|
// liveOnly is true when all historical logs are delivered
|
||||||
|
// and we switch-over to solely returning live logs.
|
||||||
liveOnly bool
|
liveOnly bool
|
||||||
reorged bool
|
// reorged is true when a reorg is detected.
|
||||||
|
// Question is if its enough to keep one flag (liveMode).
|
||||||
|
//reorged bool
|
||||||
staleHash common.Hash
|
staleHash common.Hash
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
|
|
@ -379,20 +383,14 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
|
||||||
if len(logs) == 0 {
|
if len(logs) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if liveOnly {
|
|
||||||
notifyLogsIf(notifier, rpcSub.ID, logs, nil)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
reorgBlock := logs[0].BlockNumber
|
reorgBlock := logs[0].BlockNumber
|
||||||
if !reorged && reorgBlock <= delivered {
|
if !liveOnly && reorgBlock <= delivered {
|
||||||
logger.Info("Reorg detected", "reorgBlock", reorgBlock, "delivered", 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.
|
// Reorg in future. Remember fork point.
|
||||||
if logs[0].Removed && staleHash == (common.Hash{}) {
|
|
||||||
staleHash = logs[0].BlockHash
|
staleHash = logs[0].BlockHash
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if logs[0].Removed {
|
if logs[0].Removed {
|
||||||
|
|
@ -411,7 +409,7 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
|
||||||
if len(logs) == 0 {
|
if len(logs) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if reorged {
|
if liveOnly {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if logs[0].BlockHash == staleHash {
|
if logs[0].BlockHash == staleHash {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue