mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
Mac OS build fixes by laszlo
-- version 0.2.8 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@76 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
23
rpc.cpp
23
rpc.cpp
@@ -77,6 +77,18 @@ Value getconnectioncount(const Array& params)
|
||||
}
|
||||
|
||||
|
||||
double GetDifficulty()
|
||||
{
|
||||
// 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)
|
||||
@@ -84,15 +96,7 @@ Value getdifficulty(const Array& params)
|
||||
"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.
|
||||
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;
|
||||
return GetDifficulty();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user