Skip to content

Commit 7f15c18

Browse files
committed
rpc: getdeploymentinfo: allow specifying a blockhash other than tip
1 parent fd82613 commit 7f15c18

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/rpc/blockchain.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,9 @@ static RPCHelpMan getdeploymentinfo()
15901590
{
15911591
return RPCHelpMan{"getdeploymentinfo",
15921592
"Returns an object containing various state info regarding soft-forks.",
1593-
{},
1593+
{
1594+
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Default{"chain tip"}, "The block hash at which to query fork state"},
1595+
},
15941596
RPCResult{
15951597
RPCResult::Type::OBJ, "", "", {
15961598
{RPCResult::Type::OBJ, "deployments", "", {
@@ -1605,8 +1607,18 @@ static RPCHelpMan getdeploymentinfo()
16051607
LOCK(cs_main);
16061608
CChainState& active_chainstate = chainman.ActiveChainstate();
16071609

1608-
const CBlockIndex* tip = active_chainstate.m_chain.Tip();
1609-
CHECK_NONFATAL(tip);
1610+
const CBlockIndex* tip;
1611+
if (request.params[0].isNull()) {
1612+
tip = active_chainstate.m_chain.Tip();
1613+
CHECK_NONFATAL(tip);
1614+
} else {
1615+
uint256 hash(ParseHashV(request.params[0], "blockhash"));
1616+
tip = chainman.m_blockman.LookupBlockIndex(hash);
1617+
if (!tip) {
1618+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
1619+
}
1620+
}
1621+
16101622
const Consensus::Params& consensusParams = Params().GetConsensus();
16111623

16121624
UniValue deploymentinfo(UniValue::VOBJ);

0 commit comments

Comments
 (0)