Struct ckb_script::TransactionScriptsVerifier[][src]

pub struct TransactionScriptsVerifier<'a, DL> { /* fields omitted */ }
Expand description

This struct leverages CKB VM to verify transaction inputs.

FlatBufferBuilder owned Vec<u8> that grows as needed, in the future, we might refactor this to share buffer to achieve zero-copy

Implementations

impl<'a, DL: CellDataProvider + HeaderProvider> TransactionScriptsVerifier<'a, DL>[src]

pub fn new(
    rtx: &'a ResolvedTransaction,
    data_loader: &'a DL
) -> TransactionScriptsVerifier<'a, DL>
[src]

Creates a script verifier for the transaction.

Params

  • rtx - transaction which cell out points have been resolved.
  • data_loader - used to load cell data.

pub fn set_debug_printer<F: Fn(&Byte32, &str) + 'static>(&mut self, func: F)[src]

Sets a callback to handle the debug syscall.

Script can print a message using the debug syscall.

The callback receives two parameters:

  • hash: &Byte32: this is the script hash of currently running script group.
  • message: &str: message passed to the debug syscall.

pub fn extract_script(&self, script: &'a Script) -> Result<Bytes, ScriptError>[src]

Extracts actual script binary either in dep cells.

pub fn verify(&self, max_cycles: Cycle) -> Result<Cycle, Error>[src]

Verifies the transaction by running scripts.

Params

  • max_cycles - Maximium allowed cycles to run the scripts. The verification quits early when the consumed cycles exceed the limit.

Returns

It returns the total consumed cycles on success, Otherwise it returns the verification error.

pub fn verify_single(
    &self,
    script_group_type: ScriptGroupType,
    script_hash: &Byte32,
    max_cycles: Cycle
) -> Result<Cycle, ScriptError>
[src]

Runs a single script in current transaction, while this is not useful for CKB itself, it can be very helpful when building a CKB debugger.

pub fn find_script_group(
    &self,
    script_group_type: ScriptGroupType,
    script_hash: &Byte32
) -> Option<&ScriptGroup>
[src]

Finds the script group from cell deps.

pub fn cost_model(&self) -> Box<InstructionCycleFunc>[src]

Gets the cost model.

Cost model is used to evaluate consumed cycles.

pub fn generate_syscalls(
    &'a self,
    script_group: &'a ScriptGroup
) -> Vec<Box<dyn Syscalls<Box<AsmCoreMachine>> + 'a>>
[src]

Prepares syscalls.

Auto Trait Implementations

impl<'a, DL> !RefUnwindSafe for TransactionScriptsVerifier<'a, DL>

impl<'a, DL> !Send for TransactionScriptsVerifier<'a, DL>

impl<'a, DL> !Sync for TransactionScriptsVerifier<'a, DL>

impl<'a, DL> Unpin for TransactionScriptsVerifier<'a, DL>

impl<'a, DL> !UnwindSafe for TransactionScriptsVerifier<'a, DL>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> AsAny for T where
    T: Any

pub fn as_any(&self) -> &(dyn Any + 'static)

TODO(doc): @quake

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V