Skip to content

Commit 2ec4b25

Browse files
authored
Merge pull request #329 from SurfingNerd/i172-service-transactions-garbage-collector
I172 service transactions garbage collector
2 parents 10c2ecb + 9b10f1c commit 2ec4b25

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/ethcore/src/client/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ impl Client {
15601560
}
15611561
}
15621562

1563-
/// Garbage collect invalid servive transactions from the transaction queue based on the given block header.
1563+
/// Garbage collect invalid service transactions from the transaction queue based on the given block header.
15641564
pub fn garbage_collect_in_queue(&self) {
15651565
let machine = self.engine().machine();
15661566

@@ -1589,7 +1589,7 @@ impl Client {
15891589
match machine.verify_transaction(tx.signed(), block_header, self) {
15901590
Ok(_) => true,
15911591
Err(e) => {
1592-
info!(target: "client", "collected garbage transaction from {:?}: {:?} reason: {:?}", tx.signed().sender(), tx.signed().hash, e);
1592+
trace!(target: "client", "collected garbage transaction from {:?}: {:?} reason: {:?}", tx.signed().sender(), tx.signed().hash, e);
15931593
false
15941594
},
15951595
});

crates/transaction-pool/src/pool.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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};
1818
use 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

Comments
 (0)