Skip to content

Commit

Permalink
Fix get mining info rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed May 9, 2024
1 parent ad3e4b9 commit 42b8a21
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/wallet/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ using node::BlockAssembler;

namespace wallet {

UniValue GetReqNetworkHashPS(const JSONRPCRequest& request, ChainstateManager& chainman)
{
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].getInt<int>() : 120, !request.params[1].isNull() ? request.params[1].getInt<int>() : -1, chainman.ActiveChain());
}

RPCHelpMan getmininginfo()
{
return RPCHelpMan{"getmininginfo",
Expand Down Expand Up @@ -81,8 +86,8 @@ RPCHelpMan getmininginfo()
if (BlockAssembler::m_last_block_weight) obj.pushKV("currentblockweight", *BlockAssembler::m_last_block_weight);
if (BlockAssembler::m_last_block_num_txs) obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs);

diff.pushKV("proof-of-work", GetDifficulty(GetLastBlockIndex(chainman.m_best_header, false)));
diff.pushKV("proof-of-stake", GetDifficulty(GetLastBlockIndex(chainman.m_best_header, true)));
diff.pushKV("proof-of-work", (double)GetDifficulty(GetLastBlockIndex(chainman.m_best_header, false)));
diff.pushKV("proof-of-stake", (double)GetDifficulty(GetLastBlockIndex(chainman.m_best_header, true)));
diff.pushKV("search-interval", (int)lastCoinStakeSearchInterval);
obj.pushKV("difficulty", diff);

Expand All @@ -92,7 +97,7 @@ RPCHelpMan getmininginfo()
obj.pushKV("netmhashps", GetPoWMHashPS(chainman));
obj.pushKV("netstakeweight", GetPoSKernelPS(chainman));
obj.pushKV("errors", GetWarnings("statusbar").original);
obj.pushKV("networkhashps", GetNetworkHashPS(self.Arg<int>(0), self.Arg<int>(1), chainman.ActiveChain()));
obj.pushKV("networkhashps", GetReqNetworkHashPS(request, chainman));
obj.pushKV("pooledtx", (uint64_t)mempool.size());

weight.pushKV("minimum", (uint64_t)nWeight);
Expand Down Expand Up @@ -168,7 +173,7 @@ RPCHelpMan getstakinginfo()
if (BlockAssembler::m_last_block_num_txs) obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs);
obj.pushKV("pooledtx", (uint64_t)mempool.size());

obj.pushKV("difficulty", GetDifficulty(GetLastBlockIndex(chainman.m_best_header, true)));
obj.pushKV("difficulty", (double)GetDifficulty(GetLastBlockIndex(chainman.m_best_header, true)));
obj.pushKV("search-interval", (int)lastCoinStakeSearchInterval);

obj.pushKV("weight", (uint64_t)nStakerWeight);
Expand Down

0 comments on commit 42b8a21

Please sign in to comment.