Merge pull request #99 from ch4ot1c/fixup/network-difficulty-merge
Fix segfaults by using chain tip header
This commit is contained in:
commit
9d72497c27
|
@ -71,8 +71,9 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul
|
|||
}
|
||||
|
||||
uint32_t bits;
|
||||
auto tipblock = chainActive.Tip()->GetBlockHeader();
|
||||
if (networkDifficulty) {
|
||||
bits = GetNextWorkRequired(blockindex, nullptr, Params());
|
||||
bits = GetNextWorkRequired(blockindex, &tipblock, Params());
|
||||
} else {
|
||||
bits = blockindex->nBits;
|
||||
}
|
||||
|
@ -1281,7 +1282,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
|||
obj.pushKV("blocks", (int)chainActive.Height());
|
||||
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1);
|
||||
obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex());
|
||||
obj.pushKV("difficulty", (double)GetNetworkDifficulty());
|
||||
obj.pushKV("difficulty", (double)GetDifficulty(chainActive.Tip()));
|
||||
obj.pushKV("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast());
|
||||
obj.pushKV("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip()));
|
||||
obj.pushKV("initialblockdownload", IsInitialBlockDownload());
|
||||
|
|
|
@ -23,7 +23,7 @@ static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
|
|||
*/
|
||||
double GetDifficulty(const CBlockIndex* blockindex = nullptr);
|
||||
|
||||
double GetNetworkDifficulty(const CBlockIndex* blockindex = nullptr);
|
||||
double GetNetworkDifficulty(const CBlockIndex* blockindex);
|
||||
|
||||
/** Callback for when block tip changed. */
|
||||
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
|
||||
|
|
|
@ -254,7 +254,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
|
|||
obj.pushKV("blocks", (int)chainActive.Height());
|
||||
obj.pushKV("currentblockweight", (uint64_t)nLastBlockWeight);
|
||||
obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx);
|
||||
obj.pushKV("difficulty", (double)GetNetworkDifficulty());
|
||||
obj.pushKV("difficulty", (double)GetNetworkDifficulty(chainActive.Tip()));
|
||||
obj.pushKV("networkhashps", getnetworkhashps(request));
|
||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||
obj.pushKV("chain", Params().NetworkIDString());
|
||||
|
|
Loading…
Reference in New Issue