From a43785332f4e03cf49980ab201f8958dedc5a839 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Tue, 27 Jun 2023 00:26:45 +0800 Subject: [PATCH] eth/filters: dry Signed-off-by: jsvisa --- eth/filters/api.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index 112abf51f6..f11a5f551a 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -37,6 +37,7 @@ import ( var ( errInvalidTopic = errors.New("invalid topic(s)") errFilterNotFound = errors.New("filter not found") + errConnectDropped = errors.New("connection dropped") errInvalidToBlock = errors.New("log subscription does not support history block range") errInvalidFromBlock = errors.New("invalid from block") ) @@ -375,7 +376,7 @@ func (api *FilterAPI) histLogs(ctx context.Context, notifier notifier, rpcSub *r select { case <-notifier.Closed(): rmLogsSub.Unsubscribe() - return 0, errors.New("connection dropped") + return 0, errConnectDropped case err := <-rpcSub.Err(): // client send an unsubscribe request rmLogsSub.Unsubscribe() return 0, err @@ -402,7 +403,7 @@ func (api *FilterAPI) histLogs(ctx context.Context, notifier notifier, rpcSub *r for _, log := range rmLogs { select { case <-notifier.Closed(): - return head, errors.New("connection dropped") + return head, errConnectDropped case err := <-rpcSub.Err(): // client send an unsubscribe request return head, err default: