Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Reported hashrate is now u256
Browse files Browse the repository at this point in the history
  • Loading branch information
LefterisJP committed Aug 17, 2015
1 parent 2b6cecc commit f752f3d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions libethereum/Client.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libethereum/Client.h
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions libethereum/ClientBase.cpp
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions libethereum/ClientBase.h
Expand Up @@ -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;

Expand All @@ -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.

Expand All @@ -194,7 +194,7 @@ class ClientBase: public Interface
std::map<unsigned, ClientWatch> m_watches; ///< Each and every watch - these reference a filter.

// external hashrate
mutable std::unordered_map<h256, std::pair<uint64_t, std::chrono::steady_clock::time_point>> m_externalRates;
mutable std::unordered_map<h256, std::pair<u256, std::chrono::steady_clock::time_point>> m_externalRates;
};

}}
4 changes: 2 additions & 2 deletions libethereum/Interface.h
Expand Up @@ -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<h256, h256, h256> 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;

Expand Down
2 changes: 1 addition & 1 deletion libweb3jsonrpc/WebThreeStubServerBase.cpp
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion mix/MixClient.cpp
Expand Up @@ -370,7 +370,7 @@ bool MixClient::isMining() const
return false;
}

uint64_t MixClient::hashrate() const
u256 MixClient::hashrate() const
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion mix/MixClient.h
Expand Up @@ -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 {}

Expand Down

0 comments on commit f752f3d

Please sign in to comment.