From a2a323613370e434fa22fbb9c26b31f16b0b3824 Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Fri, 6 Oct 2023 17:10:42 +1100 Subject: [PATCH] Revert plugin interface to return object instead of list Signed-off-by: Gabriel-Trintinalia --- .../txselection/BlockTransactionSelector.java | 11 ++++++++++- plugin-api/build.gradle | 2 +- .../txselection/TransactionSelectorFactory.java | 4 +--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java index a5d168ae8c1..1bf34f71cf7 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java @@ -46,6 +46,7 @@ import java.util.Optional; import java.util.concurrent.CancellationException; import java.util.function.Supplier; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -118,7 +119,8 @@ public BlockTransactionSelector( transactionPool); transactionSelectors = createTransactionSelectors(blockSelectionContext); externalTransactionSelectors = - transactionSelectorFactory.map(TransactionSelectorFactory::create).orElse(List.of()); + createExternalTransactionSelectors( + transactionSelectorFactory.map(List::of).orElseGet(List::of)); } /** @@ -324,4 +326,11 @@ private List createTransactionSelectors( new BlobPriceTransactionSelector(context), new ProcessingResultTransactionSelector(context)); } + + private List createExternalTransactionSelectors( + final List transactionSelectorFactory) { + return transactionSelectorFactory.stream() + .map(TransactionSelectorFactory::create) + .collect(Collectors.toList()); + } } diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index b29b2c0e78e..388115bfe50 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -69,7 +69,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 = 'IPqcFdM1uy+ZDbcvzsKxMIrzhP9VoaSeanhBOLtbhfE=' + knownHash = 'n7Nr+J78ImUPzFxTa6Ig5C7Ul4nSM+AZnsLGQY0dL60=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionSelectorFactory.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionSelectorFactory.java index 81fb2a5512b..1b4dbac5ca5 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionSelectorFactory.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/services/txselection/TransactionSelectorFactory.java @@ -17,8 +17,6 @@ import org.hyperledger.besu.plugin.Unstable; -import java.util.List; - /** Interface for a factory that creates transaction selectors */ @Unstable public interface TransactionSelectorFactory { @@ -28,5 +26,5 @@ public interface TransactionSelectorFactory { * * @return the transaction selector list */ - List create(); + TransactionSelector create(); }