File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 6
6
#define BITCOIN_INTERFACES_MINING_H
7
7
8
8
#include < consensus/amount.h> // for CAmount
9
+ #include < interfaces/types.h> // for BlockRef
9
10
#include < node/types.h> // for BlockCreateOptions
10
11
#include < primitives/block.h> // for CBlock, CBlockHeader
11
12
#include < primitives/transaction.h> // for CTransactionRef
@@ -55,8 +56,8 @@ class Mining
55
56
// ! Returns whether IBD is still in progress.
56
57
virtual bool isInitialBlockDownload () = 0;
57
58
58
- // ! Returns the hash for the tip of this chain
59
- virtual std::optional<uint256> getTipHash () = 0;
59
+ // ! Returns the hash and height for the tip of this chain
60
+ virtual std::optional<BlockRef> getTip () = 0;
60
61
61
62
/* *
62
63
* Construct a new block template
Original file line number Diff line number Diff line change 17
17
#include < interfaces/handler.h>
18
18
#include < interfaces/mining.h>
19
19
#include < interfaces/node.h>
20
+ #include < interfaces/types.h>
20
21
#include < interfaces/wallet.h>
21
22
#include < kernel/chain.h>
22
23
#include < kernel/context.h>
67
68
68
69
#include < boost/signals2/signal.hpp>
69
70
71
+ using interfaces::BlockRef;
70
72
using interfaces::BlockTemplate;
71
73
using interfaces::BlockTip;
72
74
using interfaces::Chain;
@@ -925,12 +927,12 @@ class MinerImpl : public Mining
925
927
return chainman ().IsInitialBlockDownload ();
926
928
}
927
929
928
- std::optional<uint256> getTipHash () override
930
+ std::optional<BlockRef> getTip () override
929
931
{
930
932
LOCK (::cs_main);
931
933
CBlockIndex* tip{chainman ().ActiveChain ().Tip ()};
932
934
if (!tip) return {};
933
- return tip->GetBlockHash ();
935
+ return BlockRef{ tip->GetBlockHash (), tip-> nHeight } ;
934
936
}
935
937
936
938
bool processNewBlock (const std::shared_ptr<const CBlock>& block, bool * new_block) override
Original file line number Diff line number Diff line change @@ -661,7 +661,7 @@ static RPCHelpMan getblocktemplate()
661
661
ChainstateManager& chainman = EnsureChainman (node);
662
662
Mining& miner = EnsureMining (node);
663
663
LOCK (cs_main);
664
- uint256 tip{CHECK_NONFATAL (miner.getTipHash ()).value ()};
664
+ uint256 tip{CHECK_NONFATAL (miner.getTip ()).value (). hash };
665
665
666
666
std::string strMode = " template" ;
667
667
UniValue lpval = NullUniValue;
@@ -776,7 +776,7 @@ static RPCHelpMan getblocktemplate()
776
776
}
777
777
ENTER_CRITICAL_SECTION (cs_main);
778
778
779
- tip = CHECK_NONFATAL (miner.getTipHash ()).value ();
779
+ tip = CHECK_NONFATAL (miner.getTip ()).value (). hash ;
780
780
781
781
if (!IsRPCRunning ())
782
782
throw JSONRPCError (RPC_CLIENT_NOT_CONNECTED, " Shutting down" );
You can’t perform that action at this time.
0 commit comments