pub fn connect_block(
block: &Block,
witnesses: &[Vec<Vec<Vec<u8>>>],
utxo_set: HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>,
height: u64,
context: &BlockValidationContext,
) -> Result<(ValidationResult, HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>, BlockUndoLog), ConsensusError>Expand description
ConnectBlock: โฌ ร ๐ฒ* ร ๐ฐ๐ฎ ร โ ร โ* โ {valid, invalid} ร ๐ฐ๐ฎ
For block b = (h, txs) with witnesses ws, UTXO set us at height height, and recent headers:
- Validate block header h
- For each transaction tx โ txs:
- Validate tx structure
- Check inputs against us
- Verify scripts (with witness data if available)
- Let fees = ฮฃ_{tx โ txs} fee(tx)
- Let subsidy = GetBlockSubsidy(height)
- If coinbase output > fees + subsidy: return (invalid, us)
- Apply all transactions to us: usโ = ApplyTransactions(txs, us)
- Return (valid, usโ)
ยงArguments
block- The block to validate and connectwitnesses- Witness data for each transaction in the block (one Witness per transaction)utxo_set- Current UTXO set (will be modified)height- Current block heightcontext- Block validation context (time, network, fork activation, BIP54 boundary). Build withBlockValidationContext::from_connect_block_ibd_args,from_time_context_and_network, orfor_network. ConnectBlock: Validate and apply a block to the UTXO set.