Struct clarity_repl::clarity::contexts::GlobalContext
source · [−]pub struct GlobalContext<'a> {
pub event_batches: Vec<EventBatch>,
pub database: ClarityDatabase<'a>,
pub cost_track: LimitedCostTracker,
pub mainnet: bool,
pub coverage_reporting: Option<TestCoverageReport>,
pub costs_reporting: Option<CostsReport>,
/* private fields */
}
Expand description
GlobalContext represents the outermost context for a single transaction’s execution. It tracks an asset changes that occurred during the processing of the transaction, whether or not the current context is read_only, and is responsible for committing/rolling-back transactions as they error or abort.
Fields
event_batches: Vec<EventBatch>
database: ClarityDatabase<'a>
cost_track: LimitedCostTracker
mainnet: bool
coverage_reporting: Option<TestCoverageReport>
costs_reporting: Option<CostsReport>
Implementations
sourceimpl<'a> GlobalContext<'a>
impl<'a> GlobalContext<'a>
pub fn new(
mainnet: bool,
database: ClarityDatabase<'_>,
cost_track: LimitedCostTracker
) -> GlobalContext<'_>
pub fn is_top_level(&self) -> bool
pub fn log_asset_transfer(
&mut self,
sender: &PrincipalData,
contract_identifier: &QualifiedContractIdentifier,
asset_name: &ClarityName,
transfered: Value
)
pub fn log_token_transfer(
&mut self,
sender: &PrincipalData,
contract_identifier: &QualifiedContractIdentifier,
asset_name: &ClarityName,
transfered: u128
) -> Result<()>
pub fn log_stx_transfer(
&mut self,
sender: &PrincipalData,
transfered: u128
) -> Result<()>
pub fn log_stx_burn(
&mut self,
sender: &PrincipalData,
transfered: u128
) -> Result<()>
pub fn execute<F, T>(&mut self, f: F) -> Result<T> where
F: FnOnce(&mut Self) -> Result<T>,
pub fn is_read_only(&self) -> bool
pub fn begin(&mut self)
pub fn begin_read_only(&mut self)
pub fn commit(&mut self) -> Result<(Option<AssetMap>, Option<EventBatch>)>
pub fn roll_back(&mut self)
pub fn handle_tx_result(&mut self, result: Result<Value>) -> Result<Value>
sourcepub fn destruct(self) -> Option<(ClarityDatabase<'a>, LimitedCostTracker)>
pub fn destruct(self) -> Option<(ClarityDatabase<'a>, LimitedCostTracker)>
Destroys this context, returning ownership of its database reference. If the context wasn’t top-level (i.e., it had uncommitted data), return None, because the database is not guaranteed to be in a sane state.
Trait Implementations
sourceimpl CostTracker for GlobalContext<'_>
impl CostTracker for GlobalContext<'_>
fn compute_cost(
&mut self,
cost_function: ClarityCostFunction,
input: &[u64]
) -> Result<ExecutionCost, CostErrors>
fn add_cost(&mut self, cost: ExecutionCost) -> Result<(), CostErrors>
fn add_memory(&mut self, memory: u64) -> Result<(), CostErrors>
fn drop_memory(&mut self, memory: u64)
fn reset_memory(&mut self)
sourcefn short_circuit_contract_call(
&mut self,
contract: &QualifiedContractIdentifier,
function: &ClarityName,
input: &[u64]
) -> Result<bool, CostErrors>
fn short_circuit_contract_call(
&mut self,
contract: &QualifiedContractIdentifier,
function: &ClarityName,
input: &[u64]
) -> Result<bool, CostErrors>
Check if the given contract-call should be short-circuited. If so: this charges the cost to the CostTracker, and return true If not: return false Read more
Auto Trait Implementations
impl<'a> !RefUnwindSafe for GlobalContext<'a>
impl<'a> !Send for GlobalContext<'a>
impl<'a> !Sync for GlobalContext<'a>
impl<'a> Unpin for GlobalContext<'a>
impl<'a> !UnwindSafe for GlobalContext<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more