src/cryptonote_core/tx_pool.cpp
//---------------------------------------------------------------------------------
//TODO: investigate whether boolean return is appropriate
investigate whether boolean return is appropriate
investigate whether boolean return is appropriate
bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee)
  {
    CRITICAL_REGION_LOCAL(m_transactions_lock);
    total_size = 0;
    fee = 0;
    size_t max_total_size = (130 * median_size) / 100 - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
    std::unordered_set<crypto::key_image> k_images;
    auto sorted_it = m_txs_by_fee.begin();
    while (sorted_it != m_txs_by_fee.end())
    {
      auto tx_it = m_transactions.find(sorted_it->second);
      if (max_total_size < total_size + tx_it->second.blob_size)
      {
        sorted_it++;
        continue;
      }
      if ( (total_size + tx_it->second.blob_size) > CRYPTONOTE_GETBLOCKTEMPLATE_MAX_BLOCK_SIZE )
      {
        sorted_it++;
        continue;
      }
      if (total_size > median_size)
        break;
      if (!is_transaction_ready_to_go(tx_it->second) || have_key_images(k_images, tx_it->second.tx))
      {
        sorted_it++;
        continue;
      }
      bl.tx_hashes.push_back(tx_it->first);
      total_size += tx_it->second.blob_size;
      fee += tx_it->second.fee;
      append_key_images(k_images, tx_it->second.tx);
      sorted_it++;
    }
    return true;
  }
bool tx_memory_pool :: fill_block_template ( block & bl , size_t median_size , uint64_t already_generated_coins , size_t & total_size , uint64_t & fee ) { CRITICAL_REGION_LOCAL ( m_transactions_lock ) ; total_size = 0 ; fee = 0 ; size_t max_total_size = ( 130 * median_size ) / 100 - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE ; std :: unordered_set < crypto :: key_image > k_images ; auto sorted_it = m_txs_by_fee . begin ( ) ; while ( sorted_it != m_txs_by_fee . end ( ) ) { auto tx_it = m_transactions . find ( sorted_it -> second ) ; if ( max_total_size < total_size + tx_it -> second . blob_size ) { sorted_it ++ ; continue ; } if ( ( total_size + tx_it -> second . blob_size ) > CRYPTONOTE_GETBLOCKTEMPLATE_MAX_BLOCK_SIZE ) { sorted_it ++ ; continue ; } if ( total_size > median_size ) break ; if ( ! is_transaction_ready_to_go ( tx_it -> second ) || have_key_images ( k_images , tx_it -> second . tx ) ) { sorted_it ++ ; continue ; } bl . tx_hashes . push_back ( tx_it -> first ) ; total_size += tx_it -> second . blob_size ; fee += tx_it -> second . fee ; append_key_images ( k_images , tx_it -> second . tx ) ; sorted_it ++ ; } return true ; }
TODO: investigate whether boolean return is appropriate
TODO : investigate whether boolean return is appropriate
// Warning: This function takes already_generated_ // coins as an argument and appears to do nothing // with it. // Maximum block size is 130% of the median block size.  This gives a // little extra headroom for the max size transaction. // Can not exceed maximum block size // If adding this tx will make the block size // greater than CRYPTONOTE_GETBLOCKTEMPLATE_MAX // _BLOCK_SIZE bytes, reject the tx; this will // keep block sizes from becoming too unwieldly // to propagate at 60s block times. // If we've exceeded the penalty free size, // stop including more tx // Skip transactions that are not ready to be // included into the blockchain or that are // missing key images