@@ -238,7 +238,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
238238 if ! config .NoLocals && config .Journal != "" {
239239 pool .journal = newTxJournal (config .Journal )
240240
241- if err := pool .journal .load (pool .AddLocal ); err != nil {
241+ if err := pool .journal .load (pool .AddLocals ); err != nil {
242242 log .Warn ("Failed to load transaction journal" , "err" , err )
243243 }
244244 if err := pool .journal .rotate (pool .local ()); err != nil {
@@ -444,9 +444,9 @@ func (pool *TxPool) Stop() {
444444 log .Info ("Transaction pool stopped" )
445445}
446446
447- // SubscribeTxPreEvent registers a subscription of TxPreEvent and
447+ // SubscribeTxPreEvent registers a subscription of TxsPreEvent and
448448// starts sending event to the given channel.
449- func (pool * TxPool ) SubscribeTxPreEvent (ch chan <- TxPreEvent ) event.Subscription {
449+ func (pool * TxPool ) SubscribeTxPreEvent (ch chan <- TxsPreEvent ) event.Subscription {
450450 return pool .scope .Track (pool .txFeed .Subscribe (ch ))
451451}
452452
@@ -653,7 +653,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
653653 log .Trace ("Pooled new executable transaction" , "hash" , hash , "from" , from , "to" , tx .To ())
654654
655655 // We've directly injected a replacement transaction, notify subsystems
656- go pool .txFeed .Send (TxPreEvent { tx })
656+ go pool .txFeed .Send (TxsPreEvent {types. Transactions { tx } })
657657
658658 return old != nil , nil
659659 }
@@ -715,7 +715,7 @@ func (pool *TxPool) journalTx(from common.Address, tx *types.Transaction) {
715715// promoteTx adds a transaction to the pending (processable) list of transactions.
716716//
717717// Note, this method assumes the pool lock is held!
718- func (pool * TxPool ) promoteTx (addr common.Address , hash common.Hash , tx * types.Transaction ) {
718+ func (pool * TxPool ) promoteTx (addr common.Address , hash common.Hash , tx * types.Transaction ) bool {
719719 // Try to insert the transaction into the pending queue
720720 if pool .pending [addr ] == nil {
721721 pool .pending [addr ] = newTxList (true )
@@ -729,7 +729,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
729729 pool .priced .Removed ()
730730
731731 pendingDiscardCounter .Inc (1 )
732- return
732+ return false
733733 }
734734 // Otherwise discard any previous transaction and mark this
735735 if old != nil {
@@ -746,8 +746,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
746746 // Set the potentially new pending nonce and notify any subsystems of the new tx
747747 pool .beats [addr ] = time .Now ()
748748 pool .pendingState .SetNonce (addr , tx .Nonce ()+ 1 )
749-
750- go pool .txFeed .Send (TxPreEvent {tx })
749+ return true
751750}
752751
753752// AddLocal enqueues a single transaction into the pool if it is valid, marking
@@ -907,6 +906,7 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) {
907906// future queue to the set of pending transactions. During this process, all
908907// invalidated transactions (low nonce, low balance) are deleted.
909908func (pool * TxPool ) promoteExecutables (accounts []common.Address ) {
909+ var promotedTxs types.Transactions
910910 // Gather all the accounts potentially needing updates
911911 if accounts == nil {
912912 accounts = make ([]common.Address , 0 , len (pool .queue ))
@@ -937,11 +937,16 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
937937 queuedNofundsCounter .Inc (1 )
938938 }
939939 // Gather all executable transactions and promote them
940- for _ , tx := range list .Ready (pool .pendingState .GetNonce (addr )) {
940+ txs := list .Ready (pool .pendingState .GetNonce (addr ))
941+ for _ , tx := range txs {
941942 hash := tx .Hash ()
942- log .Trace ("Promoting queued transaction" , "hash" , hash )
943- pool .promoteTx (addr , hash , tx )
943+ inserted := pool .promoteTx (addr , hash , tx )
944+ if inserted {
945+ log .Trace ("Promoting queued transaction" , "hash" , hash )
946+ promotedTxs = append (promotedTxs , tx )
947+ }
944948 }
949+
945950 // Drop all transactions over the allowed limit
946951 if ! pool .locals .contains (addr ) {
947952 for _ , tx := range list .Cap (int (pool .config .AccountQueue )) {
@@ -957,6 +962,11 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
957962 delete (pool .queue , addr )
958963 }
959964 }
965+ // Notify subsystem for new promoted transactions.
966+ if promotedTxs .Len () > 0 {
967+ pool .txFeed .Send (TxsPreEvent {promotedTxs })
968+ }
969+
960970 // If the pending limit is overflown, start equalizing allowances
961971 pending := uint64 (0 )
962972 for _ , list := range pool .pending {
0 commit comments