|
| Account () |
| Construct a dead Account. More...
|
|
| Account (u256 _nonce, u256 _balance, Changedness _c=Changed) |
| Construct an alive Account, with given endowment, for either a normal (non-contract) account or for a contract account in the conception phase, where the code is not yet known. More...
|
|
| Account (u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c) |
| Explicit constructor for wierd cases of construction or a contract account. More...
|
|
void | kill () |
| Kill this account. Useful for the suicide opcode. Following this call, isAlive() returns false. More...
|
|
bool | isAlive () const |
|
bool | isDirty () const |
|
void | untouch () |
|
bool | isEmpty () const |
|
u256 const & | balance () const |
|
void | addBalance (u256 _value) |
| Increments the balance of this account by the given amount. More...
|
|
u256 | nonce () const |
|
void | incNonce () |
| Increment the nonce of the account by one. More...
|
|
void | setNonce (u256 const &_nonce) |
| Set nonce to a new value. More...
|
|
h256 | baseRoot () const |
|
std::unordered_map< u256, u256 > const & | storageOverlay () const |
|
void | setStorage (u256 _p, u256 _v) |
| Set a key/value pair in the account's storage. More...
|
|
void | setStorageCache (u256 _p, u256 _v) const |
| Set a key/value pair in the account's storage to a value that is already present inside the database. More...
|
|
h256 | codeHash () const |
|
bool | hasNewCode () const |
|
void | setNewCode (bytes &&_code) |
| Sets the code of the account. Used by "create" messages. More...
|
|
void | resetCode () |
| Reset the code set by previous CREATE message. More...
|
|
void | noteCode (bytesConstRef _code) |
| Specify to the object what the actual code is for the account. More...
|
|
bytes const & | code () const |
|
Models the state of a single Ethereum account.
Used to cache a portion of the full Ethereum state. State keeps a mapping of Address's to Accounts.
Aside from storing the nonce and balance, the account may also be "dead" (where isAlive() returns false). This allows State to explicitly store the notion of a deleted account in it's cache. kill() can be used for this.
For the account's storage, the class operates a cache. baseRoot() specifies the base state of the storage given as the Trie root to be looked up in the state database. Alterations beyond this base are specified in the overlay, stored in this class and retrieved with storageOverlay(). setStorage allows the overlay to be altered.
The code handling explicitly supports a two-stage commit model needed for contract-creation. When creating a contract (running the initialisation code), the code of the account is considered empty. The attribute of emptiness can be retrieved with codeBearing(). After initialisation one must set the code accordingly; the code of the Account can be set with setCode(). To validate a setCode() call, this class records the state of being in contract-creation (and thus in a state where setCode may validly be called). It can be determined through isFreshCode().
The code can be retrieved through code(), and its hash through codeHash(). codeHash() is only valid when the account is not in the contract-creation phase (i.e. when isFreshCode() returns false). This class supports populating code on-demand from the state database. To determine if the code has been prepopulated call codeCacheValid(). To populate the code, look it up with codeHash() and populate with noteCode().
- Todo:
- : need to make a noteCodeCommitted().
The constructor allows you to create an one of a number of "types" of accounts. The default constructor makes a dead account (this is ignored by State when writing out the Trie). Another three allow a basic or contract account to be specified along with an initial balance. The fina two allow either a basic or a contract account to be created with arbitrary values.
Definition at line 67 of file Account.h.