Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
FascState Class Reference

#include <fascstate.h>

Inheritance diagram for FascState:
[legend]
Collaboration diagram for FascState:
[legend]

Public Member Functions

 FascState ()
 
 FascState (dev::u256 const &_accountStartNonce, dev::OverlayDB const &_db, const std::string &_path, dev::eth::BaseState _bs=dev::eth::BaseState::PreExisting)
 
ResultExecute execute (dev::eth::EnvInfo const &_envInfo, dev::eth::SealEngineFace const &_sealEngine, FascTransaction const &_t, dev::eth::Permanence _p=dev::eth::Permanence::Committed, dev::eth::OnOpFunc const &_onOp=OnOpFunc())
 
void setRootUTXO (dev::h256 const &_r)
 
void setCacheUTXO (dev::Address const &address, Vin const &vin)
 
dev::h256 rootHashUTXO () const
 
std::unordered_map< dev::Address, Vinvins () const
 
dev::OverlayDB const & dbUtxo () const
 
dev::OverlayDBdbUtxo ()
 
virtual ~FascState ()
 
- Public Member Functions inherited from dev::eth::State
 State (u256 const &_accountStartNonce)
 Default constructor; creates with a blank database prepopulated with the genesis block. More...
 
 State (u256 const &_accountStartNonce, OverlayDB const &_db, BaseState _bs=BaseState::PreExisting)
 Basic state object from database. More...
 
 State (NullType)
 
 State (State const &_s)
 Copy state object. More...
 
Stateoperator= (State const &_s)
 Copy state object. More...
 
OverlayDB const & db () const
 
OverlayDBdb ()
 
void populateFrom (AccountMap const &_map)
 Populate the state from the given AccountMap. Just uses dev::eth::commit(). More...
 
std::unordered_map< Address, u256addresses () const
 
std::pair< ExecutionResult, TransactionReceiptexecute (EnvInfo const &_envInfo, SealEngineFace const &_sealEngine, Transaction const &_t, Permanence _p=Permanence::Committed, OnOpFunc const &_onOp=OnOpFunc())
 Execute a given transaction. More...
 
bool addressInUse (Address const &_address) const
 Check if the address is in use. More...
 
bool accountNonemptyAndExisting (Address const &_address) const
 Check if the account exists in the state and is non empty (nonce > 0 || balance > 0 || code nonempty). More...
 
bool addressHasCode (Address const &_address) const
 Check if the address contains executable code. More...
 
u256 balance (Address const &_id) const
 Get an account's balance. More...
 
void subBalance (Address const &_addr, u256 const &_value)
 Subtract the _value amount from the balance of _addr account. More...
 
h256 storageRoot (Address const &_contract) const
 Get the root of the storage of an account. More...
 
u256 storage (Address const &_contract, u256 const &_memory) const
 Get the value of a storage position of an account. More...
 
void setStorage (Address const &_contract, u256 const &_location, u256 const &_value)
 Set the value of a storage position of an account. More...
 
void createContract (Address const &_address)
 Create a contract at the given address (with unset code and unchanged balance). More...
 
void setNewCode (Address const &_address, bytes &&_code)
 Sets the code of the account. Must only be called during / after contract creation. More...
 
std::map< h256, std::pair< u256, u256 > > storage (Address const &_contract) const
 Get the storage of an account. More...
 
bytes const & code (Address const &_addr) const
 Get the code of an account. More...
 
h256 codeHash (Address const &_contract) const
 Get the code hash of an account. More...
 
size_t codeSize (Address const &_contract) const
 Get the byte-size of the code of an account. More...
 
void incNonce (Address const &_id)
 Increament the account nonce. More...
 
u256 getNonce (Address const &_addr) const
 Get the account nonce – the number of transactions it has sent. More...
 
h256 rootHash () const
 The hash of the root of our state tree. More...
 
void commit (CommitBehaviour _commitBehaviour)
 Commit all changes waiting in the address cache to the DB. More...
 
void setRoot (h256 const &_root)
 Resets any uncommitted changes to the cache. More...
 
u256 const & accountStartNonce () const
 Get the account start nonce. May be required. More...
 
u256 const & requireAccountStartNonce () const
 
void noteAccountStartNonce (u256 const &_actual)
 
size_t savepoint () const
 Create a savepoint in the state changelog. More...
 
void rollback (size_t _savepoint)
 Revert all recent changes up to the given _savepoint savepoint. More...
 
virtual ~State ()
 

Public Attributes

friend CondensingTX
 

Private Member Functions

void transferBalance (dev::Address const &_from, dev::Address const &_to, dev::u256 const &_value)
 Transfers "the balance _value between two accounts. More...
 
Vin const * vin (dev::Address const &_a) const
 
Vinvin (dev::Address const &_addr)
 
void kill (dev::Address _addr)
 Delete an account (used for processing suicides). More...
 
void addBalance (dev::Address const &_id, dev::u256 const &_amount)
 Add some amount to balance. More...
 
dev::Address createFascAddress (dev::h256 hashTx, uint32_t voutNumber)
 
void deleteAccounts (std::set< dev::Address > &addrs)
 
void updateUTXO (const std::unordered_map< dev::Address, Vin > &vins)
 
void printfErrorLog (const dev::eth::TransactionException er)
 

Private Attributes

dev::Address newAddress
 
std::vector< TransferInfotransfers
 
dev::OverlayDB dbUTXO
 
dev::eth::SecureTrieDB< dev::Address, dev::OverlayDBstateUTXO
 
std::unordered_map< dev::Address, VincacheUTXO
 

Additional Inherited Members

- Public Types inherited from dev::eth::State
enum  CommitBehaviour { CommitBehaviour::KeepEmptyAccounts, CommitBehaviour::RemoveEmptyAccounts }
 
enum  NullType { Null }
 
- Static Public Member Functions inherited from dev::eth::State
static OverlayDB openDB (std::string const &_path, h256 const &_genesisHash, WithExisting _we=WithExisting::Trust)
 Open a DB - useful for passing into the constructor & keeping for other states that are necessary. More...
 
- Protected Member Functions inherited from dev::eth::State
void removeEmptyAccounts ()
 Turns all "touched" empty accounts into non-alive accounts. More...
 
Account const * account (Address const &_addr) const
 
Accountaccount (Address const &_addr)
 
void clearCacheIfTooLarge () const
 Purges non-modified entries in m_cache if it grows too large. More...
 
void createAccount (Address const &_address, Account const &&_account)
 
- Protected Attributes inherited from dev::eth::State
OverlayDB m_db
 Our overlay for the state tree. More...
 
SecureTrieDB< Address, OverlayDBm_state
 Our state tree, as an OverlayDB DB. More...
 
std::unordered_map< Address, Accountm_cache
 Our address cache. This stores the states of each address that has (or at least might have) been changed. More...
 
std::vector< Addressm_unchangedCacheEntries
 Tracks entries in m_cache that can potentially be purged if it grows too large. More...
 
std::set< Addressm_nonExistingAccountsCache
 Tracks addresses that are known to not exist. More...
 
AddressHash m_touched
 Tracks all addresses touched so far. More...
 
u256 m_accountStartNonce
 
std::vector< detail::Changem_changeLog
 

Detailed Description

Definition at line 59 of file fascstate.h.

Constructor & Destructor Documentation

FascState::FascState ( )

Definition at line 17 of file fascstate.cpp.

FascState::FascState ( dev::u256 const &  _accountStartNonce,
dev::OverlayDB const &  _db,
const std::string &  _path,
dev::eth::BaseState  _bs = dev::eth::BaseState::PreExisting 
)
virtual FascState::~FascState ( )
inlinevirtual

Definition at line 92 of file fascstate.h.

Member Function Documentation

void FascState::addBalance ( dev::Address const &  _id,
dev::u256 const &  _amount 
)
privatevirtual

Add some amount to balance.

Will initialise the address if it has never been used.

Reimplemented from dev::eth::State.

Definition at line 198 of file fascstate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

dev::Address FascState::createFascAddress ( dev::h256  hashTx,
uint32_t  voutNumber 
)
private

Definition at line 229 of file fascstate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

dev::OverlayDB const& FascState::dbUtxo ( ) const
inline

Definition at line 84 of file fascstate.h.

dev::OverlayDB& FascState::dbUtxo ( )
inline

Definition at line 88 of file fascstate.h.

void FascState::deleteAccounts ( std::set< dev::Address > &  addrs)
private

Definition at line 246 of file fascstate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

ResultExecute FascState::execute ( dev::eth::EnvInfo const &  _envInfo,
dev::eth::SealEngineFace const &  _sealEngine,
FascTransaction const &  _t,
dev::eth::Permanence  _p = dev::eth::Permanence::Committed,
dev::eth::OnOpFunc const &  _onOp = OnOpFunc() 
)

Definition at line 22 of file fascstate.cpp.

Here is the call graph for this function:

void FascState::kill ( dev::Address  _a)
privatevirtual

Delete an account (used for processing suicides).

Reimplemented from dev::eth::State.

Definition at line 189 of file fascstate.cpp.

Here is the call graph for this function:

void FascState::printfErrorLog ( const dev::eth::TransactionException  er)
private

Definition at line 272 of file fascstate.cpp.

Here is the caller graph for this function:

dev::h256 FascState::rootHashUTXO ( ) const
inline

Definition at line 78 of file fascstate.h.

void FascState::setCacheUTXO ( dev::Address const &  address,
Vin const &  vin 
)
inline

Definition at line 74 of file fascstate.h.

void FascState::setRootUTXO ( dev::h256 const &  _r)
inline

Definition at line 69 of file fascstate.h.

void FascState::transferBalance ( dev::Address const &  _from,
dev::Address const &  _to,
dev::u256 const &  _value 
)
privatevirtual

Transfers "the balance _value between two accounts.

Parameters
_fromAccount from which _value will be deducted.
_toAccount to which _value will be added.
_valueAmount to be transferred.

Reimplemented from dev::eth::State.

Definition at line 144 of file fascstate.cpp.

Here is the call graph for this function:

void FascState::updateUTXO ( const std::unordered_map< dev::Address, Vin > &  vins)
private

Definition at line 257 of file fascstate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Vin const * FascState::vin ( dev::Address const &  _a) const
private

Definition at line 151 of file fascstate.cpp.

Here is the caller graph for this function:

Vin * FascState::vin ( dev::Address const &  _addr)
private

Definition at line 156 of file fascstate.cpp.

Here is the call graph for this function:

std::unordered_map< dev::Address, Vin > FascState::vins ( ) const

Definition at line 130 of file fascstate.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::unordered_map<dev::Address, Vin> FascState::cacheUTXO
private

Definition at line 126 of file fascstate.h.

friend FascState::CondensingTX

Definition at line 94 of file fascstate.h.

dev::OverlayDB FascState::dbUTXO
private

Definition at line 122 of file fascstate.h.

dev::Address FascState::newAddress
private

Definition at line 118 of file fascstate.h.

dev::eth::SecureTrieDB<dev::Address, dev::OverlayDB> FascState::stateUTXO
private

Definition at line 124 of file fascstate.h.

std::vector<TransferInfo> FascState::transfers
private

Definition at line 120 of file fascstate.h.


The documentation for this class was generated from the following files: