pub struct Context {
    pub cells: HashMap<OutPoint, (CellOutput, Bytes)>,
    pub transaction_infos: HashMap<OutPoint, TransactionInfo>,
    pub headers: HashMap<Byte32, HeaderView>,
    pub epoches: HashMap<Byte32, EpochExt>,
    pub cells_by_data_hash: HashMap<Byte32, OutPoint>,
    /* private fields */
}
Expand description

Verification Context

Fields§

§cells: HashMap<OutPoint, (CellOutput, Bytes)>§transaction_infos: HashMap<OutPoint, TransactionInfo>§headers: HashMap<Byte32, HeaderView>§epoches: HashMap<Byte32, EpochExt>§cells_by_data_hash: HashMap<Byte32, OutPoint>

Implementations§

source§

impl Context

source

pub fn deploy_contract(&mut self, data: Bytes) -> OutPoint

👎Deprecated since 0.1.1: Please use the deploy_cell function instead
source

pub fn deploy_cell(&mut self, data: Bytes) -> OutPoint

Deploy a cell return the out-point of the cell

source

pub fn insert_header(&mut self, header: HeaderView)

Insert a block header into context

Link a cell with a block to make the load_header_by_cell syscalls works

source

pub fn get_contract_out_point(&self, data_hash: &Byte32) -> Option<OutPoint>

👎Deprecated since 0.1.1: Please use the get_cell_by_data_hash function instead
source

pub fn get_cell_by_data_hash(&self, data_hash: &Byte32) -> Option<OutPoint>

Get the out-point of a cell by data_hash the cell must has deployed to this context

source

pub fn create_cell(&mut self, cell: CellOutput, data: Bytes) -> OutPoint

Create a cell with data return the out-point

source

pub fn create_cell_with_out_point( &mut self, out_point: OutPoint, cell: CellOutput, data: Bytes )

Create cell with specified out-point and cell data

source

pub fn insert_cell( &mut self, out_point: OutPoint, cell: CellOutput, data: Bytes )

👎Deprecated since 0.1.1: Please use the create_cell_with_out_point function instead
source

pub fn get_cell(&self, out_point: &OutPoint) -> Option<(CellOutput, Bytes)>

Get cell output and data by out-point

source

pub fn build_script_with_hash_type( &mut self, out_point: &OutPoint, hash_type: ScriptHashType, args: Bytes ) -> Option<Script>

Build script with out_point, hash_type, args return none if the out-point is not exist

source

pub fn build_script( &mut self, out_point: &OutPoint, args: Bytes ) -> Option<Script>

Build script with out_point, args (hash_type = ScriptHashType::Data1) return none if the out-point is not exist

source

pub fn complete_tx(&mut self, tx: TransactionView) -> TransactionView

Complete cell deps for a transaction this function searches context cells; generate cell dep for referenced scripts.

source

pub fn capture_debug(&self) -> bool

source

pub fn set_capture_debug(&mut self, capture_debug: bool)

Capture debug output, default value is false

source

pub fn captured_messages(&self) -> Vec<Message>

return captured messages

source

pub fn verify_tx( &self, tx: &TransactionView, max_cycles: u64 ) -> Result<Cycle, CKBError>

Verify the transaction in CKB-VM

Trait Implementations§

source§

impl CellDataProvider for Context

source§

fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes>

Load cell_data from memory, fallback to storage access
source§

fn get_cell_data(&self, out_point: &OutPoint) -> Option<Bytes>

Fetch cell_data from storage
source§

fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>

Fetch cell_data_hash from storage, please note that loading a large amount of cell data and calculating hash may be a performance bottleneck, so here is a separate fn designed to facilitate caching. Read more
source§

fn load_cell_data_hash(&self, cell: &CellMeta) -> Option<Byte32>

Load cell_data_hash from memory, fallback to storage access
source§

impl Default for Context

source§

fn default() -> Context

Returns the “default value” for a type. Read more
source§

impl HeaderProvider for Context

source§

fn get_header(&self, block_hash: &Byte32) -> Option<HeaderView>

Get the header of the given block hash
source§

fn timestamp_and_parent(&self, block_hash: &Byte32) -> (u64, u64, Byte32)

Get timestamp and block_number of the corresponding block_hash, and hash of parent block
source§

fn block_median_time( &self, block_hash: &Byte32, median_block_count: usize ) -> u64

Get past block median time, including the timestamp of the given one

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for Twhere T: Any,

§

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

TODO(doc): @quake
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V