![]() |
Fabcoin Core
0.16.2
P2P Digital Currency
|
Active model of a block within the block chain. More...
#include <Block.h>
Public Types | |
enum | NullType { Null } |
Public Member Functions | |
Block (u256 const &_accountStartNonce) | |
Default constructor; creates with a blank database prepopulated with the genesis block. More... | |
Block (BlockChain const &_bc, OverlayDB const &_db, BaseState _bs=BaseState::PreExisting, Address const &_author=Address()) | |
Basic state object from database. More... | |
Block (BlockChain const &_bc, OverlayDB const &_db, h256 const &_root, Address const &_author=Address()) | |
Basic state object from database. More... | |
Block (NullType) | |
Block (BlockChain const &_bc) | |
Construct from a given blockchain. Empty, but associated with _bc 's chain params. More... | |
Block (Block const &_s) | |
Copy state object. More... | |
Block & | operator= (Block const &_s) |
Copy state object. More... | |
Address | author () const |
Get the author address for any transactions we do and rewards we get. More... | |
void | setAuthor (Address const &_id) |
Set the author address for any transactions we do and rewards we get. More... | |
void | noteChain (BlockChain const &_bc) |
Note the fact that this block is being used with a particular chain. More... | |
u256 | balance (Address const &_address) const |
Get an account's balance. More... | |
u256 | transactionsFrom (Address const &_address) const |
Get the number of transactions a particular address has sent (used for the transaction nonce). More... | |
bool | addressInUse (Address const &_address) const |
Check if the address is in use. More... | |
bool | addressHasCode (Address const &_address) const |
Check if the address contains executable code. 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... | |
std::map< h256, std::pair< u256, u256 > > | storage (Address const &_contract) const |
Get the storage of an account. More... | |
bytes const & | code (Address const &_contract) const |
Get the code of an account. More... | |
h256 | codeHash (Address const &_contract) const |
Get the code hash of an account. More... | |
State const & | state () const |
Get the backing state object. More... | |
OverlayDB const & | db () const |
Open a DB - useful for passing into the constructor & keeping for other states that are necessary. More... | |
h256 | rootHash () const |
The hash of the root of our state tree. More... | |
std::unordered_map< Address, u256 > | addresses () const |
State & | mutableState () |
Get a mutable State object which is backing this block. More... | |
u256 | gasLimitRemaining () const |
Get the remaining gas limit in this block. More... | |
Transactions const & | pending () const |
Get the list of pending transactions. More... | |
h256Hash const & | pendingHashes () const |
Get the list of hashes of pending transactions. More... | |
TransactionReceipt const & | receipt (unsigned _i) const |
Get the transaction receipt for the transaction of the given index. More... | |
LogEntries const & | log (unsigned _i) const |
Get the list of pending transactions. More... | |
LogBloom | logBloom () const |
Get the bloom filter of all logs that happened in the block. More... | |
LogBloom const & | logBloom (unsigned _i) const |
Get the bloom filter of a particular transaction that happened in the block. More... | |
State | fromPending (unsigned _i) const |
Get the State immediately after the given number of pending transactions have been applied. More... | |
PopulationStatistics | populateFromChain (BlockChain const &_bc, h256 const &_hash, ImportRequirements::value _ir=ImportRequirements::None) |
Construct state object from arbitrary point in blockchain. More... | |
ExecutionResult | execute (LastHashes const &_lh, Transaction const &_t, Permanence _p=Permanence::Committed, OnOpFunc const &_onOp=OnOpFunc()) |
Execute a given transaction. More... | |
std::pair< TransactionReceipts, bool > | sync (BlockChain const &_bc, TransactionQueue &_tq, GasPricer const &_gp, unsigned _msTimeout=100) |
Sync our transactions, killing those from the queue that we have and assimilating those that we don't. More... | |
bool | sync (BlockChain const &_bc) |
Sync our state with the block chain. More... | |
bool | sync (BlockChain const &_bc, h256 const &_blockHash, BlockHeader const &_bi=BlockHeader()) |
Sync with the block chain, but rather than synching to the latest block, instead sync to the given block. More... | |
u256 | enactOn (VerifiedBlockRef const &_block, BlockChain const &_bc) |
Execute all transactions within a given block. More... | |
void | cleanup (bool _fullCommit) |
Returns back to a pristine state after having done a playback. More... | |
void | resetCurrent (u256 const &_timestamp=u256(utcTime())) |
Sets m_currentBlock to a clean state, (i.e. More... | |
void | commitToSeal (BlockChain const &_bc, bytes const &_extraData={}) |
Prepares the current state for mining. More... | |
bool | sealBlock (bytes const &_header) |
Pass in a properly sealed header matching this block. More... | |
bool | sealBlock (bytesConstRef _header) |
bool | isSealed () const |
bytes const & | blockData () const |
Get the complete current block, including valid nonce. More... | |
BlockHeader const & | info () const |
Get the header information on the present block. More... | |
Private Member Functions | |
SealEngineFace * | sealEngine () const |
void | uncommitToSeal () |
Undo the changes to the state for committing to mine. More... | |
void | ensureCached (Address const &_a, bool _requireCode, bool _forceCreate) const |
Retrieve all information about a given address into the cache. More... | |
void | ensureCached (std::unordered_map< Address, Account > &_cache, Address const &_a, bool _requireCode, bool _forceCreate) const |
Retrieve all information about a given address into a cache. More... | |
u256 | enact (VerifiedBlockRef const &_block, BlockChain const &_bc) |
Execute the given block, assuming it corresponds to m_currentBlock. More... | |
void | applyRewards (std::vector< BlockHeader > const &_uncleBlockHeaders, u256 const &_blockReward) |
Finalise the block, applying the earned rewards. More... | |
u256 | gasUsed () const |
void | performIrregularModifications () |
Performs irregular modifications right after initialization, e.g. to implement a hard fork. More... | |
std::string | vmTrace (bytesConstRef _block, BlockChain const &_bc, ImportRequirements::value _ir) |
Provide a standard VM trace for debugging purposes. More... | |
Private Attributes | |
State | m_state |
Our state tree, as an OverlayDB DB. More... | |
Transactions | m_transactions |
The current list of transactions that we've included in the state. More... | |
TransactionReceipts | m_receipts |
The corresponding list of transaction receipts. More... | |
h256Hash | m_transactionSet |
The set of transaction hashes that we've included in the state. More... | |
State | m_precommit |
State at the point immediately prior to rewards. More... | |
BlockHeader | m_previousBlock |
The previous block's information. More... | |
BlockHeader | m_currentBlock |
The current block's information. More... | |
bytes | m_currentBytes |
The current block's bytes. More... | |
bool | m_committedToSeal = false |
Have we committed to mine on the present m_currentBlock? More... | |
bytes | m_currentTxs |
The RLP-encoded block of transactions. More... | |
bytes | m_currentUncles |
The RLP-encoded block of uncles. More... | |
Address | m_author |
Our address (i.e. the address to which fees go). More... | |
SealEngineFace * | m_sealEngine = nullptr |
The chain's seal engine. More... | |
Friends | |
class | ExtVM |
class | dev::test::ImportTest |
class | dev::test::StateLoader |
class | Executive |
class | BlockChain |
std::ostream & | operator<< (std::ostream &_out, Block const &_s) |
Active model of a block within the block chain.
Keeps track of all transactions, receipts and state for a particular block. Can apply all needed transforms of the state for rewards and contains logic for sealing the block.
|
inline |
Block::Block | ( | BlockChain const & | _bc, |
OverlayDB const & | _db, | ||
BaseState | _bs = BaseState::PreExisting , |
||
Address const & | _author = Address() |
||
) |
Basic state object from database.
Use the default when you already have a database and you just want to make a Block object which uses it. If you have no preexisting database then set BaseState to something other than BaseState::PreExisting in order to prepopulate the Trie. You can also set the author address.
Definition at line 55 of file Block.cpp.
Block::Block | ( | BlockChain const & | _bc, |
OverlayDB const & | _db, | ||
h256 const & | _root, | ||
Address const & | _author = Address() |
||
) |
Basic state object from database.
Use the default when you already have a database and you just want to make a Block object which uses it. Will throw InvalidRoot if the root passed is not in the database. You can also set the author address.
Definition at line 66 of file Block.cpp.
|
inlineexplicit |
InterfaceNotSupported | if compiled without ETH_FATDB. |
|
inline |
|
inline |
|
private |
|
inline |
|
inline |
Get the complete current block, including valid nonce.
Only valid when isSealed() is true.
Definition at line 276 of file Block.h.
void Block::cleanup | ( | bool | _fullCommit | ) |
Returns back to a pristine state after having done a playback.
Definition at line 851 of file Block.cpp.
void Block::commitToSeal | ( | BlockChain const & | _bc, |
bytes const & | _extraData = {} |
||
) |
Prepares the current state for mining.
Commits all transactions into the trie, compiles uncles and transactions list, applies all rewards and populates the current block header with the appropriate hashes. The only thing left to do after this is to actually mine().
This may be called multiple times and without issue.
Definition at line 695 of file Block.cpp.
|
inline |
|
private |
u256 Block::enactOn | ( | VerifiedBlockRef const & | _block, |
BlockChain const & | _bc | ||
) |
|
private |
Retrieve all information about a given address into the cache.
If _requireMemory is true, grab the full memory should it be a contract item. If _forceCreate is true, then insert a default item into the cache, in the case it doesn't exist in the DB.
|
private |
Retrieve all information about a given address into a cache.
ExecutionResult Block::execute | ( | LastHashes const & | _lh, |
Transaction const & | _t, | ||
Permanence | _p = Permanence::Committed , |
||
OnOpFunc const & | _onOp = OnOpFunc() |
||
) |
State Block::fromPending | ( | unsigned | _i | ) | const |
Get the State immediately after the given number of pending transactions have been applied.
If (_i == 0) returns the initial state of the block. If (_i == pending().size()) returns the final state of the block, prior to rewards.
Definition at line 832 of file Block.cpp.
|
inline |
|
inlineprivate |
|
inline |
|
inline |
|
inline |
LogBloom Block::logBloom | ( | ) | const |
|
inline |
|
inline |
void Block::noteChain | ( | BlockChain const & | _bc | ) |
|
inline |
|
inline |
|
private |
PopulationStatistics Block::populateFromChain | ( | BlockChain const & | _bc, |
h256 const & | _hash, | ||
ImportRequirements::value | _ir = ImportRequirements::None |
||
) |
|
inline |
|
inline |
|
inline |
Pass in a properly sealed header matching this block.
Definition at line 268 of file Block.h.
bool Block::sealBlock | ( | bytesConstRef | _header | ) |
|
private |
|
inline |
|
inline |
pair< TransactionReceipts, bool > Block::sync | ( | BlockChain const & | _bc, |
TransactionQueue & | _tq, | ||
GasPricer const & | _gp, | ||
unsigned | _msTimeout = 100 |
||
) |
Sync our transactions, killing those from the queue that we have and assimilating those that we don't.
Definition at line 301 of file Block.cpp.
bool Block::sync | ( | BlockChain const & | _bc | ) |
bool Block::sync | ( | BlockChain const & | _bc, |
h256 const & | _blockHash, | ||
BlockHeader const & | _bi = BlockHeader() |
||
) |
|
private |
|
private |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |