class TransactionPoolReplacementHandler {

  public boolean shouldReplace(
      final TransactionInfo existingTransactionInfo,
      final TransactionInfo newTransactionInfo,
      final BlockHeader chainHeadHeader) {
    assert existingTransactionInfo != null;
    if (newTransactionInfo == null) {
      return false;
    }
    return eip1559
            .map(
                eip ->
                    eip.isValidTransaction(
                        chainHeadHeader.getNumber(), newTransactionInfo.getTransaction()))
            .orElse(newTransactionInfo.getTransaction().isFrontierTransaction())
        && rules.stream()
            .anyMatch(
                rule ->
                    rule.shouldReplace(
                        existingTransactionInfo, newTransactionInfo, chainHeadHeader.getBaseFee()));
  }

  public  TransactionPoolReplacementHandler(
      final Optional<EIP1559> eip1559, final Percentage priceBump);
  @VisibleForTesting  TransactionPoolReplacementHandler(
      final List<TransactionPoolReplacementRule> rules, final Optional<EIP1559> eip1559);

}