@Override
  public void selectTransactions(final PendingTransactions.TransactionSelector selector) {
    final Map<Byte, List<SenderPendingTransactions>> candidateTxsByScore;
    synchronized (this) {
      // since selecting transactions for block creation is a potential long operation
      // we want to avoid to keep the lock for all the process, but we just lock to get
      // the candidate transactions
      candidateTxsByScore = prioritizedTransactions.getByScore();
    }

    selection:
    for (final var entry : candidateTxsByScore.entrySet()) {
      LOG.trace("Evaluating txs with score {}", entry.getKey());

      for (final var senderTxs : entry.getValue()) {
        LOG.trace("Evaluating sender txs {}", senderTxs);

        for (final var candidatePendingTx : senderTxs.pendingTransactions()) {
          final var selectionResult = selector.evaluateTransaction(candidatePendingTx);

          LOG.atTrace()
              .setMessage("Selection result {} for transaction {}")
              .addArgument(selectionResult)
              .addArgument(candidatePendingTx::toTraceLog)
              .log();

          if (selectionResult.discard()) {
            ethScheduler.scheduleTxWorkerTask(
                () -> {
                  synchronized (this) {
                    prioritizedTransactions.remove(candidatePendingTx, INVALIDATED);
                  }
                });
            logDiscardedTransaction(candidatePendingTx, selectionResult);
          } else if (selectionResult.penalize()) {
            ethScheduler.scheduleTxWorkerTask(
                () -> {
                  synchronized (this) {
                    prioritizedTransactions.penalize(candidatePendingTx);
                  }
                });
            LOG.atTrace()
                .setMessage("Transaction {} penalized")
                .addArgument(candidatePendingTx::toTraceLog)
                .log();
          }

          if (selectionResult.stop()) {
            LOG.trace("Stopping selection");
            break selection;
          }
        }
      }
    }
  }
Rebuild the txpool for a sender according to the specified nonce. This is used in case the
account nonce has seen by the txpool is not the correct one (see {@link
LayeredPendingTransactions#hasAccountNonceDisparity(PendingTransaction, long)} for when this
could happen). It works by removing all the txs for the sender and re-adding them using the
passed nonce.

@param sender the sender for which rebuild the txpool
@param stateSenderNonce the world state account nonce to use in the txpool for the sender
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java