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 block_extensions: HashMap<Byte32, Bytes>,
pub cells_by_data_hash: HashMap<Byte32, OutPoint>,
pub cells_by_type_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>
§block_extensions: HashMap<Byte32, Bytes>
§cells_by_data_hash: HashMap<Byte32, OutPoint>
§cells_by_type_hash: HashMap<Byte32, OutPoint>
Implementations§
Source§impl Context
impl Context
Sourcepub fn new_with_deterministic_rng() -> Self
pub fn new_with_deterministic_rng() -> Self
Create a new context with a deterministic random number generator, which can be used to generate deterministic out point of deployed contract
pub fn add_contract_dir(&mut self, path: &str)
pub fn deploy_contract(&mut self, data: Bytes) -> OutPoint
Sourcepub fn deploy_cell(&mut self, data: Bytes) -> OutPoint
pub fn deploy_cell(&mut self, data: Bytes) -> OutPoint
Deploy a cell return the out-point of the cell
pub fn deploy_cell_by_name(&mut self, filename: &str) -> OutPoint
Sourcepub fn insert_header(&mut self, header: HeaderView)
pub fn insert_header(&mut self, header: HeaderView)
Insert a block header into context
Sourcepub fn link_cell_with_block(
&mut self,
out_point: OutPoint,
block_hash: Byte32,
tx_index: usize,
)
pub fn link_cell_with_block( &mut self, out_point: OutPoint, block_hash: Byte32, tx_index: usize, )
Link a cell with a block to make the load_header_by_cell syscalls works
pub fn get_contract_out_point(&self, data_hash: &Byte32) -> Option<OutPoint>
Sourcepub fn get_cell_by_data_hash(&self, data_hash: &Byte32) -> Option<OutPoint>
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
Sourcepub fn create_cell(&mut self, cell: CellOutput, data: Bytes) -> OutPoint
pub fn create_cell(&mut self, cell: CellOutput, data: Bytes) -> OutPoint
Create a cell with data return the out-point
Sourcepub fn create_cell_with_out_point(
&mut self,
out_point: OutPoint,
cell: CellOutput,
data: Bytes,
)
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
pub fn insert_cell( &mut self, out_point: OutPoint, cell: CellOutput, data: Bytes, )
Sourcepub fn get_cell(&self, out_point: &OutPoint) -> Option<(CellOutput, Bytes)>
pub fn get_cell(&self, out_point: &OutPoint) -> Option<(CellOutput, Bytes)>
Get cell output and data by out-point
Sourcepub fn build_script_with_hash_type(
&mut self,
out_point: &OutPoint,
hash_type: ScriptHashType,
args: Bytes,
) -> Option<Script>
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
Sourcepub fn build_script(
&mut self,
out_point: &OutPoint,
args: Bytes,
) -> Option<Script>
pub fn build_script( &mut self, out_point: &OutPoint, args: Bytes, ) -> Option<Script>
Build script with out_point, args and hash_type(ScriptHashType::Type) return none if the out-point is not exist
Sourcepub fn complete_tx(&mut self, tx: TransactionView) -> TransactionView
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.
pub fn capture_debug(&self) -> bool
Sourcepub fn set_capture_debug(&mut self, capture_debug: bool)
pub fn set_capture_debug(&mut self, capture_debug: bool)
Capture debug output, default value is false
Sourcepub fn captured_messages(&self) -> Vec<Message>
pub fn captured_messages(&self) -> Vec<Message>
return captured messages
Sourcepub fn verify_tx(
&self,
tx: &TransactionView,
max_cycles: u64,
) -> Result<Cycle, CKBError>
pub fn verify_tx( &self, tx: &TransactionView, max_cycles: u64, ) -> Result<Cycle, CKBError>
Verify the transaction in CKB-VM
Sourcepub fn dump_tx(
&self,
tx: &TransactionView,
) -> Result<ReprMockTransaction, CKBError>
pub fn dump_tx( &self, tx: &TransactionView, ) -> Result<ReprMockTransaction, CKBError>
Dump the transaction in mock transaction format, so we can offload it to ckb debugger
Trait Implementations§
Source§impl CellDataProvider for Context
impl CellDataProvider for Context
Source§fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes>
fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes>
Source§impl ExtensionProvider for Context
impl ExtensionProvider for Context
Source§impl HeaderProvider for Context
impl HeaderProvider for Context
Source§fn get_header(&self, block_hash: &Byte32) -> Option<HeaderView>
fn get_header(&self, block_hash: &Byte32) -> Option<HeaderView>
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more