mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
rpc: add next to getmininginfo
Obtain difficulty and target for the next block without having to call getblocktemplate.
This commit is contained in:
@@ -4,10 +4,13 @@
|
||||
|
||||
#include <rpc/server_util.h>
|
||||
|
||||
#include <chain.h>
|
||||
#include <common/args.h>
|
||||
#include <net_processing.h>
|
||||
#include <node/context.h>
|
||||
#include <node/miner.h>
|
||||
#include <policy/fees.h>
|
||||
#include <pow.h>
|
||||
#include <rpc/protocol.h>
|
||||
#include <rpc/request.h>
|
||||
#include <txmempool.h>
|
||||
@@ -17,6 +20,7 @@
|
||||
#include <any>
|
||||
|
||||
using node::NodeContext;
|
||||
using node::UpdateTime;
|
||||
|
||||
NodeContext& EnsureAnyNodeContext(const std::any& context)
|
||||
{
|
||||
@@ -129,3 +133,18 @@ AddrMan& EnsureAnyAddrman(const std::any& context)
|
||||
{
|
||||
return EnsureAddrman(EnsureAnyNodeContext(context));
|
||||
}
|
||||
|
||||
void NextEmptyBlockIndex(CBlockIndex& tip, const Consensus::Params& consensusParams, CBlockIndex& next_index)
|
||||
{
|
||||
CBlockHeader next_header{};
|
||||
next_header.hashPrevBlock = tip.GetBlockHash();
|
||||
UpdateTime(&next_header, consensusParams, &tip);
|
||||
next_header.nBits = GetNextWorkRequired(&tip, &next_header, consensusParams);
|
||||
next_header.nNonce = 0;
|
||||
|
||||
next_index.pprev = &tip;
|
||||
next_index.nTime = next_header.nTime;
|
||||
next_index.nBits = next_header.nBits;
|
||||
next_index.nNonce = next_header.nNonce;
|
||||
next_index.nHeight = tip.nHeight + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user