Skip to content

Commit

Permalink
concats streams
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Florentine <[email protected]>
  • Loading branch information
jflo committed Nov 14, 2023
1 parent 35bb18f commit 6b849e6
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,20 @@ private ValidationResult<TransactionInvalidReason> addTransaction(
metrics.incrementRejected(isLocal, hasPriority, TRANSACTION_ALREADY_KNOWN, "txpool");
return ValidationResult.invalid(TRANSACTION_ALREADY_KNOWN);
}
Transaction toAdd = transaction;

final ValidationResultAndAccount validationResult =
validateTransaction(toAdd, isLocal, hasPriority);
validateTransaction(transaction, isLocal, hasPriority);

if (validationResult.result.isValid()) {
final TransactionAddedResult status =
pendingTransactions.addTransaction(
PendingTransaction.newPendingTransaction(toAdd, isLocal, hasPriority),
PendingTransaction.newPendingTransaction(transaction, isLocal, hasPriority),
validationResult.maybeAccount);
if (status.isSuccess()) {
LOG.atTrace()
.setMessage("Added {} transaction {}")
.addArgument(() -> isLocal ? "local" : "remote")
.addArgument(toAdd::toTraceLog)
.addArgument(transaction::toTraceLog)
.log();
} else {
final var rejectReason =
Expand All @@ -264,7 +263,7 @@ private ValidationResult<TransactionInvalidReason> addTransaction(
});
LOG.atTrace()
.setMessage("Transaction {} rejected reason {}")
.addArgument(toAdd::toTraceLog)
.addArgument(transaction::toTraceLog)
.addArgument(rejectReason)
.log();
metrics.incrementRejected(isLocal, hasPriority, rejectReason, "txpool");
Expand All @@ -273,7 +272,7 @@ private ValidationResult<TransactionInvalidReason> addTransaction(
} else {
LOG.atTrace()
.setMessage("Discard invalid transaction {}, reason {}")
.addArgument(toAdd::toTraceLog)
.addArgument(transaction::toTraceLog)
.addArgument(validationResult.result::getInvalidReason)
.log();
metrics.incrementRejected(
Expand Down Expand Up @@ -375,12 +374,9 @@ private void reAddTransactions(final List<Transaction> reAddTransactions) {
if (!reAddTransactions.isEmpty()) {
// if adding a blob tx, and it is missing its blob, is a re-org and we should restore the blob
// from cache.
List<Transaction> restoredTransactions =
reAddTransactions.stream()
.map(t -> pendingTransactions.restoreBlob(t).orElse(t))
.toList();
var txsByOrigin =
restoredTransactions.stream()
reAddTransactions.stream()
.map(t -> pendingTransactions.restoreBlob(t).orElse(t))
.collect(Collectors.partitioningBy(tx -> isLocalSender(tx.getSender())));
var reAddLocalTxs = txsByOrigin.get(true);
var reAddRemoteTxs = txsByOrigin.get(false);
Expand Down

0 comments on commit 6b849e6

Please sign in to comment.