mempool_options.h raw

   1  // Copyright (c) 2022-present The Bitcoin Core developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  #ifndef BITCOIN_KERNEL_MEMPOOL_OPTIONS_H
   5  #define BITCOIN_KERNEL_MEMPOOL_OPTIONS_H
   6  
   7  #include <kernel/mempool_limits.h>
   8  
   9  #include <policy/feerate.h>
  10  #include <policy/policy.h>
  11  #include <util/time.h>
  12  
  13  #include <cstdint>
  14  #include <optional>
  15  
  16  class ValidationSignals;
  17  
  18  /** Default for -maxmempool, maximum megabytes of mempool memory usage */
  19  static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300};
  20  /** Default for -maxmempool when blocksonly is set */
  21  static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
  22  /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
  23  static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
  24  /** Whether to fall back to legacy V1 serialization when writing mempool.dat */
  25  static constexpr bool DEFAULT_PERSIST_V1_DAT{false};
  26  /** Default for -acceptnonstdtxn */
  27  static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
  28  
  29  namespace kernel {
  30  /**
  31   * Options struct containing options for constructing a CTxMemPool. Default
  32   * constructor populates the struct with sane default values which can be
  33   * modified.
  34   *
  35   * Most of the time, this struct should be referenced as CTxMemPool::Options.
  36   */
  37  struct MemPoolOptions {
  38      /* The ratio used to determine how often sanity checks will run.  */
  39      int check_ratio{0};
  40      int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000};
  41      std::chrono::seconds expiry{std::chrono::hours{DEFAULT_MEMPOOL_EXPIRY_HOURS}};
  42      CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
  43      /** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
  44      CFeeRate min_relay_feerate{DEFAULT_MIN_RELAY_TX_FEE};
  45      CFeeRate dust_relay_feerate{DUST_RELAY_TX_FEE};
  46      /**
  47       * A data carrying output is an unspendable output containing data. The script
  48       * type is designated as TxoutType::NULL_DATA.
  49       *
  50       * Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
  51       * If nullopt, any size is nonstandard.
  52       */
  53      std::optional<unsigned> max_datacarrier_bytes{DEFAULT_ACCEPT_DATACARRIER ? std::optional{MAX_OP_RETURN_RELAY} : std::nullopt};
  54      bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
  55      bool require_standard{true};
  56      bool persist_v1_dat{DEFAULT_PERSIST_V1_DAT};
  57      MemPoolLimits limits{};
  58  
  59      ValidationSignals* signals{nullptr};
  60  };
  61  } // namespace kernel
  62  
  63  #endif // BITCOIN_KERNEL_MEMPOOL_OPTIONS_H
  64