class TransactionPoolFactory {

  public static TransactionPool createTransactionPool(
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final EthContext ethContext,
      final Clock clock,
      final MetricsSystem metricsSystem,
      final SyncState syncState,
      final Wei minTransactionGasPrice,
      final TransactionPoolConfiguration transactionPoolConfiguration,
      final boolean eth65Enabled,
      final Optional<EIP1559> eip1559) {

    final PendingTransactions pendingTransactions =
        new PendingTransactions(
            transactionPoolConfiguration.getPendingTxRetentionPeriod(),
            transactionPoolConfiguration.getTxPoolMaxSize(),
            transactionPoolConfiguration.getPooledTransactionHashesSize(),
            clock,
            metricsSystem,
            protocolContext.getBlockchain()::getChainHeadHeader,
            eip1559,
            transactionPoolConfiguration.getPriceBump());

    final PeerTransactionTracker transactionTracker = new PeerTransactionTracker();
    final TransactionsMessageSender transactionsMessageSender =
        new TransactionsMessageSender(transactionTracker);

    final Optional<PeerPendingTransactionTracker> pendingTransactionTracker =
        eth65Enabled
            ? Optional.of(new PeerPendingTransactionTracker(pendingTransactions))
            : Optional.empty();
    final Optional<PendingTransactionsMessageSender> pendingTransactionsMessageSender =
        eth65Enabled
            ? Optional.of(new PendingTransactionsMessageSender(pendingTransactionTracker.get()))
            : Optional.empty();

    return createTransactionPool(
        protocolSchedule,
        protocolContext,
        ethContext,
        metricsSystem,
        syncState,
        minTransactionGasPrice,
        transactionPoolConfiguration,
        pendingTransactions,
        transactionTracker,
        transactionsMessageSender,
        pendingTransactionTracker,
        pendingTransactionsMessageSender,
        eth65Enabled,
        eip1559);
  }

}