[−][src]Struct cita_state::StateObject
Fields
balance: U256
nonce: U256
storage_root: H256
code_hash: H256
code: Vec<u8>
code_size: usize
code_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 commit
ing.
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]
&mut self,
db: &mut B,
key: &H256
) -> Result<Option<H256>, Error>
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]
&mut self,
db: &mut B,
key: &H256
) -> Result<Option<H256>, Error>
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]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same for T
type Output = T
Should always be Self