diff --git a/eth/main.cpp b/eth/main.cpp index 7a128298a..87fde2bdd 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -119,6 +119,7 @@ void help() << " -p,--port Connect to remote port (default: 30303)." << endl << " -r,--remote Connect to remote host (default: none)." << endl << " -s,--secret Set the secret key for use with send command (default: auto)." << endl + << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl << " -u,--public-ip Force public ip to given (default; auto)." << endl << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl @@ -195,6 +196,7 @@ int main(int argc, char** argv) unsigned mining = ~(unsigned)0; NodeMode mode = NodeMode::Full; unsigned peers = 5; + int miners = -1; bool interactive = false; #if ETH_JSONRPC int jsonrpc = -1; @@ -295,6 +297,8 @@ int main(int argc, char** argv) g_logVerbosity = atoi(argv[++i]); else if ((arg == "-x" || arg == "--peers") && i + 1 < argc) peers = atoi(argv[++i]); + else if ((arg == "-t" || arg == "--miners") && i + 1 < argc) + miners = atoi(argv[++i]); else if ((arg == "-o" || arg == "--mode") && i + 1 < argc) { string m = argv[++i]; @@ -337,7 +341,8 @@ int main(int argc, char** argv) dbPath, false, mode == NodeMode::Full ? set{"eth", "shh"} : set(), - netPrefs + netPrefs, + miners ); web3.setIdealPeerCount(peers); eth::Client* c = mode == NodeMode::Full ? web3.ethereum() : nullptr; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index a42d1df99..f36a9ba22 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -59,7 +59,7 @@ void VersionChecker::setOk() } } -Client::Client(p2p::Host* _extNet, std::string const& _dbPath, bool _forceClean, u256 _networkId): +Client::Client(p2p::Host* _extNet, std::string const& _dbPath, bool _forceClean, u256 _networkId, int miners): Worker("eth"), m_vc(_dbPath), m_bc(_dbPath, !m_vc.ok() || _forceClean), @@ -69,7 +69,10 @@ Client::Client(p2p::Host* _extNet, std::string const& _dbPath, bool _forceClean, { m_host = _extNet->registerCapability(new EthereumHost(m_bc, m_tq, m_bq, _networkId)); - setMiningThreads(); + if(miners > -1) + setMiningThreads(miners); + else + setMiningThreads(); if (_dbPath.size()) Defaults::setDBPath(_dbPath); m_vc.setOk(); diff --git a/libethereum/Client.h b/libethereum/Client.h index ce3506bde..cb4488b17 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -166,7 +166,7 @@ class Client: public MinerHost, public Interface, Worker public: /// New-style Constructor. - explicit Client(p2p::Host* _host, std::string const& _dbPath = std::string(), bool _forceClean = false, u256 _networkId = 0); + explicit Client(p2p::Host* _host, std::string const& _dbPath = std::string(), bool _forceClean = false, u256 _networkId = 0, int miners = -1); /// Destructor. virtual ~Client(); diff --git a/libwebthree/WebThree.cpp b/libwebthree/WebThree.cpp index c9f9d56e3..a3a95146e 100644 --- a/libwebthree/WebThree.cpp +++ b/libwebthree/WebThree.cpp @@ -35,15 +35,15 @@ using namespace dev::p2p; using namespace dev::eth; using namespace dev::shh; -WebThreeDirect::WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean, std::set const& _interfaces, NetworkPreferences const& _n): +WebThreeDirect::WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean, std::set const& _interfaces, NetworkPreferences const& _n, int miners): m_clientVersion(_clientVersion), m_net(_clientVersion, _n) { if (_dbPath.size()) Defaults::setDBPath(_dbPath); - - if (_interfaces.count("eth")) - m_ethereum.reset(new eth::Client(&m_net, _dbPath, _forceClean)); + if (_interfaces.count("eth")) + m_ethereum.reset(new eth::Client(&m_net, _dbPath, _forceClean, 0, miners)); + if (_interfaces.count("shh")) m_whisper = m_net.registerCapability(new WhisperHost); diff --git a/libwebthree/WebThree.h b/libwebthree/WebThree.h index 682fdc0b6..013986984 100644 --- a/libwebthree/WebThree.h +++ b/libwebthree/WebThree.h @@ -106,7 +106,7 @@ class WebThreeDirect : public WebThreeNetworkFace public: /// Constructor for private instance. If there is already another process on the machine using @a _dbPath, then this will throw an exception. /// ethereum() may be safely static_cast()ed to a eth::Client*. - WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean = false, std::set const& _interfaces = {"eth", "shh"}, p2p::NetworkPreferences const& _n = p2p::NetworkPreferences()); + WebThreeDirect(std::string const& _clientVersion, std::string const& _dbPath, bool _forceClean = false, std::set const& _interfaces = {"eth", "shh"}, p2p::NetworkPreferences const& _n = p2p::NetworkPreferences(), int miners = -1); /// Destructor. ~WebThreeDirect(); diff --git a/neth/main.cpp b/neth/main.cpp index 2c1a85241..2cc3f6239 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -81,6 +81,7 @@ void help() << " -p,--port Connect to remote port (default: 30303)." << endl << " -r,--remote Connect to remote host (default: none)." << endl << " -s,--secret Set the secret key for use with send command (default: auto)." << endl + << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl << " -u,--public-ip Force public ip to given (default; auto)." << endl << " -v,--verbosity <0..9> Set the log verbosity from 0 to 9 (tmp forced to 1)." << endl << " -x,--peers Attempt to connect to given number of peers (default: 5)." << endl @@ -307,6 +308,7 @@ int main(int argc, char** argv) unsigned mining = ~(unsigned)0; NodeMode mode = NodeMode::Full; unsigned peers = 5; + int miners = -1; #if ETH_JSONRPC int jsonrpc = 8080; #endif @@ -401,6 +403,8 @@ int main(int argc, char** argv) g_logVerbosity = atoi(argv[++i]); else if ((arg == "-x" || arg == "--peers") && i + 1 < argc) peers = atoi(argv[++i]); + else if ((arg == "-t" || arg == "--miners") && i + 1 < argc) + miners = atoi(argv[++i]); else if (arg == "-h" || arg == "--help") help(); else if (arg == "-V" || arg == "--version") @@ -420,7 +424,8 @@ int main(int argc, char** argv) dbPath, false, mode == NodeMode::Full ? set{"eth", "shh"} : set(), - netPrefs + netPrefs, + miners ); web3.setIdealPeerCount(peers); eth::Client* c = mode == NodeMode::Full ? web3.ethereum() : nullptr;