From 4f973dbd1057372357d44585feefa337c87fd4ea Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 28 Sep 2021 22:01:19 -0700 Subject: [PATCH] add pending txn subscription support (#3885) --- core/events.go | 2 +- core/tx_pool.go | 8 ++++---- rpc/filters/filter_system.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/events.go b/core/events.go index 9a61c6243..fc25ae9e6 100644 --- a/core/events.go +++ b/core/events.go @@ -22,7 +22,7 @@ import ( ) // NewTxsEvent is posted when a batch of transactions enter the transaction pool. -type NewTxsEvent struct{ Txs []*types.Transaction } +type NewTxsEvent struct{ Txs []types.PoolTransaction } // PendingLogsEvent is posted pre mining and notifies of pending logs. type PendingLogsEvent struct { diff --git a/core/tx_pool.go b/core/tx_pool.go index 1e1babe53..b0a37017e 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1290,7 +1290,7 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) { // invalidated transactions (low nonce, low balance) are deleted. func (pool *TxPool) promoteExecutables(accounts []common.Address) { // Track the promoted transactions to broadcast them at once - var promoted types.PoolTransactions + var promoted []types.PoolTransaction logger := utils.Logger().With().Stack().Logger() // Gather all the accounts potentially needing updates @@ -1353,9 +1353,9 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) { } } // Notify subsystem for new promoted transactions. - //if len(promoted) > 0 { - // go pool.txFeed.Send(NewTxsEvent{promoted}) - //} + if len(promoted) > 0 { + go pool.txFeed.Send(NewTxsEvent{promoted}) + } // If the pending limit is overflown, start equalizing allowances pending := uint64(0) for _, list := range pool.pending { diff --git a/rpc/filters/filter_system.go b/rpc/filters/filter_system.go index 714bcc7d6..6593109d8 100644 --- a/rpc/filters/filter_system.go +++ b/rpc/filters/filter_system.go @@ -348,7 +348,7 @@ func (es *EventSystem) broadcast(filters filterIndex, ev interface{}) { case core.NewTxsEvent: hashes := make([]common.Hash, 0, len(e.Txs)) for _, tx := range e.Txs { - hashes = append(hashes, tx.HashByType()) + hashes = append(hashes, tx.Hash()) } for _, f := range filters[PendingTransactionsSubscription] { f.hashes <- hashes