Struct ethcore::state::Account
[−]
[src]
pub struct Account { /* fields omitted */ }
Single account in the system.
Keeps track of changes to the code and storage.
The changes are applied in commit_storage
and commit_code
Methods
impl Account
[src]
impl Account
pub fn from_pod(pod: PodAccount) -> Account
[src]
pub fn from_pod(pod: PodAccount) -> Account
General constructor.
pub fn new_basic(balance: U256, nonce: U256) -> Account
[src]
pub fn new_basic(balance: U256, nonce: U256) -> Account
Create a new account with the given balance.
pub fn from_rlp(rlp: &[u8]) -> Result<Account, Error>
[src]
pub fn from_rlp(rlp: &[u8]) -> Result<Account, Error>
Create a new account from RLP.
pub fn new_contract(balance: U256, nonce: U256) -> Account
[src]
pub fn new_contract(balance: U256, nonce: U256) -> Account
Create a new contract account.
NOTE: make sure you use init_code
on this before commit
ing.
pub fn init_code(&mut self, code: Bytes)
[src]
pub fn init_code(&mut self, code: Bytes)
Set this account's code to the given code.
NOTE: Account should have been created with new_contract()
pub fn reset_code(&mut self, code: Bytes)
[src]
pub fn reset_code(&mut self, code: Bytes)
Reset this account's code to the given code.
pub fn reset_code_and_storage(
&mut self,
code: Arc<Bytes>,
storage: HashMap<H256, H256>
)
[src]
pub fn reset_code_and_storage(
&mut self,
code: Arc<Bytes>,
storage: HashMap<H256, H256>
)
Reset this account's code and storage to given values.
pub fn set_storage(&mut self, key: H256, value: H256)
[src]
pub fn set_storage(&mut self, key: H256, value: H256)
Set (and cache) the contents of the trie's storage at key
to value
.
pub fn storage_at(&self, db: &HashDB, key: &H256) -> Result<H256>
[src]
pub fn storage_at(&self, db: &HashDB, key: &H256) -> Result<H256>
Get (and cache) the contents of the trie's storage at key
.
Takes modified storage into account.
pub fn cached_storage_at(&self, key: &H256) -> Option<H256>
[src]
pub fn cached_storage_at(&self, key: &H256) -> Option<H256>
Get cached storage value if any. Returns None
if the
key is not in the cache.
pub fn balance(&self) -> &U256
[src]
pub fn balance(&self) -> &U256
return the balance associated with this account.
pub fn nonce(&self) -> &U256
[src]
pub fn nonce(&self) -> &U256
return the nonce associated with this account.
pub fn code_hash(&self) -> H256
[src]
pub fn code_hash(&self) -> H256
return the code hash associated with this account.
pub fn address_hash(&self, address: &Address) -> H256
[src]
pub fn address_hash(&self, address: &Address) -> H256
return the code hash associated with this account.
pub fn code(&self) -> Option<Arc<Bytes>>
[src]
pub fn code(&self) -> Option<Arc<Bytes>>
returns the account's code. If None
then the code cache isn't available -
get someone who knows to call note_code
.
pub fn code_size(&self) -> Option<usize>
[src]
pub fn code_size(&self) -> Option<usize>
returns the account's code size. If None
then the code cache or code size cache isn't available -
get someone who knows to call note_code
.
pub fn is_cached(&self) -> bool
[src]
pub fn is_cached(&self) -> bool
Is code_cache
valid; such that code is going to return Some?
pub fn cache_code(&mut self, db: &HashDB) -> Option<Arc<Bytes>>
[src]
pub fn cache_code(&mut self, db: &HashDB) -> Option<Arc<Bytes>>
Provide a database to get code_hash
. Should not be called if it is a contract without code.
pub fn cache_given_code(&mut self, code: Arc<Bytes>)
[src]
pub fn cache_given_code(&mut self, code: Arc<Bytes>)
Provide code to cache. For correctness, should be the correct code for the account.
pub fn cache_code_size(&mut self, db: &HashDB) -> bool
[src]
pub fn cache_code_size(&mut self, db: &HashDB) -> bool
Provide a database to get code_size
. Should not be called if it is a contract without code.
pub fn storage_is_clean(&self) -> bool
[src]
pub fn storage_is_clean(&self) -> bool
Determine whether there are any un-commit()
-ed storage-setting operations.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Check if account has zero nonce, balance, no code and no storage.
NOTE: Will panic if !self.storage_is_clean()
pub fn is_null(&self) -> bool
[src]
pub fn is_null(&self) -> bool
Check if account has zero nonce, balance, no code.
pub fn is_basic(&self) -> bool
[src]
pub fn is_basic(&self) -> bool
Check if account is basic (Has no code).
pub fn storage_root(&self) -> Option<&H256>
[src]
pub fn storage_root(&self) -> Option<&H256>
Return the storage root associated with this account or None if it has been altered via the overlay.
pub fn storage_changes(&self) -> &HashMap<H256, H256>
[src]
pub fn storage_changes(&self) -> &HashMap<H256, H256>
Return the storage overlay.
pub fn inc_nonce(&mut self)
[src]
pub fn inc_nonce(&mut self)
Increment the nonce of the account by one.
pub fn add_balance(&mut self, x: &U256)
[src]
pub fn add_balance(&mut self, x: &U256)
Increase account balance.
pub fn sub_balance(&mut self, x: &U256)
[src]
pub fn sub_balance(&mut self, x: &U256)
Decrease account balance.
Panics if balance is less than x
pub fn commit_storage(
&mut self,
trie_factory: &TrieFactory,
db: &mut HashDB
) -> Result<()>
[src]
pub fn commit_storage(
&mut self,
trie_factory: &TrieFactory,
db: &mut HashDB
) -> Result<()>
Commit the storage_changes
to the backing DB and update storage_root
.
pub fn commit_code(&mut self, db: &mut HashDB)
[src]
pub fn commit_code(&mut self, db: &mut HashDB)
Commit any unsaved code. code_hash
will always return the hash of the code_cache
after this.
pub fn rlp(&self) -> Bytes
[src]
pub fn rlp(&self) -> Bytes
Export to RLP.
pub fn clone_basic(&self) -> Account
[src]
pub fn clone_basic(&self) -> Account
Clone basic account data
pub fn clone_dirty(&self) -> Account
[src]
pub fn clone_dirty(&self) -> Account
Clone account data and dirty storage keys
pub fn clone_all(&self) -> Account
[src]
pub fn clone_all(&self) -> Account
Clone account data, dirty storage keys and cached storage keys.
pub fn overwrite_with(&mut self, other: Account)
[src]
pub fn overwrite_with(&mut self, other: Account)
Replace self with the data from other account merging storage cache. Basic account data and all modifications are overwritten with new values.
impl Account
[src]
impl Account
pub fn prove_storage(
&self,
db: &HashDB,
storage_key: H256
) -> Result<(Vec<Bytes>, H256), Box<TrieError>>
[src]
pub fn prove_storage(
&self,
db: &HashDB,
storage_key: H256
) -> Result<(Vec<Bytes>, H256), Box<TrieError>>
Prove a storage key's existence or nonexistence in the account's storage
trie.
storage_key
is the hash of the desired storage key, meaning
this will only work correctly under a secure trie.
Trait Implementations
impl From<BasicAccount> for Account
[src]
impl From<BasicAccount> for Account
fn from(basic: BasicAccount) -> Self
[src]
fn from(basic: BasicAccount) -> Self
Performs the conversion.
impl Debug for Account
[src]
impl Debug for Account