pub fn scan_block_for_relevant_xt(block: &Block) -> SgxResult<Vec<OpaqueCall>> {
    debug!("Scanning block {} for relevant xt", block.header.number());
    let mut opaque_calls = Vec::<OpaqueCall>::new();
    for xt_opaque in block.extrinsics.iter() {
        if let Ok(xt) =
            UncheckedExtrinsicV4::<ShieldFundsFn>::decode(&mut xt_opaque.encode().as_slice())
        {
            // confirm call decodes successfully as well
            if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, SHIELD_FUNDS] {
                if let Err(e) = handle_shield_funds_xt(&mut opaque_calls, xt) {
                    error!("Error performing shieldfunds. Error: {:?}", e);
                }
            }
        };

        if let Ok(xt) =
            UncheckedExtrinsicV4::<CallWorkerFn>::decode(&mut xt_opaque.encode().as_slice())
        {
            if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, CALL_WORKER] {
                if let Ok((decrypted_trusted_call, shard)) = decrypt_unchecked_extrinsic(xt) {
                    // load state before executing any calls
                    let mut state = if state::exists(&shard) {
                        state::load(&shard)?
                    } else {
                        state::init_shard(&shard)?;
                        Stf::init_state()
                    };
                    // call execution
                    if let Err(e) = handle_trusted_worker_call(
                        &mut opaque_calls, // necessary for unshielding
                        &mut state,
                        decrypted_trusted_call,
                        block.header.clone(),
                        shard,
                        None,
                    ) {
                        error!("Error performing worker call: Error: {:?}", e);
                    }
                    // save updated state
                    state::write(state, &shard)?;
                }
            }
        }
    }

    Ok(opaque_calls)
}
/// Scans blocks for extrinsics that ask the enclave to execute some actions.
/// Executes indirect invocation calls, aswell as shielding and unshielding calls
/// Returns all unshielding call confirmations as opaque calls
Scans blocks for extrinsics that ask the enclave to execute some actions.
Executes indirect invocation calls, aswell as shielding and unshielding calls
Returns all unshielding call confirmations as opaque calls
Scans blocks for extrinsics that ask the enclave to execute some actions . Executes indirect invocation calls aswell as shielding and unshielding calls Returns all unshielding call confirmations as opaque calls
pub fn scan_block_for_relevant_xt(block: &Block) -> SgxResult<Vec<OpaqueCall>> {
    debug!("Scanning block {} for relevant xt", block.header.number());
    let mut opaque_calls = Vec::<OpaqueCall>::new();
    for xt_opaque in block.extrinsics.iter() {
        if let Ok(xt) =
            UncheckedExtrinsicV4::<ShieldFundsFn>::decode(&mut xt_opaque.encode().as_slice())
        {
            // confirm call decodes successfully as well
            if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, SHIELD_FUNDS] {
                if let Err(e) = handle_shield_funds_xt(&mut opaque_calls, xt) {
                    error!("Error performing shieldfunds. Error: {:?}", e);
                }
            }
        };
        if let Ok(xt) =
            UncheckedExtrinsicV4::<CallWorkerFn>::decode(&mut xt_opaque.encode().as_slice())
        {
            if xt.function.0 == [SUBSRATEE_REGISTRY_MODULE, CALL_WORKER] {
                if let Ok((decrypted_trusted_call, shard)) = decrypt_unchecked_extrinsic(xt) {
                    // load state before executing any calls
                    let mut state = if state::exists(&shard) {
                        state::load(&shard)?
                    } else {
                        state::init_shard(&shard)?;
                        Stf::init_state()
                    };
                    // call execution
                    if let Err(e) = handle_trusted_worker_call(
                        &mut opaque_calls, // necessary for unshielding
                        &mut state,
                        decrypted_trusted_call,
                        block.header.clone(),
                        shard,
                        None,
                    ) {
                        error!("Error performing worker call: Error: {:?}", e);
                    }
                    // save updated state
                    state::write(state, &shard)?;
                }
            }
        }
    }
    Ok(opaque_calls)
}
pub fn scan_block_for_relevant_xt ( block : & Block ) -> SgxResult < Vec < OpaqueCall > > { debug ! ( " " block header number ( ) ) ; let mut opaque_calls = Vec :: < OpaqueCall > :: new ( ) ; for xt_opaque in block . extrinsics . iter ( ) { if let Ok ( xt ) = UncheckedExtrinsicV4 :: < ShieldFundsFn > :: decode ( & mut xt_opaque . encode ( ) . as_slice ( ) ) { // confirm call decodes successfully as well if xt . function . 0 == [ SUBSRATEE_REGISTRY_MODULE , SHIELD_FUNDS ] { if let Err ( e ) = handle_shield_funds_xt ( & mut opaque_calls , xt ) { error ! ( " " e ) ; } } } ; if let Ok ( xt ) = UncheckedExtrinsicV4 :: < CallWorkerFn > :: decode ( & mut xt_opaque . encode ( ) . as_slice ( ) ) { if xt . function . 0 == [ SUBSRATEE_REGISTRY_MODULE , CALL_WORKER ] { if let Ok ( ( decrypted_trusted_call , shard ) ) = decrypt_unchecked_extrinsic ( xt ) { // load state before executing any calls let mut state = if state :: exists ( & shard ) { state :: load ( & shard ) ? } else { state :: init_shard ( & shard ) ? ; Stf :: init_state ( ) } ; // call execution if let Err ( e ) = handle_trusted_worker_call ( & mut opaque_calls , // necessary for unshielding & mut state , decrypted_trusted_call , block . header . clone ( ) , shard , None , ) { error ! ( " " e ) ; } // save updated state state :: write ( state , & shard ) ? ; } } } } Ok ( opaque_calls ) }
Scans blocks for extrinsics that ask the enclave to execute some actions.
Scans blocks for extrinsics that ask the enclave to execute some actions .
block
&Block
block
&Block