From 266cf85510d9e46198c8d5850ccecf43e14b4f31 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Tue, 6 May 2025 09:44:20 +0800 Subject: [PATCH] rpc: remove deprecated method Notifier.Closed #29162 (#1022) Co-authored-by: Undefinedor --- eth/api_tracer.go | 18 ++---------------- eth/downloader/api.go | 3 --- eth/filters/api.go | 11 ----------- node/api.go | 2 -- p2p/simulations/http_test.go | 2 -- rpc/subscription.go | 6 ------ rpc/testservice_test.go | 5 +---- 7 files changed, 3 insertions(+), 44 deletions(-) diff --git a/eth/api_tracer.go b/eth/api_tracer.go index cd172d4095..2b1cb519fb 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -263,11 +263,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl task.results[i] = &txTraceResult{Result: res} } // Stream the result back to the user or abort on teardown - select { - case results <- task: - case <-notifier.Closed(): - return - } + results <- task } }() } @@ -299,12 +295,6 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl }() // Feed all the blocks both into the tracer, as well as fast process concurrently for number = start.NumberU64() + 1; number <= end.NumberU64(); number++ { - // Stop tracing if interruption was requested - select { - case <-notifier.Closed(): - return - default: - } // Print progress logs if long enough time elapsed if time.Since(logged) > 8*time.Second { if number > origin { @@ -325,11 +315,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl if number > origin { txs := block.Transactions() - select { - case tasks <- &blockTraceTask{statedb: statedb.Copy(), block: block, rootref: proot, results: make([]*txTraceResult, len(txs))}: - case <-notifier.Closed(): - return - } + tasks <- &blockTraceTask{statedb: statedb.Copy(), block: block, rootref: proot, results: make([]*txTraceResult, len(txs))} traced += uint64(len(txs)) } feeCapacity := state.GetTRC21FeeCapacityFromState(statedb) diff --git a/eth/downloader/api.go b/eth/downloader/api.go index f1de94a99d..5508a55550 100644 --- a/eth/downloader/api.go +++ b/eth/downloader/api.go @@ -109,9 +109,6 @@ func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, case <-rpcSub.Err(): sub.Unsubscribe() return - case <-notifier.Closed(): - sub.Unsubscribe() - return } } }() diff --git a/eth/filters/api.go b/eth/filters/api.go index 7762ee1992..333a3bea3b 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -29,8 +29,6 @@ import ( "github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/core/types" - - // "github.com/XinFinOrg/XDPoSChain/ethdb" "github.com/XinFinOrg/XDPoSChain/rpc" ) @@ -167,9 +165,6 @@ func (api *FilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscrip case <-rpcSub.Err(): pendingTxSub.Unsubscribe() return - case <-notifier.Closed(): - pendingTxSub.Unsubscribe() - return } } }() @@ -232,9 +227,6 @@ func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) { case <-rpcSub.Err(): headersSub.Unsubscribe() return - case <-notifier.Closed(): - headersSub.Unsubscribe() - return } } }() @@ -270,9 +262,6 @@ func (api *FilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subsc case <-rpcSub.Err(): // client send an unsubscribe request logsSub.Unsubscribe() return - case <-notifier.Closed(): // connection dropped - logsSub.Unsubscribe() - return } } }() diff --git a/node/api.go b/node/api.go index 9453474aab..1c16a35c97 100644 --- a/node/api.go +++ b/node/api.go @@ -147,8 +147,6 @@ func (api *privateAdminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription, return case <-rpcSub.Err(): return - case <-notifier.Closed(): - return } } }() diff --git a/p2p/simulations/http_test.go b/p2p/simulations/http_test.go index 51678d64dd..8af13d2db3 100644 --- a/p2p/simulations/http_test.go +++ b/p2p/simulations/http_test.go @@ -269,8 +269,6 @@ func (t *TestAPI) Events(ctx context.Context) (*rpc.Subscription, error) { return case <-rpcSub.Err(): return - case <-notifier.Closed(): - return } } }() diff --git a/rpc/subscription.go b/rpc/subscription.go index 9ca3bed595..9e400c8b60 100644 --- a/rpc/subscription.go +++ b/rpc/subscription.go @@ -145,12 +145,6 @@ func (n *Notifier) Notify(id ID, data any) error { return nil } -// Closed returns a channel that is closed when the RPC connection is closed. -// Deprecated: use subscription error channel -func (n *Notifier) Closed() <-chan interface{} { - return n.h.conn.closed() -} - // takeSubscription returns the subscription (if one has been created). No subscription can // be created after this call. func (n *Notifier) takeSubscription() *Subscription { diff --git a/rpc/testservice_test.go b/rpc/testservice_test.go index a426d018f2..cc61663bf0 100644 --- a/rpc/testservice_test.go +++ b/rpc/testservice_test.go @@ -195,10 +195,7 @@ func (s *notificationTestService) SomeSubscription(ctx context.Context, n, val i return } } - select { - case <-notifier.Closed(): - case <-subscription.Err(): - } + <-subscription.Err() if s.unsubscribed != nil { s.unsubscribed <- string(subscription.ID) }