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,
pub storage_changes: HashMap<H256, H256>,
}Fields§
§balance: U256§nonce: U256§storage_root: H256§code_hash: H256§code: Vec<u8>§code_size: usize§code_state: CodeState§storage_changes: HashMap<H256, H256>Implementations§
Source§impl StateObject
impl StateObject
Sourcepub fn new(balance: U256, nonce: U256) -> StateObject
pub fn new(balance: U256, nonce: U256) -> StateObject
Create a new account.
Note: If contract account generated, make sure you use init_code on
this before commiting.
Sourcepub fn from_rlp(data: &[u8]) -> Result<StateObject, Error>
pub fn from_rlp(data: &[u8]) -> Result<StateObject, Error>
Create a new account from rlp bytes.
Note: make sure you use read_code after this.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Function is_empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).
Sourcepub fn read_code<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
pub fn read_code<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
Read the code from database by it’s codehash.
Sourcepub fn add_balance(&mut self, x: U256)
pub fn add_balance(&mut self, x: U256)
Add balance. Note: overflowing is not allowed.
Sourcepub fn sub_balance(&mut self, x: U256)
pub fn sub_balance(&mut self, x: U256)
Sub balance. Note: overflowing is not allowed.
Sourcepub fn set_storage(&mut self, key: H256, value: H256)
pub fn set_storage(&mut self, key: H256, value: H256)
Set (key, value) in storage cache.
Sourcepub fn get_storage_at_backend<B: DB>(
&self,
db: Arc<B>,
key: &H256,
) -> Result<Option<H256>, Error>
pub fn get_storage_at_backend<B: DB>( &self, db: Arc<B>, key: &H256, ) -> Result<Option<H256>, Error>
Get value by key from database.
Sourcepub fn get_storage_at_changes(&self, key: &H256) -> Option<H256>
pub fn get_storage_at_changes(&self, key: &H256) -> Option<H256>
Get value by key from storage cache.
Sourcepub fn get_storage<B: DB>(
&self,
db: Arc<B>,
key: &H256,
) -> Result<Option<H256>, Error>
pub fn get_storage<B: DB>( &self, db: Arc<B>, key: &H256, ) -> Result<Option<H256>, Error>
Get value by key.
Sourcepub fn get_storage_proof<B: DB>(
&self,
db: Arc<B>,
key: &H256,
) -> Result<Vec<Vec<u8>>, Error>
pub fn get_storage_proof<B: DB>( &self, db: Arc<B>, key: &H256, ) -> Result<Vec<Vec<u8>>, Error>
Get storage proof
Sourcepub fn commit_storage<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
pub fn commit_storage<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
Flush data in storage cache to database.
Sourcepub fn commit_code<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
pub fn commit_code<B: DB>(&mut self, db: Arc<B>) -> Result<(), Error>
Flush code to database if necessary.
Sourcepub fn clone_clean(&self) -> StateObject
pub fn clone_clean(&self) -> StateObject
Clone without storage changes.
Sourcepub fn clone_dirty(&self) -> StateObject
pub fn clone_dirty(&self) -> StateObject
Clone with storage changes.
Sourcepub fn merge(&mut self, other: StateObject)
pub fn merge(&mut self, other: StateObject)
Merge with others.
Trait Implementations§
Source§impl Clone for StateObject
impl Clone for StateObject
Source§fn clone(&self) -> StateObject
fn clone(&self) -> StateObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StateObject
impl Debug for StateObject
Auto Trait Implementations§
impl Freeze for StateObject
impl RefUnwindSafe for StateObject
impl Send for StateObject
impl Sync for StateObject
impl Unpin for StateObject
impl UnwindSafe for StateObject
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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