Skip to content

Commit

Permalink
Avoid unnecessary copy when moving tx between layers
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Sep 4, 2024
1 parent 5fa23f2 commit b032acc
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionAddedResult.REJECTED_UNDERPRICED_REPLACEMENT;
import static org.hyperledger.besu.ethereum.eth.transactions.TransactionAddedResult.TRY_NEXT_LAYER;
import static org.hyperledger.besu.ethereum.eth.transactions.layered.TransactionsLayer.AddReason.MOVE;
import static org.hyperledger.besu.ethereum.eth.transactions.layered.TransactionsLayer.AddReason.NEW;
import static org.hyperledger.besu.ethereum.eth.transactions.layered.TransactionsLayer.RemovalReason.CONFIRMED;
import static org.hyperledger.besu.ethereum.eth.transactions.layered.TransactionsLayer.RemovalReason.CROSS_LAYER_REPLACED;
import static org.hyperledger.besu.ethereum.eth.transactions.layered.TransactionsLayer.RemovalReason.EVICTED;
Expand Down Expand Up @@ -184,7 +185,11 @@ public TransactionAddedResult add(
}

if (addStatus.isSuccess()) {
processAdded(pendingTransaction.detachedCopy());
if (addReason.equals(NEW)) {
// only make a copy of new pending tx, since when moving internally they have already been
// copied
processAdded(pendingTransaction.detachedCopy());
}
addStatus.maybeReplacedTransaction().ifPresent(this::replaced);

nextLayer.notifyAdded(pendingTransaction);
Expand Down

0 comments on commit b032acc

Please sign in to comment.