mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
rpc: add next to getmininginfo
Obtain difficulty and target for the next block without having to call getblocktemplate.
This commit is contained in:
parent
2d18a078a2
commit
cf0a62878b
4 changed files with 50 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue