coin_age_priority.h raw

   1  // Copyright (c) 2012-2017 The Limenka developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  
   5  #ifndef LIMENKA_POLICY_COIN_AGE_PRIORITY_H
   6  #define LIMENKA_POLICY_COIN_AGE_PRIORITY_H
   7  
   8  #include <consensus/amount.h>
   9  
  10  class CCoinsViewCache;
  11  class CTransaction;
  12  
  13  struct CoinAgeCache
  14  {
  15      uint64_t inputs_coin_age;      //!< Sum coin-age of all confirmed inputs (satoshi-blocks)
  16      CAmount in_chain_input_value;  //!< Sum value of all confirmed inputs
  17  };
  18  
  19  static constexpr CoinAgeCache COIN_AGE_CACHE_ZERO{
  20      .inputs_coin_age = 0,
  21      .in_chain_input_value = 0,
  22  };
  23  
  24  // Compute modified tx vsize for priority calculation
  25  unsigned int CalculateModifiedSize(const CTransaction& tx, unsigned int nTxSize);
  26  
  27  // Compute priority, given sum coin-age of inputs and modified tx vsize
  28  // CAUTION: Original ComputePriority accepted UNMODIFIED tx vsize and did the modification internally
  29  double ComputePriority2(uint64_t inputs_coin_age, unsigned int mod_vsize);
  30  double ReversePriority2(double coin_age_priority, unsigned int mod_vsize);
  31  
  32  /**
  33   * Return sum coin-age of tx inputs at height nHeight. Also calculate the sum of the values of the inputs
  34   * that are already in the chain.  These are the inputs that will age and increase priority as
  35   * new blocks are added to the chain.
  36   * CAUTION: Original GetPriority also called ComputePriority and returned the final coin-age priority
  37   */
  38  CoinAgeCache GetCoinAge(const CTransaction &tx, const CCoinsViewCache& view, int nHeight);
  39  
  40  #endif // LIMENKA_POLICY_COIN_AGE_PRIORITY_H
  41