Skip to main content

get_proven

Function get_proven 

Source
pub fn get_proven<T>(slice: &[T], index: usize) -> Option<&T>
Expand description

Get element with proven bounds check

Uses proven maximum sizes to optimize bounds checking. For transactions proven to have <= MAX_INPUTS_PROVEN inputs, we can use optimized access patterns.

§Safety

This function is safe because formal proofs guarantee bounds. However, it still returns Option to handle cases where:

  • Runtime bounds differ from proof bounds (should not happen in practice)
  • Defensive programming (fail-safe)

§Panics

Never panics - always returns None if out of bounds.

§Examples

use blvm_consensus::optimizations::optimized_access::get_proven;
use blvm_consensus::types::Transaction;

if let Some(input) = get_proven(&tx.inputs, index) {
    // Safe to use
}