Skip to main content

ContractHistory

Struct ContractHistory 

Source
pub struct ContractHistory {
    pub contract_id: Hash,
    pub transitions: Vec<StateTransitionRecord>,
    pub active_rights: BTreeMap<Hash, Right>,
    pub consumed_seals: BTreeMap<Vec<u8>, SealRef>,
    pub latest_commitment_hash: Hash,
}
Expand description

A contract’s full state history from genesis to present.

Fields§

§contract_id: Hash

The contract’s unique identifier

§transitions: Vec<StateTransitionRecord>

All state transitions in chronological order

§active_rights: BTreeMap<Hash, Right>

Current active Rights (not yet consumed)

§consumed_seals: BTreeMap<Vec<u8>, SealRef>

All consumed seals indexed by seal ID

§latest_commitment_hash: Hash

The latest commitment hash in the chain

Implementations§

Source§

impl ContractHistory

Source

pub fn from_genesis(genesis_commitment: Commitment) -> Self

Create a new contract history from genesis.

Source

pub fn add_transition( &mut self, transition: StateTransitionRecord, ) -> Result<(), StoreError>

Add a state transition to the history.

Source

pub fn add_right(&mut self, right: Right)

Register a new Right as active.

Source

pub fn consume_right(&mut self, right_id: &Hash) -> Option<Right>

Mark a Right as consumed.

Source

pub fn is_seal_consumed(&self, seal_ref: &SealRef) -> bool

Check if a seal has been consumed.

Source

pub fn mark_seal_consumed(&mut self, seal_ref: SealRef)

Mark a seal as consumed.

Source

pub fn transition_count(&self) -> usize

Get the number of transitions in this contract’s history.

Source

pub fn get_active_rights(&self) -> Vec<&Right>

Get all active Rights.

Trait Implementations§

Source§

impl Clone for ContractHistory

Source§

fn clone(&self) -> ContractHistory

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContractHistory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ContractHistory

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ContractHistory

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,