// loop is the transaction pool's main event loop, waiting for and reacting to
// outside blockchain events as well as for various reporting and transaction
// eviction events.
loop is the transaction pool's main event loop, waiting for and reacting to
outside blockchain events as well as for various reporting and transaction
eviction events.
// loop is the transaction pool ' s main event loop waiting for and reacting to // outside blockchain events as well as for various reporting and transaction // eviction events .
func (nPool *NormalTxPool) loop() {
	defer nPool.wg.Done()
	delteTime := time.NewTicker(10 * time.Second)
	defer delteTime.Stop()
	head := nPool.chain.CurrentBlock()
	for {
		select {
		case ev := <-nPool.chainHeadCh:
			if ev.Block != nil {
				nPool.mu.Lock()
				nPool.reset(head.Header(), ev.Block.Header())
				head = ev.Block
				h := head.Number().Uint64() - 1
				if txlist, ok := nPool.mapHighttx[h]; ok {
					for _, n := range txlist {
						nPool.deletnTx(n)
					}
				}
				delete(nPool.mapHighttx, h)
				txpoolCache.DeleteTxCache(head.Header().HashNoSignsAndNonce(), head.Number().Uint64())
				nPool.mu.Unlock()
				nPool.getPendingTx() 
			}
			 Be unsubscribed due to system stopped
		case <-nPool.chainHeadSub.Err():
			return
		case <-delteTime.C:
			nPool.mu.Lock()
			nPool.blockTiming() 
			nPool.mu.Unlock()
			nPool.getPendingTx()
		}
	}
}
func ( nPool * NormalTxPool ) loop ( ) { defer nPool . wg . Done ( ) delteTime := time . NewTicker ( 10 * time . Second ) defer delteTime . Stop ( ) head := nPool . chain . CurrentBlock ( ) for { select { case ev := <- nPool . chainHeadCh : if ev . Block != nil { nPool . mu . Lock ( ) nPool . reset ( head . Header ( ) , ev . Block . Header ( ) ) head = ev . Block h := head . Number ( ) . Uint64 ( ) - 1 if txlist , ok := nPool . mapHighttx [ h ] ; ok { for _ , n := range txlist { nPool . deletnTx ( n ) } } delete ( nPool . mapHighttx , h ) txpoolCache . DeleteTxCache ( head . Header ( ) . HashNoSignsAndNonce ( ) , head . Number ( ) . Uint64 ( ) ) nPool . mu . Unlock ( ) nPool . getPendingTx ( ) } case <- nPool . chainHeadSub . Err ( ) : return case <- delteTime . C : nPool . mu . Lock ( ) nPool . blockTiming ( ) nPool . mu . Unlock ( ) nPool . getPendingTx ( ) } } }
loop is the transaction pool's main event loop, waiting for and reacting to
outside blockchain events as well as for various reporting and transaction
eviction events.
loop is the transaction pool ' s main event loop waiting for and reacting to outside blockchain events as well as for various reporting and transaction eviction events .
// Track the previous head headers for transaction reorgs // Keep waiting for and reacting to the various events // Handle ChainHeadEvent // // Be unsubscribed due to system stopped //