Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::eth::Client Class Reference

Main API hub for interfacing with Ethereum. More...

#include <Client.h>

Inheritance diagram for dev::eth::Client:
dev::eth::ClientBase dev::Worker dev::eth::Interface dev::eth::ClientTest

Public Member Functions

 Client (ChainParams const &_params, int _networkID, p2p::Host &_host, std::shared_ptr< GasPricer > _gpForAdoption, boost::filesystem::path const &_dbPath=boost::filesystem::path(), boost::filesystem::path const &_snapshotPath=boost::filesystem::path(), WithExisting _forceAction=WithExisting::Trust, TransactionQueue::Limits const &_l=TransactionQueue::Limits{1024, 1024})
 
virtual ~Client ()
 Destructor. More...
 
ChainParams const & chainParams () const
 Get information on this chain. More...
 
void setGasPricer (std::shared_ptr< GasPricer > _gp)
 Resets the gas pricer to some other object. More...
 
std::shared_ptr< GasPricergasPricer () const
 
h256 submitTransaction (TransactionSkeleton const &_t, Secret const &_secret) override
 
h256 importTransaction (Transaction const &_t) override
 Imports the given transaction into the transaction queue. More...
 
ExecutionResult call (Address const &_secret, u256 _value, Address _dest, bytes const &_data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff=FudgeFactor::Strict) override
 Makes the given call. Nothing is recorded into the state. More...
 
void flushTransactions () override
 Blocks until all pending transactions have been processed. More...
 
Transactions pending () const override
 Retrieve pending transactions. More...
 
ImportResult queueBlock (bytes const &_block, bool _isSafe=false)
 Queues a block for import. More...
 
u256 gasLimitRemaining () const override
 Get the remaining gas limit in this block. More...
 
u256 gasBidPrice () const override
 Get the gas bid price. More...
 
dev::eth::Block block (h256 const &_blockHash, PopulationStatistics *o_stats) const
 Get the block. More...
 
dev::eth::Block postState () const
 Get the object representing the current state of Ethereum. More...
 
BlockChain const & blockChain () const
 Get the object representing the current canonical blockchain. More...
 
BlockQueueStatus blockQueueStatus () const
 Get some information on the block queue. More...
 
SyncStatus syncStatus () const override
 Get some information on the block syncing. More...
 
TransactionSkeleton populateTransactionWithDefaults (TransactionSkeleton const &_t) const override
 Populate the uninitialized fields in the supplied transaction with default values. More...
 
BlockQueue const & blockQueue () const
 Get the block queue. More...
 
OverlayDB const & stateDB () const
 Get the state database. More...
 
TransactionQueue::Status transactionQueueStatus () const
 Get some information on the transaction queue. More...
 
TransactionQueue::Limits transactionQueueLimits () const
 
std::tuple< ImportRoute, bool, unsigned > syncQueue (unsigned _max=1)
 Freeze worker thread and sync some of the block queue. More...
 
Address author () const override
 Get the block author address. More...
 
void setAuthor (Address const &_us) override
 Set the block author address. More...
 
strings sealers () const
 Type of sealers available for this seal engine. More...
 
std::string sealer () const
 Current sealer in use. More...
 
void setSealer (std::string const &_id)
 Change sealer. More...
 
bytes sealOption (std::string const &_name) const
 Review option for the sealer. More...
 
bool setSealOption (std::string const &_name, bytes const &_value)
 Set option for the sealer. More...
 
void startSealing () override
 Start sealing. More...
 
void stopSealing () override
 Stop sealing. More...
 
bool wouldSeal () const override
 Are we sealing now? More...
 
bool isSyncing () const override
 Are we updating the chain (syncing or importing a new block)? More...
 
bool isMajorSyncing () const override
 Are we syncing the chain? More...
 
u256 networkId () const override
 Gets the network id. More...
 
void setNetworkId (u256 const &_n) override
 Sets the network id. More...
 
SealEngineFacesealEngine () const override
 Get the seal engine. More...
 
DownloadMan const * downloadMan () const
 
void clearPending ()
 Clears pending transactions. Just for debug use. More...
 
void killChain ()
 Kills the blockchain. Just for debug use. More...
 
void reopenChain (ChainParams const &_p, WithExisting _we=WithExisting::Trust)
 Reloads the blockchain. Just for debug use. More...
 
void reopenChain (WithExisting _we)
 
void retryUnknown ()
 Retries all blocks with unknown parents. More...
 
ActivityReport activityReport ()
 Get a report of activity. More...
 
void setExtraData (bytes const &_extraData)
 Set the extra data that goes into sealed blocks. More...
 
void rewind (unsigned _n)
 Rewind to a prior head. More...
 
void rescue ()
 Rescue the chain. More...
 
std::unique_ptr< StateImporterFacecreateStateImporter ()
 
std::unique_ptr< BlockChainImporterFacecreateBlockChainImporter ()
 
void executeInMainThread (std::function< void()> const &_function)
 Queues a function to be executed in the main thread (that owns the blockchain, etc). More...
 
Block block (h256 const &_block) const override
 
void startWorking ()
 should be called after the constructor of the most derived class finishes. More...
 
Handler< bytes const & > setOnBlockSealed (std::function< void(bytes const &)> _handler)
 Change the function that is called when a new block is sealed. More...
 
Handler< h256s const &, h256s const & > setOnChainChanged (std::function< void(h256s const &, h256s const &)> _handler)
 Change the function that is called when blockchain was changed. More...
 
std::tuple< h256, h256, h256getWork () override
 
virtual Block block (h256 const &_h) const=0
 
- Public Member Functions inherited from dev::eth::ClientBase
 ClientBase ()
 
virtual ~ClientBase ()
 
std::pair< u256, ExecutionResultestimateGas (Address const &_from, u256 _value, Address _dest, bytes const &_data, int64_t _maxGas, u256 _gasPrice, BlockNumber _blockNumber, GasEstimationCallback const &_callback) override
 
u256 balanceAt (Address _a, BlockNumber _block) const override
 
u256 countAt (Address _a, BlockNumber _block) const override
 
u256 stateAt (Address _a, u256 _l, BlockNumber _block) const override
 
h256 stateRootAt (Address _a, BlockNumber _block) const override
 
bytes codeAt (Address _a, BlockNumber _block) const override
 
h256 codeHashAt (Address _a, BlockNumber _block) const override
 
std::map< h256, std::pair< u256, u256 > > storageAt (Address _a, BlockNumber _block) const override
 
LocalisedLogEntries logs (unsigned _watchId) const override
 
LocalisedLogEntries logs (LogFilter const &_filter) const override
 
virtual void prependLogsFromBlock (LogFilter const &_filter, h256 const &_blockHash, BlockPolarity _polarity, LocalisedLogEntries &io_logs) const
 
unsigned installWatch (LogFilter const &_filter, Reaping _r=Reaping::Automatic) override
 Install, uninstall and query watches. More...
 
unsigned installWatch (h256 _filterId, Reaping _r=Reaping::Automatic) override
 
bool uninstallWatch (unsigned _watchId) override
 
LocalisedLogEntries peekWatch (unsigned _watchId) const override
 
LocalisedLogEntries checkWatch (unsigned _watchId) override
 
h256 hashFromNumber (BlockNumber _number) const override
 
BlockNumber numberFromHash (h256 _blockHash) const override
 
int compareBlockHashes (h256 _h1, h256 _h2) const override
 
BlockHeader blockInfo (h256 _hash) const override
 
BlockDetails blockDetails (h256 _hash) const override
 
Transaction transaction (h256 _transactionHash) const override
 
LocalisedTransaction localisedTransaction (h256 const &_transactionHash) const override
 
Transaction transaction (h256 _blockHash, unsigned _i) const override
 
LocalisedTransaction localisedTransaction (h256 const &_blockHash, unsigned _i) const override
 
TransactionReceipt transactionReceipt (h256 const &_transactionHash) const override
 
LocalisedTransactionReceipt localisedTransactionReceipt (h256 const &_transactionHash) const override
 
std::pair< h256, unsigned > transactionLocation (h256 const &_transactionHash) const override
 
Transactions transactions (h256 _blockHash) const override
 
Transactions transactions (BlockNumber _block) const override
 
TransactionHashes transactionHashes (h256 _blockHash) const override
 
BlockHeader uncle (h256 _blockHash, unsigned _i) const override
 
UncleHashes uncleHashes (h256 _blockHash) const override
 
unsigned transactionCount (h256 _blockHash) const override
 
unsigned transactionCount (BlockNumber _block) const override
 
unsigned uncleCount (h256 _blockHash) const override
 
unsigned number () const override
 
h256s pendingHashes () const override
 
BlockHeader pendingInfo () const override
 
BlockDetails pendingDetails () const override
 
EVMSchedule evmSchedule () const override
 
ImportResult injectBlock (bytes const &_block) override
 Injects the RLP-encoded block given by the _rlp into the block queue directly. More...
 
Addresses addresses (BlockNumber _block) const override
 
u256 gasLimitRemaining () const override
 Get the remaining gas limit in this block. More...
 
u256 gasBidPrice () const override
 
Address author () const override
 Get the block author. More...
 
bool isKnown (h256 const &_hash) const override
 
bool isKnown (BlockNumber _block) const override
 
bool isKnownTransaction (h256 const &_transactionHash) const override
 
bool isKnownTransaction (h256 const &_blockHash, unsigned _i) const override
 
void startSealing () override
 
void stopSealing () override
 
bool wouldSeal () const override
 Would we like to be sealing now? More...
 
SyncStatus syncStatus () const override
 Get some information on the block queue. More...
 
Block blockByNumber (BlockNumber _h) const
 
int chainId () const override
 Gets the chain id. More...
 
u256 balanceAt (Address _a) const
 
virtual u256 balanceAt (Address _a, BlockNumber _block) const=0
 
u256 countAt (Address _a) const
 
virtual u256 countAt (Address _a, BlockNumber _block) const=0
 
u256 stateAt (Address _a, u256 _l) const
 
virtual u256 stateAt (Address _a, u256 _l, BlockNumber _block) const=0
 
bytes codeAt (Address _a) const
 
virtual bytes codeAt (Address _a, BlockNumber _block) const=0
 
h256 codeHashAt (Address _a) const
 
virtual h256 codeHashAt (Address _a, BlockNumber _block) const=0
 
std::map< h256, std::pair< u256, u256 > > storageAt (Address _a) const
 
virtual std::map< h256, std::pair< u256, u256 > > storageAt (Address _a, BlockNumber _block) const=0
 
virtual Addresses addresses () const
 
virtual Addresses addresses (BlockNumber _block) const=0
 
- Public Member Functions inherited from dev::eth::Interface
 Interface ()
 Constructor. More...
 
virtual ~Interface ()
 Destructor. More...
 
void submitTransaction (Secret const &_secret, u256 const &_value, Address const &_dest, bytes const &_data=bytes(), u256 const &_gas=1000000, u256 const &_gasPrice=DefaultGasPrice, u256 const &_nonce=Invalid256)
 Submits the given message-call transaction. More...
 
ExecutionResult call (Address const &_from, u256 _value, Address _dest, bytes const &_data=bytes(), u256 _gas=1000000, u256 _gasPrice=DefaultGasPrice, FudgeFactor _ff=FudgeFactor::Strict)
 
ExecutionResult call (Secret const &_secret, u256 _value, Address _dest, bytes const &_data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff=FudgeFactor::Strict)
 
ExecutionResult call (Secret const &_secret, u256 _value, Address _dest, bytes const &_data, u256 _gas, u256 _gasPrice, FudgeFactor _ff=FudgeFactor::Strict)
 
int getDefault () const
 
void setDefault (BlockNumber _block)
 
u256 balanceAt (Address _a) const
 
u256 countAt (Address _a) const
 
u256 stateAt (Address _a, u256 _l) const
 
bytes codeAt (Address _a) const
 
h256 codeHashAt (Address _a) const
 
std::map< h256, std::pair< u256, u256 > > storageAt (Address _a) const
 
LocalisedLogEntries peekWatchSafe (unsigned _watchId) const
 
LocalisedLogEntries checkWatchSafe (unsigned _watchId)
 
BlockHeader blockInfo (BlockNumber _block) const
 
BlockDetails blockDetails (BlockNumber _block) const
 
Transaction transaction (BlockNumber _block, unsigned _i) const
 
TransactionHashes transactionHashes (BlockNumber _block) const
 
BlockHeader uncle (BlockNumber _block, unsigned _i) const
 
UncleHashes uncleHashes (BlockNumber _block) const
 
unsigned uncleCount (BlockNumber _block) const
 
virtual Addresses addresses () const
 

Protected Member Functions

void init (p2p::Host &_extNet, boost::filesystem::path const &_dbPath, boost::filesystem::path const &_snapshotPath, WithExisting _forceAction, u256 _networkId)
 
BlockChainbc () override
 InterfaceStub methods. More...
 
BlockChain const & bc () const override
 
Block preSeal () const override
 
Block postSeal () const override
 
void prepareForTransaction () override
 
void appendFromNewPending (TransactionReceipt const &_receipt, h256Hash &io_changed, h256 _sha3)
 
void appendFromBlock (h256 const &_blockHash, BlockPolarity _polarity, h256Hash &io_changed)
 
void noteChanged (h256Hash const &_filters)
 
virtual bool submitSealed (bytes const &_s)
 Submit. More...
 
void startedWorking () override
 Called when Worker is starting. More...
 
void doWork (bool _doWait)
 Do some work. Handles blockchain maintenance and sealing. More...
 
void doWork () override
 Called continuously following sleep for m_idleWaitMs. More...
 
void doneWorking () override
 Called when Worker is exiting. More...
 
void rejigSealing ()
 Called when wouldSeal(), pendingTransactions() have changed. More...
 
void onDeadBlocks (h256s const &_blocks, h256Hash &io_changed)
 Called on chain changes. More...
 
virtual void onNewBlocks (h256s const &_blocks, h256Hash &io_changed)
 Called on chain changes. More...
 
void resyncStateFromChain ()
 Called after processing blocks by onChainChanged(_ir) More...
 
void restartMining ()
 Update m_preSeal, m_working, m_postSeal blocks from the latest state of the chain. More...
 
void resetState ()
 Clear working state of transactions. More...
 
void onChainChanged (ImportRoute const &_ir)
 
void syncBlockQueue ()
 Signal handler for when the block queue needs processing. More...
 
void syncTransactionQueue ()
 Signal handler for when the block queue needs processing. More...
 
void onTransactionQueueReady ()
 Magically called when m_tq needs syncing. Be nice and don't block. More...
 
void onBlockQueueReady ()
 Magically called when m_bq needs syncing. Be nice and don't block. More...
 
void onPostStateChanged ()
 
void checkWatchGarbage ()
 Does garbage collection on watches. More...
 
void tick ()
 Ticks various system-level objects. More...
 
void onBadBlock (Exception &_ex) const
 
void callQueuedFunctions ()
 Executes the pending functions in m_functionQueue. More...
 
bool shouldServeWork () const
 Is there an active and valid remote worker? More...
 
bool remoteActive () const
 
- Protected Member Functions inherited from dev::Worker
 Worker (std::string const &_name="anon", unsigned _idleWaitMs=30)
 
 Worker (Worker &&_m)
 Move-constructor. More...
 
Workeroperator= (Worker &&_m)
 Move-assignment. More...
 
virtual ~Worker ()
 
void setName (std::string _n)
 Allows changing worker name if work is stopped. More...
 
void startWorking ()
 Starts worker thread; causes startedWorking() to be called. More...
 
void stopWorking ()
 Stop worker thread; causes call to stopWorking(). More...
 
bool isWorking () const
 Returns if worker thread is present. More...
 
virtual void workLoop ()
 Overrides doWork(); should call shouldStop() often and exit when true. More...
 
bool shouldStop () const
 
void terminate ()
 Blocks caller into worker thread has finished. More...
 

Protected Attributes

BlockChain m_bc
 Maintains block database and owns the seal engine. More...
 
BlockQueue m_bq
 Maintains a list of incoming blocks not yet on the blockchain (to be imported). More...
 
TransactionQueue m_tq
 Maintains a list of incoming transactions not yet in a block on the blockchain. More...
 
std::shared_ptr< GasPricerm_gp
 The gas pricer. More...
 
OverlayDB m_stateDB
 Acts as the central point for the state database, so multiple States can share it. More...
 
SharedMutex x_preSeal
 Lock on m_preSeal. More...
 
Block m_preSeal
 The present state of the client. More...
 
SharedMutex x_postSeal
 Lock on m_postSeal. More...
 
Block m_postSeal
 The state of the client which we're sealing (i.e. it'll have all the rewards added). More...
 
SharedMutex x_working
 Lock on m_working. More...
 
Block m_working
 The state of the client which we're sealing (i.e. it'll have all the rewards added), while we're actually working on it. More...
 
BlockHeader m_sealingInfo
 The header we're attempting to seal on (derived from m_postSeal). More...
 
std::atomic< bool > m_remoteWorking = { false }
 Has the remote worker recently been reset? More...
 
std::atomic< bool > m_needStateReset = { false }
 Need reset working state to premin on next sync. More...
 
std::chrono::system_clock::time_point m_lastGetWork
 Is there an active and valid remote worker? More...
 
std::weak_ptr< EthereumCapabilitym_host
 
std::weak_ptr< WarpCapabilitym_warpHost
 
std::condition_variable m_signalled
 
Mutex x_signalled
 
Handler m_tqReady
 
Handler< h256 const & > m_tqReplaced
 
Handler m_bqReady
 
std::atomic< bool > m_wouldSeal = { false }
 True if we /should/ be sealing. More...
 
bool m_wouldButShouldnot = false
 True if the last time we called rejigSealing wouldSeal() was true but sealer's shouldSeal() was false. More...
 
std::chrono::system_clock::time_point m_lastGarbageCollection
 When did we last both doing GC on the watches? More...
 
std::chrono::system_clock::time_point m_lastTick = std::chrono::system_clock::now()
 When did we last tick()? More...
 
unsigned m_syncAmount = 50
 Number of blocks to sync in each go. More...
 
ActivityReport m_report
 
SharedMutex x_functionQueue
 
std::queue< std::function< void()> > m_functionQueue
 Functions waiting to be executed in the main thread. More...
 
std::atomic< bool > m_syncTransactionQueue = {false}
 
std::atomic< bool > m_syncBlockQueue = {false}
 
bytes m_extraData
 
Signal< bytes const & > m_onBlockSealed
 Called if we have sealed a new block. More...
 
Signal< h256s const &, h256s const & > m_onChainChanged
 Called when blockchain was changed. More...
 
Logger m_logger {createLogger(VerbosityInfo, "client")}
 
Logger m_loggerDetail {createLogger(VerbosityDebug, "client")}
 
- Protected Attributes inherited from dev::eth::ClientBase
Mutex x_filtersWatches
 } More...
 
std::unordered_map< h256, InstalledFilterm_filters
 The dictionary of filters that are active. More...
 
std::unordered_map< h256, h256sm_specialFilters = std::unordered_map<h256, std::vector<h256>>{{PendingChangedFilter, {}}, {ChainChangedFilter, {}}}
 The dictionary of special filters and their additional data. More...
 
std::map< unsigned, ClientWatchm_watches
 Each and every watch - these reference a filter. More...
 
Logger m_loggerWatch {createLogger(VerbosityDebug, "watch")}
 
- Protected Attributes inherited from dev::eth::Interface
int m_default = PendingBlock
 

Detailed Description

Main API hub for interfacing with Ethereum.

Definition at line 76 of file Client.h.

Constructor & Destructor Documentation

◆ Client()

Client::Client ( ChainParams const &  _params,
int  _networkID,
p2p::Host &  _host,
std::shared_ptr< GasPricer _gpForAdoption,
boost::filesystem::path const &  _dbPath = boost::filesystem::path(),
boost::filesystem::path const &  _snapshotPath = boost::filesystem::path(),
WithExisting  _forceAction = WithExisting::Trust,
TransactionQueue::Limits const &  _l = TransactionQueue::Limits{1024, 1024} 
)

Definition at line 73 of file Client.cpp.

◆ ~Client()

Client::~Client ( )
virtual

Destructor.

Definition at line 90 of file Client.cpp.

Member Function Documentation

◆ activityReport()

ActivityReport dev::eth::Client::activityReport ( )
inline

Get a report of activity.

Definition at line 199 of file Client.h.

◆ appendFromBlock()

void Client::appendFromBlock ( h256 const &  _blockHash,
BlockPolarity  _polarity,
h256Hash io_changed 
)
protected

Collate the changed filters for the hash of the given block. Insert any filters that are activated into o_changed.

Definition at line 353 of file Client.cpp.

◆ appendFromNewPending()

void Client::appendFromNewPending ( TransactionReceipt const &  _receipt,
h256Hash io_changed,
h256  _sha3 
)
protected

Collate the changed filters for the bloom filter of the given pending transaction. Insert any filters that are activated into o_changed.

Definition at line 334 of file Client.cpp.

◆ author()

Address dev::eth::Client::author ( ) const
inlineoverridevirtual

Get the block author address.

Implements dev::eth::Interface.

Definition at line 147 of file Client.h.

◆ bc() [1/2]

BlockChain const& dev::eth::Client::bc ( ) const
inlineoverrideprotectedvirtual

Implements dev::eth::ClientBase.

Definition at line 242 of file Client.h.

◆ bc() [2/2]

BlockChain& dev::eth::Client::bc ( )
inlineoverrideprotectedvirtual

InterfaceStub methods.

Implements dev::eth::ClientBase.

Definition at line 241 of file Client.h.

◆ block() [1/3]

Block Client::block ( h256 const &  _block) const
overridevirtual

Implements dev::eth::ClientBase.

Definition at line 758 of file Client.cpp.

◆ block() [2/3]

Block Client::block ( h256 const &  _blockHash,
PopulationStatistics o_stats 
) const

Get the block.

Definition at line 774 of file Client.cpp.

◆ block() [3/3]

virtual Block dev::eth::ClientBase::block

◆ blockChain()

BlockChain const& dev::eth::Client::blockChain ( ) const
inline

Get the object representing the current canonical blockchain.

Definition at line 126 of file Client.h.

◆ blockQueue()

BlockQueue const& dev::eth::Client::blockQueue ( ) const
inline

Get the block queue.

Definition at line 134 of file Client.h.

◆ blockQueueStatus()

BlockQueueStatus dev::eth::Client::blockQueueStatus ( ) const
inline

Get some information on the block queue.

Definition at line 128 of file Client.h.

◆ call()

ExecutionResult Client::call ( Address const &  _secret,
u256  _value,
Address  _dest,
bytes const &  _data,
u256  _gas,
u256  _gasPrice,
BlockNumber  _blockNumber,
FudgeFactor  _ff = FudgeFactor::Strict 
)
overridevirtual

Makes the given call. Nothing is recorded into the state.

Implements dev::eth::Interface.

Definition at line 912 of file Client.cpp.

◆ callQueuedFunctions()

void Client::callQueuedFunctions ( )
protected

Executes the pending functions in m_functionQueue.

Definition at line 184 of file Client.cpp.

◆ chainParams()

ChainParams const& dev::eth::Client::chainParams ( ) const
inline

Get information on this chain.

Definition at line 89 of file Client.h.

◆ checkWatchGarbage()

void Client::checkWatchGarbage ( )
protected

Does garbage collection on watches.

Definition at line 725 of file Client.cpp.

◆ clearPending()

void Client::clearPending ( )

Clears pending transactions. Just for debug use.

Definition at line 318 of file Client.cpp.

◆ createBlockChainImporter()

std::unique_ptr<BlockChainImporterFace> dev::eth::Client::createBlockChainImporter ( )
inline

Definition at line 208 of file Client.h.

◆ createStateImporter()

std::unique_ptr<StateImporterFace> dev::eth::Client::createStateImporter ( )
inline

Definition at line 207 of file Client.h.

◆ doneWorking()

void Client::doneWorking ( )
overrideprotectedvirtual

Called when Worker is exiting.

Reimplemented from dev::Worker.

Definition at line 249 of file Client.cpp.

◆ downloadMan()

DownloadMan const* dev::eth::Client::downloadMan ( ) const

◆ doWork() [1/2]

void dev::eth::Client::doWork ( )
inlineoverrideprotectedvirtual

Called continuously following sleep for m_idleWaitMs.

Reimplemented from dev::Worker.

Definition at line 271 of file Client.h.

◆ doWork() [2/2]

void Client::doWork ( bool  _doWait)
protected

Do some work. Handles blockchain maintenance and sealing.

Definition at line 676 of file Client.cpp.

◆ executeInMainThread()

void Client::executeInMainThread ( std::function< void()> const &  _function)

Queues a function to be executed in the main thread (that owns the blockchain, etc).

Definition at line 311 of file Client.cpp.

◆ flushTransactions()

void Client::flushTransactions ( )
overridevirtual

Blocks until all pending transactions have been processed.

Implements dev::eth::Interface.

Definition at line 792 of file Client.cpp.

◆ gasBidPrice()

u256 dev::eth::Client::gasBidPrice ( ) const
inlineoverridevirtual

Get the gas bid price.

Implements dev::eth::Interface.

Definition at line 117 of file Client.h.

◆ gasLimitRemaining()

u256 dev::eth::Client::gasLimitRemaining ( ) const
inlineoverridevirtual

Get the remaining gas limit in this block.

Implements dev::eth::Interface.

Definition at line 115 of file Client.h.

◆ gasPricer()

std::shared_ptr<GasPricer> dev::eth::Client::gasPricer ( ) const
inline

Definition at line 93 of file Client.h.

◆ getWork()

std::tuple< h256, h256, h256 > Client::getWork ( )
overridevirtual

Implements dev::eth::Interface.

Definition at line 934 of file Client.cpp.

◆ importTransaction()

h256 Client::importTransaction ( Transaction const &  _t)
overridevirtual

Imports the given transaction into the transaction queue.

Implements dev::eth::Interface.

Definition at line 880 of file Client.cpp.

◆ init()

void Client::init ( p2p::Host &  _extNet,
boost::filesystem::path const &  _dbPath,
boost::filesystem::path const &  _snapshotPath,
WithExisting  _forceAction,
u256  _networkId 
)
protected

Perform critical setup functions. Must be called in the constructor of the finally derived class.

Definition at line 97 of file Client.cpp.

◆ isMajorSyncing()

bool Client::isMajorSyncing ( ) const
overridevirtual

Are we syncing the chain?

Reimplemented from dev::eth::Interface.

Definition at line 222 of file Client.cpp.

◆ isSyncing()

bool Client::isSyncing ( ) const
overridevirtual

Are we updating the chain (syncing or importing a new block)?

Reimplemented from dev::eth::Interface.

Definition at line 215 of file Client.cpp.

◆ killChain()

void dev::eth::Client::killChain ( )
inline

Kills the blockchain. Just for debug use.

Definition at line 192 of file Client.h.

◆ networkId()

u256 Client::networkId ( ) const
overridevirtual

Gets the network id.

Reimplemented from dev::eth::Interface.

Definition at line 202 of file Client.cpp.

◆ noteChanged()

void Client::noteChanged ( h256Hash const &  _filters)
protected

Record that the set of filters _filters have changed. This doesn't actually make any callbacks, but incrememnts some counters in m_watches.

Definition at line 644 of file Client.cpp.

◆ onBadBlock()

void Client::onBadBlock ( Exception _ex) const
protected

Called when we have attempted to import a bad block.

Warning
May be called from any thread.

Definition at line 170 of file Client.cpp.

◆ onBlockQueueReady()

void dev::eth::Client::onBlockQueueReady ( )
inlineprotected

Magically called when m_bq needs syncing. Be nice and don't block.

Definition at line 307 of file Client.h.

◆ onChainChanged()

void Client::onChainChanged ( ImportRoute const &  _ir)
protected

Magically called when the chain has changed. An import route is provided. Called by either submitWork() or in our main thread through syncBlockQueue().

Definition at line 554 of file Client.cpp.

◆ onDeadBlocks()

void Client::onDeadBlocks ( h256s const &  _blocks,
h256Hash io_changed 
)
protected

Called on chain changes.

Definition at line 457 of file Client.cpp.

◆ onNewBlocks()

void Client::onNewBlocks ( h256s const &  _blocks,
h256Hash io_changed 
)
protectedvirtual

Called on chain changes.

Definition at line 476 of file Client.cpp.

◆ onPostStateChanged()

void Client::onPostStateChanged ( )
protected

Called when the post state has changed (i.e. when more transactions are in it or we're sealing on a new block). This updates m_sealingInfo.

Definition at line 576 of file Client.cpp.

◆ onTransactionQueueReady()

void dev::eth::Client::onTransactionQueueReady ( )
inlineprotected

Magically called when m_tq needs syncing. Be nice and don't block.

Definition at line 304 of file Client.h.

◆ pending()

Transactions Client::pending ( ) const
overridevirtual

Retrieve pending transactions.

Implements dev::eth::Interface.

Definition at line 797 of file Client.cpp.

◆ populateTransactionWithDefaults()

TransactionSkeleton Client::populateTransactionWithDefaults ( TransactionSkeleton const &  _t) const
overridevirtual

Populate the uninitialized fields in the supplied transaction with default values.

Implements dev::eth::Interface.

Definition at line 812 of file Client.cpp.

◆ postSeal()

Block dev::eth::Client::postSeal ( ) const
inlineoverrideprotectedvirtual

Implements dev::eth::ClientBase.

Definition at line 247 of file Client.h.

◆ postState()

dev::eth::Block dev::eth::Client::postState ( ) const
inline

Get the object representing the current state of Ethereum.

Definition at line 124 of file Client.h.

◆ prepareForTransaction()

void Client::prepareForTransaction ( )
overrideprotectedvirtual

Implements dev::eth::ClientBase.

Definition at line 753 of file Client.cpp.

◆ preSeal()

Block dev::eth::Client::preSeal ( ) const
inlineoverrideprotectedvirtual

Returns the state object for the full block (i.e. the terminal state) for index _h. Works properly with LatestBlock and PendingBlock.

Implements dev::eth::ClientBase.

Definition at line 246 of file Client.h.

◆ queueBlock()

ImportResult Client::queueBlock ( bytes const &  _block,
bool  _isSafe = false 
)

Queues a block for import.

Definition at line 157 of file Client.cpp.

◆ rejigSealing()

void Client::rejigSealing ( )
protected

Called when wouldSeal(), pendingTransactions() have changed.

Definition at line 597 of file Client.cpp.

◆ remoteActive()

bool Client::remoteActive ( ) const
protected

Definition at line 571 of file Client.cpp.

◆ reopenChain() [1/2]

void Client::reopenChain ( ChainParams const &  _p,
WithExisting  _we = WithExisting::Trust 
)

Reloads the blockchain. Just for debug use.

Definition at line 269 of file Client.cpp.

◆ reopenChain() [2/2]

void Client::reopenChain ( WithExisting  _we)

Definition at line 264 of file Client.cpp.

◆ rescue()

void dev::eth::Client::rescue ( )
inline

Rescue the chain.

Definition at line 205 of file Client.h.

◆ resetState()

void Client::resetState ( )
protected

Clear working state of transactions.

Definition at line 539 of file Client.cpp.

◆ restartMining()

void Client::restartMining ( )
protected

Update m_preSeal, m_working, m_postSeal blocks from the latest state of the chain.

Definition at line 498 of file Client.cpp.

◆ resyncStateFromChain()

void Client::resyncStateFromChain ( )
protected

Called after processing blocks by onChainChanged(_ir)

Definition at line 489 of file Client.cpp.

◆ retryUnknown()

void dev::eth::Client::retryUnknown ( )
inline

Retries all blocks with unknown parents.

Definition at line 197 of file Client.h.

◆ rewind()

void Client::rewind ( unsigned  _n)

Rewind to a prior head.

Definition at line 849 of file Client.cpp.

◆ sealEngine()

SealEngineFace* dev::eth::Client::sealEngine ( ) const
inlineoverridevirtual

Get the seal engine.

Reimplemented from dev::eth::Interface.

Definition at line 184 of file Client.h.

◆ sealer()

std::string dev::eth::Client::sealer ( ) const
inline

Current sealer in use.

Definition at line 158 of file Client.h.

◆ sealers()

strings dev::eth::Client::sealers ( ) const
inline

Type of sealers available for this seal engine.

Definition at line 156 of file Client.h.

◆ sealOption()

bytes dev::eth::Client::sealOption ( std::string const &  _name) const
inline

Review option for the sealer.

Definition at line 162 of file Client.h.

◆ setAuthor()

void dev::eth::Client::setAuthor ( Address const &  _us)
inlineoverridevirtual

Set the block author address.

Implements dev::eth::Interface.

Definition at line 148 of file Client.h.

◆ setExtraData()

void dev::eth::Client::setExtraData ( bytes const &  _extraData)
inline

Set the extra data that goes into sealed blocks.

Definition at line 201 of file Client.h.

◆ setGasPricer()

void dev::eth::Client::setGasPricer ( std::shared_ptr< GasPricer _gp)
inline

Resets the gas pricer to some other object.

Definition at line 92 of file Client.h.

◆ setNetworkId()

void Client::setNetworkId ( u256 const &  _n)
overridevirtual

Sets the network id.

Reimplemented from dev::eth::Interface.

Definition at line 209 of file Client.cpp.

◆ setOnBlockSealed()

Handler<bytes const&> dev::eth::Client::setOnBlockSealed ( std::function< void(bytes const &)>  _handler)
inline

Change the function that is called when a new block is sealed.

Definition at line 220 of file Client.h.

◆ setOnChainChanged()

Handler<h256s const&, h256s const&> dev::eth::Client::setOnChainChanged ( std::function< void(h256s const &, h256s const &)>  _handler)
inline

Change the function that is called when blockchain was changed.

Get POW depending on sealengine it's using

Definition at line 225 of file Client.h.

◆ setSealer()

void dev::eth::Client::setSealer ( std::string const &  _id)
inline

Change sealer.

Definition at line 160 of file Client.h.

◆ setSealOption()

bool dev::eth::Client::setSealOption ( std::string const &  _name,
bytes const &  _value 
)
inline

Set option for the sealer.

Definition at line 164 of file Client.h.

◆ shouldServeWork()

bool dev::eth::Client::shouldServeWork ( ) const
inlineprotected

Is there an active and valid remote worker?

Returns
true only if it's worth bothering to prep the mining block.

Definition at line 327 of file Client.h.

◆ startedWorking()

void Client::startedWorking ( )
overrideprotectedvirtual

Called when Worker is starting.

Reimplemented from dev::Worker.

Definition at line 232 of file Client.cpp.

◆ startSealing()

void Client::startSealing ( )
overridevirtual

Start sealing.

Implements dev::eth::Interface.

Definition at line 583 of file Client.cpp.

◆ startWorking()

void dev::eth::Client::startWorking ( )
inline

should be called after the constructor of the most derived class finishes.

Definition at line 217 of file Client.h.

◆ stateDB()

OverlayDB const& dev::eth::Client::stateDB ( ) const
inline

Get the state database.

Definition at line 136 of file Client.h.

◆ stopSealing()

void dev::eth::Client::stopSealing ( )
inlineoverridevirtual

Stop sealing.

Implements dev::eth::Interface.

Definition at line 169 of file Client.h.

◆ submitSealed()

bool Client::submitSealed ( bytes const &  _s)
protectedvirtual

Submit.

Definition at line 830 of file Client.cpp.

◆ submitTransaction()

h256 Client::submitTransaction ( TransactionSkeleton const &  _t,
Secret const &  _secret 
)
overridevirtual

Submits the given transaction.

Returns
the new transaction's hash.

Implements dev::eth::Interface.

Definition at line 872 of file Client.cpp.

◆ syncBlockQueue()

void Client::syncBlockQueue ( )
protected

Signal handler for when the block queue needs processing.

Definition at line 384 of file Client.cpp.

◆ syncQueue()

tuple< ImportRoute, bool, unsigned > Client::syncQueue ( unsigned  _max = 1)

Freeze worker thread and sync some of the block queue.

Definition at line 164 of file Client.cpp.

◆ syncStatus()

SyncStatus Client::syncStatus ( ) const
overridevirtual

Get some information on the block syncing.

Implements dev::eth::Interface.

Definition at line 802 of file Client.cpp.

◆ syncTransactionQueue()

void Client::syncTransactionQueue ( )
protected

Signal handler for when the block queue needs processing.

Definition at line 409 of file Client.cpp.

◆ tick()

void Client::tick ( )
protected

Ticks various system-level objects.

Definition at line 712 of file Client.cpp.

◆ transactionQueueLimits()

TransactionQueue::Limits dev::eth::Client::transactionQueueLimits ( ) const
inline

Definition at line 139 of file Client.h.

◆ transactionQueueStatus()

TransactionQueue::Status dev::eth::Client::transactionQueueStatus ( ) const
inline

Get some information on the transaction queue.

Definition at line 138 of file Client.h.

◆ wouldSeal()

bool dev::eth::Client::wouldSeal ( ) const
inlineoverridevirtual

Are we sealing now?

Implements dev::eth::Interface.

Definition at line 171 of file Client.h.

Member Data Documentation

◆ m_bc

BlockChain dev::eth::Client::m_bc
protected

Maintains block database and owns the seal engine.

Definition at line 335 of file Client.h.

◆ m_bq

BlockQueue dev::eth::Client::m_bq
protected

Maintains a list of incoming blocks not yet on the blockchain (to be imported).

Definition at line 336 of file Client.h.

◆ m_bqReady

Handler dev::eth::Client::m_bqReady
protected

Definition at line 361 of file Client.h.

◆ m_extraData

bytes dev::eth::Client::m_extraData
protected

Definition at line 381 of file Client.h.

◆ m_functionQueue

std::queue<std::function<void()> > dev::eth::Client::m_functionQueue
protected

Functions waiting to be executed in the main thread.

Definition at line 376 of file Client.h.

◆ m_gp

std::shared_ptr<GasPricer> dev::eth::Client::m_gp
protected

The gas pricer.

Definition at line 339 of file Client.h.

◆ m_host

std::weak_ptr<EthereumCapability> dev::eth::Client::m_host
protected

Definition at line 353 of file Client.h.

◆ m_lastGarbageCollection

std::chrono::system_clock::time_point dev::eth::Client::m_lastGarbageCollection
mutableprotected

When did we last both doing GC on the watches?

Definition at line 366 of file Client.h.

◆ m_lastGetWork

std::chrono::system_clock::time_point dev::eth::Client::m_lastGetWork
protected

Is there an active and valid remote worker?

Definition at line 351 of file Client.h.

◆ m_lastTick

std::chrono::system_clock::time_point dev::eth::Client::m_lastTick = std::chrono::system_clock::now()
mutableprotected

When did we last tick()?

Definition at line 368 of file Client.h.

◆ m_logger

Logger dev::eth::Client::m_logger {createLogger(VerbosityInfo, "client")}
protected

Definition at line 388 of file Client.h.

◆ m_loggerDetail

Logger dev::eth::Client::m_loggerDetail {createLogger(VerbosityDebug, "client")}
protected

Definition at line 389 of file Client.h.

◆ m_needStateReset

std::atomic<bool> dev::eth::Client::m_needStateReset = { false }
protected

Need reset working state to premin on next sync.

Definition at line 350 of file Client.h.

◆ m_onBlockSealed

Signal<bytes const&> dev::eth::Client::m_onBlockSealed
protected

Called if we have sealed a new block.

Definition at line 383 of file Client.h.

◆ m_onChainChanged

Signal<h256s const&, h256s const&> dev::eth::Client::m_onChainChanged
protected

Called when blockchain was changed.

Definition at line 386 of file Client.h.

◆ m_postSeal

Block dev::eth::Client::m_postSeal
protected

The state of the client which we're sealing (i.e. it'll have all the rewards added).

Definition at line 345 of file Client.h.

◆ m_preSeal

Block dev::eth::Client::m_preSeal
protected

The present state of the client.

Definition at line 343 of file Client.h.

◆ m_remoteWorking

std::atomic<bool> dev::eth::Client::m_remoteWorking = { false }
protected

Has the remote worker recently been reset?

Definition at line 349 of file Client.h.

◆ m_report

ActivityReport dev::eth::Client::m_report
protected

Definition at line 373 of file Client.h.

◆ m_sealingInfo

BlockHeader dev::eth::Client::m_sealingInfo
protected

The header we're attempting to seal on (derived from m_postSeal).

Definition at line 348 of file Client.h.

◆ m_signalled

std::condition_variable dev::eth::Client::m_signalled
protected

Definition at line 356 of file Client.h.

◆ m_stateDB

OverlayDB dev::eth::Client::m_stateDB
protected

Acts as the central point for the state database, so multiple States can share it.

Definition at line 341 of file Client.h.

◆ m_syncAmount

unsigned dev::eth::Client::m_syncAmount = 50
protected

Number of blocks to sync in each go.

Definition at line 371 of file Client.h.

◆ m_syncBlockQueue

std::atomic<bool> dev::eth::Client::m_syncBlockQueue = {false}
protected

Definition at line 379 of file Client.h.

◆ m_syncTransactionQueue

std::atomic<bool> dev::eth::Client::m_syncTransactionQueue = {false}
protected

Definition at line 378 of file Client.h.

◆ m_tq

TransactionQueue dev::eth::Client::m_tq
protected

Maintains a list of incoming transactions not yet in a block on the blockchain.

Definition at line 337 of file Client.h.

◆ m_tqReady

Handler dev::eth::Client::m_tqReady
protected

Definition at line 359 of file Client.h.

◆ m_tqReplaced

Handler<h256 const&> dev::eth::Client::m_tqReplaced
protected

Definition at line 360 of file Client.h.

◆ m_warpHost

std::weak_ptr<WarpCapability> dev::eth::Client::m_warpHost
protected

Definition at line 354 of file Client.h.

◆ m_working

Block dev::eth::Client::m_working
protected

The state of the client which we're sealing (i.e. it'll have all the rewards added), while we're actually working on it.

Definition at line 347 of file Client.h.

◆ m_wouldButShouldnot

bool dev::eth::Client::m_wouldButShouldnot = false
protected

True if the last time we called rejigSealing wouldSeal() was true but sealer's shouldSeal() was false.

Definition at line 364 of file Client.h.

◆ m_wouldSeal

std::atomic<bool> dev::eth::Client::m_wouldSeal = { false }
protected

True if we /should/ be sealing.

Definition at line 363 of file Client.h.

◆ x_functionQueue

SharedMutex dev::eth::Client::x_functionQueue
protected

Definition at line 375 of file Client.h.

◆ x_postSeal

SharedMutex dev::eth::Client::x_postSeal
mutableprotected

Lock on m_postSeal.

Definition at line 344 of file Client.h.

◆ x_preSeal

SharedMutex dev::eth::Client::x_preSeal
mutableprotected

Lock on m_preSeal.

Definition at line 342 of file Client.h.

◆ x_signalled

Mutex dev::eth::Client::x_signalled
protected

Definition at line 357 of file Client.h.

◆ x_working

SharedMutex dev::eth::Client::x_working
mutableprotected

Lock on m_working.

Definition at line 346 of file Client.h.


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