mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-17 05:41:34 +02:00
Fix GetDifficulty
This commit is contained in:
@@ -20,16 +20,17 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
|
||||
double GetDifficulty(const CBlockIndex* blockindex, int algo)
|
||||
{
|
||||
unsigned int nBits;
|
||||
|
||||
|
||||
// Floating point number that is a multiple of the minimum difficulty,
|
||||
// minimum difficulty = 1.0.
|
||||
if (blockindex == NULL)
|
||||
{
|
||||
if (chainActive.Tip() == NULL)
|
||||
CBlockIndex* tip = chainActive.Tip();
|
||||
if (tip == NULL)
|
||||
nBits = Params().ProofOfWorkLimit(ALGO_SHA256D).GetCompact();
|
||||
else
|
||||
{
|
||||
blockindex = GetLastBlockIndexForAlgo(chainActive.Tip(), algo);
|
||||
blockindex = GetLastBlockIndexForAlgo(tip, algo);
|
||||
if (blockindex == NULL)
|
||||
nBits = Params().ProofOfWorkLimit(algo).GetCompact();
|
||||
else
|
||||
@@ -38,11 +39,11 @@ double GetDifficulty(const CBlockIndex* blockindex, int algo)
|
||||
}
|
||||
else
|
||||
nBits = blockindex->nBits;
|
||||
|
||||
|
||||
int nShift = (nBits >> 24) & 0xff;
|
||||
|
||||
double dDiff =
|
||||
(double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
|
||||
(double)0x0000ffff / (double)(nBits & 0x00ffffff);
|
||||
|
||||
while (nShift < 29)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,7 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("difficulty_skein", (double)GetDifficulty(NULL, ALGO_SKEIN)));
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_QUBIT)));
|
||||
obj.push_back(Pair("testnet", TestNet()));
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain) {
|
||||
obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime()));
|
||||
@@ -92,6 +93,7 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
#endif
|
||||
obj.push_back(Pair("relayfee", ValueFromAmount(CTransaction::nMinRelayTxFee)));
|
||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user