29 #include <boost/filesystem/path.hpp> 77 Account(
u256 _nonce,
u256 _balance,
h256 _contractRoot,
h256 _codeHash,
Changedness _c): m_isAlive(true), m_isUnchanged(_c ==
Unchanged), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); }
85 m_storageOverlay.clear();
86 m_storageOriginal.clear();
97 bool isAlive()
const {
return m_isAlive; }
100 bool isDirty()
const {
return !m_isUnchanged; }
132 auto mit = m_storageOverlay.find(_key);
133 if (mit != m_storageOverlay.end())
144 std::unordered_map<u256, u256>
const&
storageOverlay()
const {
return m_storageOverlay; }
153 m_storageOverlay.clear();
154 m_storageOriginal.clear();
162 m_storageOverlay.clear();
163 m_storageOriginal.clear();
164 m_storageRoot = _root;
185 void changed() { m_isUnchanged =
false; }
188 bool m_isAlive =
false;
191 bool m_isUnchanged =
false;
194 bool m_hasNewCode =
false;
215 mutable std::unordered_map<u256, u256> m_storageOverlay;
218 mutable std::unordered_map<u256, u256> m_storageOriginal;
225 static const h256 c_contractConceptionCodeHash;
243 bool _shouldNotExist =
false 245 m_hasBalance(_hasBalance),
246 m_hasNonce(_hasNonce),
248 m_hasStorage(_hasStorage),
249 m_shouldNotExist(_shouldNotExist)
252 bool allSet()
const {
return m_hasBalance && m_hasNonce && m_hasCode && m_hasStorage; }
264 bool m_shouldNotExist =
false;
275 const boost::filesystem::path& _configPath = {});
std::unordered_map< Address, PrecompiledContract > PrecompiledContractMap
Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c)
Explicit constructor for wierd cases of construction or a contract account.
Account starts as though it has been changed.
std::unordered_map< Address, Account > AccountMap
std::vector< unsigned char > toBytes() const
u256 storageValue(u256 const &_key, OverlayDB const &_db) const
std::unordered_map< u256, u256 > const & storageOverlay() const
Account()
Construct a dead Account.
Account starts as though it has not been changed.
void noteCode(bytesConstRef _code)
void setNonce(u256 const &_nonce)
bool sha3(bytesConstRef _input, bytesRef o_output) noexcept
AccountMask(bool _all=false)
bytes const & code() const
AccountMask(bool _hasBalance, bool _hasNonce, bool _hasCode, bool _hasStorage, bool _shouldNotExist=false)
void setStorageRoot(h256 const &_root)
Set the storage root. Used when clearStorage() is reverted.
std::vector< byte > bytes
Account(u256 _nonce, u256 _balance, Changedness _c=Changed)
void clearStorage()
Empty the storage. Used when a contract is overwritten.
std::unordered_map< Address, AccountMask > AccountMaskMap
void setCode(bytes &&_code)
Sets the code of the account. Used by "create" messages.
Changedness
Changedness of account to create.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
void addBalance(u256 _value)
Increments the balance of this account by the given amount.
void setStorage(u256 _p, u256 _v)
u256 originalStorageValue(u256 const &_key, OverlayDB const &_db) const
u256 const & balance() const
AccountMap jsonToAccountMap(std::string const &_json, u256 const &_defaultNonce=0, AccountMaskMap *o_mask=nullptr, PrecompiledContractMap *o_precompiled=nullptr, const boost::filesystem::path &_configPath={})
void incNonce()
Increment the nonce of the account by one.