[][src]Struct cita_state::StateObject

pub struct StateObject {
    pub balance: U256,
    pub nonce: U256,
    pub storage_root: H256,
    pub code_hash: H256,
    pub code: Vec<u8>,
    pub code_size: usize,
    pub code_state: CodeState,
    // some fields omitted
}

Fields

balance: U256nonce: U256storage_root: H256code_hash: H256code: Vec<u8>code_size: usizecode_state: CodeState

Methods

impl StateObject[src]

pub fn new(balance: U256, nonce: U256) -> StateObject[src]

Create a new account. Note: If contract account generated, make sure you use init_code on this before commiting.

pub fn from_rlp(data: &[u8]) -> Result<StateObject, Error>[src]

Create a new account from rlp bytes. Note: make sure you use read_code after this.

pub fn account(&self) -> Account[src]

Get the account from state object.

pub fn rlp(&self) -> Vec<u8>[src]

Get the rlp data.

pub fn is_empty(&self) -> bool[src]

Function is_empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).

pub fn init_code(&mut self, code: Vec<u8>)[src]

Init the code by given data.

pub fn read_code<B: DB>(&mut self, db: &mut B) -> Result<(), Error>[src]

Read the code from database by it's codehash.

pub fn inc_nonce(&mut self)[src]

Add nonce by 1.

pub fn add_balance(&mut self, x: U256)[src]

Add balance. Note: overflowing is not allowed.

pub fn sub_balance(&mut self, x: U256)[src]

Sub balance. Note: overflowing is not allowed.

pub fn set_storage(&mut self, key: H256, value: H256)[src]

Set (key, value) in storage cache.

pub fn get_storage_at_backend<B: DB>(
    &mut self,
    db: &mut B,
    key: &H256
) -> Result<Option<H256>, Error>
[src]

Get value by key from database.

pub fn get_storage_at_changes(&self, key: &H256) -> Option<H256>[src]

Get value by key from storage cache.

pub fn get_storage<B: DB>(
    &mut self,
    db: &mut B,
    key: &H256
) -> Result<Option<H256>, Error>
[src]

Get value by key.

pub fn commit_storage<B: DB>(&mut self, db: &mut B) -> Result<(), Error>[src]

Flush data in storage cache to database.

pub fn commit_code<B: DB>(&mut self, db: &mut B) -> Result<(), Error>[src]

Flush code to database if necessary.

pub fn clone_clean(&self) -> StateObject[src]

Clone without storage changes.

pub fn clone_dirty(&self) -> StateObject[src]

Clone with storage changes.

pub fn merge(&mut self, other: StateObject)[src]

Merge with others.

Trait Implementations

impl From<Account> for StateObject[src]

impl Debug for StateObject[src]

Auto Trait Implementations

impl Send for StateObject

impl Sync for StateObject

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

impl<T> Same for T

type Output = T

Should always be Self