Change`txpool_beusPendingTransactions`:`numResults` from a required parameter to an optional parameter (#6708)

Signed-off-by: MASDXI <sirawitt42@gmail.com>
pull/6733/head
MASDXI 8 months ago committed by GitHub
parent 6dd3c84052
commit 9bf542732b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TxPoolBesuPendingTransactions.java
  3. 32
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/TxPoolBesuPendingTransactionsTest.java

@ -11,6 +11,7 @@
### Deprecations
### Additions and Improvements
- `txpool_besuPendingTransactions`change parameter `numResults` to optional parameter [#6708](https://github.com/hyperledger/besu/pull/6708)
- Extend `Blockchain` service [#6592](https://github.com/hyperledger/besu/pull/6592)
- Add bft-style blockperiodseconds transitions to Clique [#6596](https://github.com/hyperledger/besu/pull/6596)
- Add createemptyblocks transitions to Clique [#6608](https://github.com/hyperledger/besu/pull/6608)

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionPen
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.transaction.pool.PendingTransactionFilter.Filter;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import java.util.Collection;
@ -49,7 +50,10 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
final Integer limit = requestContext.getRequiredParameter(0, Integer.class);
final Collection<PendingTransaction> pendingTransactions =
transactionPool.getPendingTransactions();
final Integer limit =
requestContext.getOptionalParameter(0, Integer.class).orElse(pendingTransactions.size());
final List<Filter> filters =
requestContext
.getOptionalParameter(1, PendingTransactionsParams.class)
@ -57,7 +61,7 @@ public class TxPoolBesuPendingTransactions implements JsonRpcMethod {
.orElse(Collections.emptyList());
final Collection<Transaction> pendingTransactionsFiltered =
pendingTransactionFilter.reduce(transactionPool.getPendingTransactions(), filters, limit);
pendingTransactionFilter.reduce(pendingTransactions, filters, limit);
return new JsonRpcSuccessResponse(
requestContext.getRequest().getId(),

@ -70,7 +70,7 @@ public class TxPoolBesuPendingTransactionsTest {
final JsonRpcRequestContext request =
new JsonRpcRequestContext(
new JsonRpcRequest(
JSON_RPC_VERSION, TXPOOL_PENDING_TRANSACTIONS_METHOD, new Object[] {100}));
JSON_RPC_VERSION, TXPOOL_PENDING_TRANSACTIONS_METHOD, new Object[] {}));
final JsonRpcSuccessResponse actualResponse = (JsonRpcSuccessResponse) method.response(request);
final Set<TransactionPendingResult> result =
@ -120,6 +120,36 @@ public class TxPoolBesuPendingTransactionsTest {
@Test
public void shouldReturnPendingTransactionsWithFilter() {
final Map<String, String> fromFilter = new HashMap<>();
fromFilter.put(
"eq", listTrx.stream().findAny().get().getTransaction().getSender().toHexString());
final JsonRpcRequestContext request =
new JsonRpcRequestContext(
new JsonRpcRequest(
JSON_RPC_VERSION,
TXPOOL_PENDING_TRANSACTIONS_METHOD,
new Object[] {
null,
new PendingTransactionsParams(
fromFilter,
new HashMap<>(),
new HashMap<>(),
new HashMap<>(),
new HashMap<>(),
new HashMap<>())
}));
final JsonRpcSuccessResponse actualResponse = (JsonRpcSuccessResponse) method.response(request);
final Set<TransactionPendingResult> result =
(Set<TransactionPendingResult>) actualResponse.getResult();
assertThat(result.size()).isEqualTo(1);
}
@Test
public void shouldReturnPendingTransactionsWithLimitAndFilter() {
final Map<String, String> fromFilter = new HashMap<>();
fromFilter.put(
"eq", listTrx.stream().findAny().get().getTransaction().getSender().toHexString());

Loading…
Cancel
Save