Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
Sina Mahmoodi 2023-08-29 17:32:42 +02:00 committed by jsvisa
parent 7f30c9e4d1
commit 3aa0f5bad2

View file

@ -353,6 +353,10 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
// Compose and notify the logs from liveLogs and histLogs // Compose and notify the logs from liveLogs and histLogs
go func() { go func() {
defer func() {
liveLogsSub.Unsubscribe()
cancel()
}()
var ( var (
delivered uint64 delivered uint64
liveOnly bool liveOnly bool
@ -364,7 +368,6 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
case err := <-histDone: case err := <-histDone:
if err != nil { if err != nil {
logger.Warn("History logs delivery failed", "err", err) logger.Warn("History logs delivery failed", "err", err)
liveLogsSub.Unsubscribe()
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
@ -426,12 +429,8 @@ func (api *FilterAPI) histLogs(notifier notifier, rpcSub *rpc.Subscription, from
// Assuming batch = all logs of a single block // Assuming batch = all logs of a single block
delivered = logs[0].BlockNumber delivered = logs[0].BlockNumber
case <-rpcSub.Err(): // client send an unsubscribe request case <-rpcSub.Err(): // client send an unsubscribe request
liveLogsSub.Unsubscribe()
cancel()
return return
case <-notifier.Closed(): // connection dropped case <-notifier.Closed(): // connection dropped
liveLogsSub.Unsubscribe()
cancel()
return return
} }
} }