25 #include <condition_variable> 82 std::shared_ptr<GasPricer> _gpForAdoption,
83 std::string
const& _dbPath = std::string(),
95 std::shared_ptr<GasPricer>
gasPricer()
const {
return m_gp; }
98 virtual void flushTransactions()
override;
139 std::tuple<ImportRoute, bool, unsigned> syncQueue(
unsigned _max = 1);
150 std::string
sealer()
const {
return sealEngine()->sealer(); }
152 void setSealer(std::string
const& _id) { sealEngine()->setSealer(_id);
if (wouldSeal()) startSealing(); }
154 bytes sealOption(std::string
const& _name)
const {
return sealEngine()->option(_name); }
156 bool setSealOption(std::string
const& _name,
bytes const& _value) {
auto ret = sealEngine()->setOption(_name, _value);
if (wouldSeal()) startSealing();
return ret; }
159 void startSealing()
override;
166 bool isSyncing()
const override;
168 bool isMajorSyncing()
const override;
173 void setNetworkId(
u256 const& _n)
override;
180 DownloadMan
const* downloadMan()
const;
195 void rewind(
unsigned _n);
197 void rescue() { bc().rescue(m_stateDB); }
200 void executeInMainThread(
std::function<
void()>
const& _function);
202 virtual Block block(
h256 const& _block)
const override;
218 virtual void prepareForTransaction()
override;
230 void noteChanged(
h256Hash const& _filters);
233 virtual bool submitSealed(
bytes const& _s);
237 void startedWorking()
override;
240 void doWork(
bool _doWait);
244 void doneWorking()
override;
250 void onDeadBlocks(
h256s const& _blocks,
h256Hash& io_changed);
253 virtual void onNewBlocks(
h256s const& _blocks,
h256Hash& io_changed);
256 void resyncStateFromChain();
266 void syncBlockQueue();
269 void syncTransactionQueue();
279 void onPostStateChanged();
282 void checkWatchGarbage();
292 void callQueuedFunctions();
296 std::shared_ptr<GasPricer>
m_gp;
306 bool remoteActive()
const;
307 bool m_remoteWorking =
false;
308 std::atomic<bool> m_needStateReset = {
false };
317 bool m_wouldSeal =
false;
318 bool m_wouldButShouldnot =
false;
325 unsigned m_syncAmount = 50;
334 std::atomic<bool> m_syncTransactionQueue = {
false};
335 std::atomic<bool> m_syncBlockQueue = {
false};
void stopSealing() override
Stop sealing.
std::shared_ptr< GasPricer > gasPricer() const
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
BlockHeader m_sealingInfo
The header we're attempting to seal on (derived from m_postSeal).
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.
#define function(a, b, c, d, k, s)
std::chrono::system_clock::time_point m_lastGarbageCollection
When did we last both doing GC on the watches?
void swap(dev::eth::Watch &_a, dev::eth::Watch &_b)
Implements the blockchain database.
void onTransactionQueueReady()
Magically called when m_tq needs syncing. Be nice and don't block.
Block m_postSeal
The state of the client which we're sealing (i.e. it'll have all the rewards added).
dev::eth::Block postState() const
Get the object representing the current state of Ethereum.
static const char * name()
std::ostream & operator<<(std::ostream &_out, BlockHeader const &_bi)
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not t...
h160 Address
An Ethereum address: 20 bytes.
void setExtraData(bytes const &_extraData)
Set the extra data that goes into sealed blocks.
SharedMutex x_preSeal
Lock on m_preSeal.
virtual u256 gasLimitRemaining() const override
Get the remaining gas limit in this block.
OverlayDB const & stateDB() const
Get the block queue.
std::vector< std::string > strings
ChainParams const & chainParams() const
Get information on this chain.
Description of the result of executing a transaction.
Model of an Ethereum state, essentially a facade for the trie.
BlockQueue m_bq
Maintains a list of incoming blocks not yet on the blockchain (to be imported).
void doWork() override
Called continuously following sleep for m_idleWaitMs.
virtual Address author() const override
Get the block author.
Active model of a block within the block chain.
std::shared_ptr< GasPricer > m_gp
The gas pricer.
void onBlockQueueReady()
Magically called when m_bq needs syncing. Be nice and don't block.
bool wouldSeal() const override
Are we sealing now?
Base class for all exceptions.
bool setSealOption(std::string const &_name, bytes const &_value)
Set option for the sealer.
virtual Block preSeal() const override
Returns the state object for the full block (i.e.
BlockChain & bc() override
InterfaceStub methods.
virtual ExecutionResult call(Address const &_from, u256 _value, Address _dest, bytes const &_data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff=FudgeFactor::Strict)=0
Makes the given call. Nothing is recorded into the state.
BlockChain const & blockChain() const
Get the object representing the current canonical blockchain.
std::shared_ptr< typename Signal< Args... >::HandlerAux > Handler
virtual Block postSeal() const override
Block block(BlockNumber _h) const
std::vector< byte > bytes
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Main API hub for interfacing with Ethereum.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
boost::shared_lock< boost::shared_mutex > ReadGuard
void killChain()
Kills the blockchain. Just for debug use.
boost::unique_lock< boost::shared_mutex > WriteGuard
BlockChain const & bc() const override
std::queue< std::function< void()> > m_functionQueue
Functions waiting to be executed in the main thread.
std::chrono::system_clock::time_point m_lastGetWork
Is there an active and valid remote worker?
BlockChain m_bc
Maintains block database and owns the seal engine.
strings sealers() const
Type of sealers available for this seal engine.
SharedMutex x_functionQueue
boost::shared_mutex SharedMutex
void retryUnknown()
Retries all blocks with unknown parents.
Block m_preSeal
The present state of the client.
void rescue()
Rescue the chain.
clock::time_point time_point
std::weak_ptr< EthereumHost > m_host
Our Ethereum Host. Don't do anything if we can't lock.
The default logging channels.
void setSealer(std::string const &_id)
Change sealer.
std::unordered_set< h256 > h256Hash
SealEngineFace * sealEngine() const override
Get the seal engine.
TransactionQueue::Status transactionQueueStatus() const
Get some information on the transaction queue.
std::string sealer() const
Current sealer in use.
TransactionQueue::Limits transactionQueueLimits() const
ActivityReport activityReport()
Get a report of activity.
SharedMutex x_working
Lock on m_working.
OverlayDB m_stateDB
Acts as the central point for the state database, so multiple States can share it.
std::vector< h256 > h256s
BlockQueue const & blockQueue() const
Get the block queue.
virtual u256 gasBidPrice() const override
Get the gas bid price.
SharedMutex x_postSeal
Lock on m_postSeal.
static const int verbosity
std::condition_variable m_signalled
virtual void setAuthor(Address const &_us) override
Set the block author address.
void setGasPricer(std::shared_ptr< GasPricer > _gp)
Resets the gas pricer to some other object.
bytes sealOption(std::string const &_name) const
Review option for the sealer.
BlockQueueStatus blockQueueStatus() const
Get some information on the block queue.
Handler< h256 const & > m_tqReplaced