diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 3a6087ea583..031af59e874 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -507,9 +507,9 @@ WorkingProgress Client::miningProgress() const return WorkingProgress(); } -uint64_t Client::hashrate() const +u256 Client::hashrate() const { - uint64_t r = externalHashrate(); + u256 r = externalHashrate(); if (Ethash::isWorking(m_sealEngine.get())) r += Ethash::workingProgress(m_sealEngine.get()).rate(); return r; diff --git a/libethereum/Client.h b/libethereum/Client.h index a7d184d76b6..f7b5eefadc1 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -171,7 +171,7 @@ class Client: public ClientBase, protected Worker /// Are we mining now? bool wouldMine() const override { return m_wouldMine; } /// The hashrate... - uint64_t hashrate() const override; + u256 hashrate() const override; /// Check the progress of the mining. WorkingProgress miningProgress() const override; /// Get and clear the mining history. diff --git a/libethereum/ClientBase.cpp b/libethereum/ClientBase.cpp index f11d533a605..1d230a9b38c 100644 --- a/libethereum/ClientBase.cpp +++ b/libethereum/ClientBase.cpp @@ -524,14 +524,14 @@ bool ClientBase::isKnownTransaction(h256 const& _blockHash, unsigned _i) const return isKnown(_blockHash) && bc().transactions().size() > _i; } -void ClientBase::submitExternalHashrate(int _rate, h256 const& _id) +void ClientBase::submitExternalHashrate(u256 const& _rate, h256 const& _id) { m_externalRates[_id] = make_pair(_rate, chrono::steady_clock::now()); } -uint64_t ClientBase::externalHashrate() const +u256 ClientBase::externalHashrate() const { - uint64_t ret = 0; + u256 ret = 0; for (auto i = m_externalRates.begin(); i != m_externalRates.end();) if (chrono::steady_clock::now() - i->second.second > chrono::seconds(5)) i = m_externalRates.erase(i); diff --git a/libethereum/ClientBase.h b/libethereum/ClientBase.h index 504fb2dbd4d..c942c459d9d 100644 --- a/libethereum/ClientBase.h +++ b/libethereum/ClientBase.h @@ -164,10 +164,10 @@ class ClientBase: public Interface virtual void stopMining() override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::stopMining")); } virtual bool isMining() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::isMining")); } virtual bool wouldMine() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::wouldMine")); } - virtual uint64_t hashrate() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::hashrate")); } + virtual u256 hashrate() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::hashrate")); } virtual WorkingProgress miningProgress() const override { BOOST_THROW_EXCEPTION(InterfaceNotSupported("ClientBase::miningProgress")); } - virtual void submitExternalHashrate(int _rate, h256 const& _id) override; + virtual void submitExternalHashrate(u256 const& _rate, h256 const& _id) override; Block asOf(BlockNumber _h) const; @@ -182,7 +182,7 @@ class ClientBase: public Interface virtual void prepareForTransaction() = 0; /// } - uint64_t externalHashrate() const; + u256 externalHashrate() const; TransactionQueue m_tq; ///< Maintains a list of incoming transactions not yet in a block on the blockchain. @@ -194,7 +194,7 @@ class ClientBase: public Interface std::map m_watches; ///< Each and every watch - these reference a filter. // external hashrate - mutable std::unordered_map> m_externalRates; + mutable std::unordered_map> m_externalRates; }; }} diff --git a/libethereum/Interface.h b/libethereum/Interface.h index ed9659f3b75..e7bbb5e4fd8 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -211,14 +211,14 @@ class Interface /// Would we like to mine now? virtual bool wouldMine() const = 0; /// Current hash rate. - virtual uint64_t hashrate() const = 0; + virtual u256 hashrate() const = 0; /// Get hash of the current block to be mined minus the nonce (the 'work hash'). virtual std::tuple getEthashWork() { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::getEthashWork")); } /// Submit the nonce for the proof-of-work. virtual bool submitEthashWork(h256 const&, h64 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitEthashWork")); } /// Submit the ongoing hashrate of a particular external miner. - virtual void submitExternalHashrate(int, h256 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitExternalHashrate")); } + virtual void submitExternalHashrate(u256 const&, h256 const&) { BOOST_THROW_EXCEPTION(InterfaceNotSupported("Interface::submitExternalHashrate")); } /// Check the progress of the mining. virtual WorkingProgress miningProgress() const = 0; diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index 94fbc6477a4..11dae47cc77 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -782,7 +782,7 @@ bool WebThreeStubServerBase::eth_submitWork(string const& _nonce, string const&, bool WebThreeStubServerBase::eth_submitHashrate(string const& _hashes, string const& _id) { - client()->submitExternalHashrate(jsToInt(_hashes), jsToFixed<32>(_id)); + client()->submitExternalHashrate(jsToInt<32>(_hashes), jsToFixed<32>(_id)); return true; } diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 7d212543609..834ce27a916 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -370,7 +370,7 @@ bool MixClient::isMining() const return false; } -uint64_t MixClient::hashrate() const +u256 MixClient::hashrate() const { return 0; } diff --git a/mix/MixClient.h b/mix/MixClient.h index 8646f89384b..8be9ec9cbd9 100644 --- a/mix/MixClient.h +++ b/mix/MixClient.h @@ -95,7 +95,7 @@ class MixClient: public dev::eth::ClientBase void startMining() override; void stopMining() override; bool isMining() const override; - uint64_t hashrate() const override; + u256 hashrate() const override; eth::WorkingProgress miningProgress() const override; virtual void flushTransactions() override {}