mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
Co-authored-by: Undefinedor <wanghao@imwh.net>
This commit is contained in:
parent
f19813e3ee
commit
266cf85510
7 changed files with 3 additions and 44 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ func (api *privateAdminAPI) PeerEvents(ctx context.Context) (*rpc.Subscription,
|
|||
return
|
||||
case <-rpcSub.Err():
|
||||
return
|
||||
case <-notifier.Closed():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -269,8 +269,6 @@ func (t *TestAPI) Events(ctx context.Context) (*rpc.Subscription, error) {
|
|||
return
|
||||
case <-rpcSub.Err():
|
||||
return
|
||||
case <-notifier.Closed():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue