1414// You should have received a copy of the GNU General Public License
1515// along with Parity. If not, see <http://www.gnu.org/licenses/>.
1616
17- use log:: { info , trace, warn} ;
17+ use log:: { debug , trace, warn} ;
1818use std:: {
1919 collections:: { hash_map, BTreeSet , HashMap } ,
2020 slice,
@@ -236,11 +236,12 @@ where
236236 }
237237 }
238238
239- /// Performs garbage collection of the pool for free service transactions.
240- /// Removes transaction that are not valid anymore.
241- /// The process executes listener calls.
242- pub fn garbage_collect < F : Fn ( & T ) -> bool > ( & mut self , service_transaction_check : F ) {
243- if self . best_transactions . is_empty ( ) {
239+ /// Performs garbage collection of the pool for free service transactions (zero gas transactions).
240+ /// Only checks lowest nonce.
241+ /// inject "should_keep_function" to decide.
242+ /// The process executes listener calls for invalid transactions.
243+ pub fn garbage_collect < F : Fn ( & T ) -> bool > ( & mut self , should_keep_function : F ) {
244+ if self . transactions . is_empty ( ) {
244245 return ;
245246 }
246247
@@ -249,7 +250,7 @@ where
249250 for sender in self . transactions . iter ( ) {
250251 for tx in sender. 1 . iter_transactions ( ) {
251252 if tx. transaction . has_zero_gas_price ( ) {
252- if service_transaction_check ( & tx. transaction ) {
253+ if ! should_keep_function ( & tx. transaction ) {
253254 txs_to_remove. push ( tx. hash ( ) . clone ( ) ) ;
254255 }
255256 } else {
@@ -264,7 +265,7 @@ where
264265 return ;
265266 }
266267
267- info ! (
268+ debug ! (
268269 "Garbage collection: removing invalid {} service transactions from pool." ,
269270 txs_to_remove. len( )
270271 ) ;
0 commit comments