Skip to main content

create_new_block

Function create_new_block 

Source
pub fn create_new_block(
    utxo_set: &HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>,
    mempool_txs: &[Transaction],
    height: u64,
    prev_header: &BlockHeader,
    prev_headers: &[BlockHeader],
    coinbase_script: &Vec<u8>,
    coinbase_address: &Vec<u8>,
) -> Result<Block, ConsensusError>
Expand description

CreateNewBlock: 𝒰𝒮 × 𝒯𝒳* → ℬ

For UTXO set us and mempool transactions txs:

  1. Create coinbase transaction with appropriate subsidy
  2. Select transactions from mempool based on fee rate
  3. Calculate merkle root
  4. Create block header with appropriate difficulty
  5. Return new block