aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2015-04-11 06:45:21 +0800
committerGav Wood <i@gavwood.com>2015-04-11 06:45:21 +0800
commitb848fa9af1487c3cfcc35d4ff24a6c48b0c79d06 (patch)
tree4fb8760fe2e2aa182a12391d2e29d5b2db108907
parentc111dbff3f4d4d5e6d064b38bcd645f2d763ccab (diff)
downloaddexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar.gz
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar.bz2
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar.lz
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar.xz
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.tar.zst
dexon-solidity-b848fa9af1487c3cfcc35d4ff24a6c48b0c79d06.zip
Ability to switch GPU/CPU mining on the fly.
-rw-r--r--blockchain.cpp7
-rw-r--r--stateOriginal.cpp5
-rw-r--r--webthreestubclient.h10
3 files changed, 17 insertions, 5 deletions
diff --git a/blockchain.cpp b/blockchain.cpp
index ab01df5a..15cda803 100644
--- a/blockchain.cpp
+++ b/blockchain.cpp
@@ -192,7 +192,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
state.sync(bc, txs, gp);
state.commitToMine(bc);
MineInfo info;
- for (info.completed = false; !info.completed; info = state.mine()) {}
+ ProofOfWork pow;
+ for (info.completed = false; !info.completed; info = state.mine(&pow)) {}
state.completeMine();
}
catch (Exception const& _e)
@@ -577,7 +578,7 @@ void overwriteBlockHeader(BlockInfo& _currentBlockHeader, mObject& _blObj)
std::pair<MineInfo, Ethash::Proof> ret;
while (!ProofOfWork::verify(_currentBlockHeader))
{
- ret = pow.mine(_currentBlockHeader, 1000, true, true);
+ ret = pow.mine(_currentBlockHeader, 1000, true);
Ethash::assignResult(ret.second, _currentBlockHeader);
}
}
@@ -623,7 +624,7 @@ void updatePoW(BlockInfo& _bi)
std::pair<MineInfo, Ethash::Proof> ret;
while (!ProofOfWork::verify(_bi))
{
- ret = pow.mine(_bi, 10000, true, true);
+ ret = pow.mine(_bi, 10000, true);
Ethash::assignResult(ret.second, _bi);
}
_bi.noteDirty();
diff --git a/stateOriginal.cpp b/stateOriginal.cpp
index 572e84dc..40f75943 100644
--- a/stateOriginal.cpp
+++ b/stateOriginal.cpp
@@ -68,7 +68,8 @@ BOOST_AUTO_TEST_CASE(Complex)
// Mine to get some ether!
s.commitToMine(bc);
- while (!s.mine(100, true).completed) {}
+ ProofOfWork pow;
+ while (!s.mine(&pow).completed) {}
s.completeMine();
bc.attemptImport(s.blockData(), stateDB);
@@ -88,7 +89,7 @@ BOOST_AUTO_TEST_CASE(Complex)
// Mine to get some ether and set in stone.
s.commitToMine(bc);
s.commitToMine(bc);
- while (!s.mine(100, true).completed) {}
+ while (!s.mine(&pow).completed) {}
s.completeMine();
bc.attemptImport(s.blockData(), stateDB);
diff --git a/webthreestubclient.h b/webthreestubclient.h
index a460ddda..c1fdc341 100644
--- a/webthreestubclient.h
+++ b/webthreestubclient.h
@@ -72,6 +72,16 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
+ std::string eth_hashrate() throw (jsonrpc::JsonRpcException)
+ {
+ Json::Value p;
+ p = Json::nullValue;
+ Json::Value result = this->CallMethod("eth_hashrate",p);
+ if (result.isString())
+ return result.asString();
+ else
+ throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
+ }
std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
{
Json::Value p;