 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
23 #include <libethashseal/Ethash.h>
26 #include <boost/filesystem/path.hpp>
33 namespace fs = boost::filesystem;
45 ClientTest::ClientTest(
ChainParams const& _params,
int _networkID, p2p::Host& _host,
46 std::shared_ptr<GasPricer> _gpForAdoption, fs::path
const& _dbPath,
WithExisting _forceAction,
49 _params, _networkID, _host, _gpForAdoption, _dbPath,
std::string(), _forceAction, _limits)
65 BOOST_THROW_EXCEPTION(
66 ChainParamsInvalid() <<
errinfo_comment(
"Seal engine is not supported!"));
70 catch (std::exception
const& ex)
72 BOOST_THROW_EXCEPTION(ChainParamsInvalid() <<
errinfo_comment(ex.what()));
109 unsigned sealedBlocks = 0;
110 auto sealHandler = setOnBlockSealed([
this, _count, &sealedBlocks](
bytes const&) {
111 if (++sealedBlocks == _count)
115 std::promise<void> allBlocksImported;
116 unsigned importedBlocks = 0;
117 auto chainChangedHandler = setOnChainChanged(
118 [_count, &importedBlocks, &allBlocksImported](
h256s const&,
h256s const& _newBlocks) {
119 importedBlocks += _newBlocks.size();
120 if (importedBlocks == _count)
121 allBlocksImported.set_value();
125 future_status ret = allBlocksImported.get_future().wait_for(
126 std::chrono::seconds(m_singleBlockMaxMiningTimeInSeconds * _count));
127 return (ret == future_status::ready);
129 catch (std::exception
const&)
131 LOG(m_logger) << boost::current_exception_diagnostic_information();
154 if (
auto h =
m_host.lock())
157 bool moreToImport =
true;
160 tie(ignore, moreToImport, ignore) =
syncQueue(100000);
161 this_thread::sleep_for(chrono::milliseconds(100));
Block m_preSeal
The present state of the client.
void reopenChain(ChainParams const &_p, WithExisting _we=WithExisting::Trust)
Reloads the blockchain. Just for debug use.
void setChainParams(std::string const &_genesis)
std::tuple< ImportRoute, bool, unsigned > syncQueue(unsigned _max=1)
Freeze worker thread and sync some of the block queue.
BlockChain & bc() override
InterfaceStub methods.
void modifyTimestamp(int64_t _timestamp)
SharedMutex x_working
Lock on m_working.
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
h256 importRawBlock(std::string const &_blockRLP)
std::weak_ptr< EthereumCapability > m_host
Transactions transactions(h256 _blockHash) const override
ChainParams const & chainParams() const
Get information on this chain.
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
SharedMutex x_preSeal
Lock on m_preSeal.
std::vector< h256 > h256s
dev::eth::Block block(h256 const &_blockHash, PopulationStatistics *o_stats) const
Get the block.
Main API hub for interfacing with Ethereum.
ExecutionResult execute(LastBlockHashesFace const &_lh, Transaction const &_t, Permanence _p=Permanence::Committed, OnOpFunc const &_onOp=OnOpFunc())
#define DEV_WRITE_GUARDED(MUTEX)
std::vector< byte > bytes
Transactions const & pending() const
Get the list of pending transactions.
bytes jsToBytes(string const &_s, OnFailed _f)
LastBlockHashesFace const & lastBlockHashes() const
ImportResult queueBlock(bytes const &_block, bool _isSafe=false)
Queues a block for import.
Main API hub for interfacing with Ethereum.
ChainParams loadConfig(std::string const &_json, h256 const &_stateRoot={}, const boost::filesystem::path &_configPath={}) const
load config
#define DEV_READ_GUARDED(MUTEX)
static std::string name()
void resetCurrent(int64_t _timestamp=utcTime())
std::condition_variable m_signalled
boost::error_info< struct tag_importResult, ImportResult > errinfo_importResult
bool mineBlocks(unsigned _count) noexcept
Block m_working
The state of the client which we're sealing (i.e. it'll have all the rewards added),...
BlockHeader const & info() const
Get the header information on the present block.
void terminate()
Blocks caller into worker thread has finished.
void onPostStateChanged()
Block m_postSeal
The state of the client which we're sealing (i.e. it'll have all the rewards added).
ClientTest & asClientTest(Interface &_c)
Active model of a block within the block chain. Keeps track of all transactions, receipts and state f...
SharedMutex x_postSeal
Lock on m_postSeal.
boost::error_info< struct tag_comment, std::string > errinfo_comment