From ee69279a9485f3e2ea05f0fe450456e752fbc79f Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Mon, 28 Oct 2024 00:40:33 +0100 Subject: [PATCH] Add getPendingTransactions to TransactionPoolService (#7813) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + .../besu/services/TransactionPoolServiceImpl.java | 8 ++++++++ plugin-api/build.gradle | 2 +- .../transactionpool/TransactionPoolService.java | 10 ++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f862ed866fe..8bfb4ebd3ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fine tune already seen txs tracker when a tx is removed from the pool [#7755](https://github.com/hyperledger/besu/pull/7755) - Create and publish Besu BOM (Bill of Materials) [#7615](https://github.com/hyperledger/besu/pull/7615) - Update Java dependencies [#7786](https://github.com/hyperledger/besu/pull/7786) +- Add a method to get all the transaction in the pool, to the `TransactionPoolService`, to easily access the transaction pool content from plugins [#7813](https://github.com/hyperledger/besu/pull/7813) ### Bug fixes diff --git a/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java b/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java index 16d033ac9e4..b720b60b7c1 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/TransactionPoolServiceImpl.java @@ -14,9 +14,12 @@ */ package org.hyperledger.besu.services; +import org.hyperledger.besu.datatypes.PendingTransaction; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.plugin.services.transactionpool.TransactionPoolService; +import java.util.Collection; + /** Service to enable and disable the transaction pool. */ public class TransactionPoolServiceImpl implements TransactionPoolService { @@ -40,4 +43,9 @@ public void disableTransactionPool() { public void enableTransactionPool() { transactionPool.setEnabled(); } + + @Override + public Collection getPendingTransactions() { + return transactionPool.getPendingTransactions(); + } } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index d400e5abe22..0dbca077ab4 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -71,7 +71,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = '1VIGlJuGiaEVUksIjTTHDt7SIjjJE9+DU8rYk/ze3XM=' + knownHash = 'G3cpM0HGYp4G1u6dN2CRZiEEsgce6jy9rkIlT1blUb4=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/transactionpool/TransactionPoolService.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/transactionpool/TransactionPoolService.java index 01b1f5768b3..ba30fa80fff 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/transactionpool/TransactionPoolService.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/transactionpool/TransactionPoolService.java @@ -14,8 +14,11 @@ */ package org.hyperledger.besu.plugin.services.transactionpool; +import org.hyperledger.besu.datatypes.PendingTransaction; import org.hyperledger.besu.plugin.services.BesuService; +import java.util.Collection; + /** Service to enable and disable the transaction pool. */ public interface TransactionPoolService extends BesuService { /** Enables the transaction pool. */ @@ -23,4 +26,11 @@ public interface TransactionPoolService extends BesuService { /** Disables the transaction pool. */ void enableTransactionPool(); + + /** + * Returns the collection of pending transactions. + * + * @return a collection of pending transactions + */ + Collection getPendingTransactions(); }