diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-05-19 00:26:56 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-05-19 00:26:56 +0000 |
commit | 2d98de1b3ae2ade8b1e5493bc63c0c1d776deeb1 (patch) | |
tree | afb0807f148c4452f060ad8456a0fcb56dbae8f8 /rpc.cpp | |
parent | 966cca4bd4a6d869583fb47f5f66ed4672c007ff (diff) |
Mac OS build fixes by laszlov0.2.8
-- version 0.2.8
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@76 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'rpc.cpp')
-rw-r--r-- | rpc.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -77,24 +77,28 @@ Value getconnectioncount(const Array& params) }
-Value getdifficulty(const Array& params)
+double GetDifficulty()
{
- if (params.size() != 0)
- throw runtime_error(
- "getdifficulty (no parameters)\n"
- "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
-
- if (pindexBest == NULL)
- throw runtime_error("block chain not loaded");
-
// Floating point number that is a multiple of the minimum difficulty,
// minimum difficulty = 1.0.
+ if (pindexBest == NULL)
+ return 1.0;
int nShift = 256 - 32 - 31; // to fit in a uint
double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();
double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();
return dMinimum / dCurrently;
}
+Value getdifficulty(const Array& params)
+{
+ if (params.size() != 0)
+ throw runtime_error(
+ "getdifficulty (no parameters)\n"
+ "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
+
+ return GetDifficulty();
+}
+
Value getbalance(const Array& params)
{
@@ -157,6 +161,7 @@ Value getinfo(const Array& params) obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string())));
obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
+ obj.push_back(Pair("difficulty", (double)GetDifficulty()));
return obj;
}
|