MCPcopy Create free account
hub / github.com/ElementsProject/elements / getdeploymentinfo

Function getdeploymentinfo

src/rpc/blockchain.cpp:1845–1889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1843} // anon namespace
1844
1845static RPCHelpMan getdeploymentinfo()
1846{
1847 return RPCHelpMan{"getdeploymentinfo",
1848 "Returns an object containing various state info regarding deployments of consensus changes.",
1849 {
1850 {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Default{"hash of current chain tip"}, "The block hash at which to query deployment state"},
1851 },
1852 RPCResult{
1853 RPCResult::Type::OBJ, "", "", {
1854 {RPCResult::Type::STR, "hash", "requested block hash (or tip)"},
1855 {RPCResult::Type::NUM, "height", "requested block height (or tip)"},
1856 {RPCResult::Type::OBJ, "deployments", "", {
1857 {RPCResult::Type::OBJ, "xxxx", "name of the deployment", RPCHelpForDeployment}
1858 }},
1859 }
1860 },
1861 RPCExamples{ HelpExampleCli("getdeploymentinfo", "") + HelpExampleRpc("getdeploymentinfo", "") },
1862 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1863 {
1864 const ChainstateManager& chainman = EnsureAnyChainman(request.context);
1865 LOCK(cs_main);
1866 const CChainState& active_chainstate = chainman.ActiveChainstate();
1867
1868 const CBlockIndex* blockindex;
1869 if (request.params[0].isNull()) {
1870 blockindex = active_chainstate.m_chain.Tip();
1871 CHECK_NONFATAL(blockindex);
1872 } else {
1873 const uint256 hash(ParseHashV(request.params[0], "blockhash"));
1874 blockindex = chainman.m_blockman.LookupBlockIndex(hash);
1875 if (!blockindex) {
1876 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
1877 }
1878 }
1879
1880 const Consensus::Params& consensusParams = Params().GetConsensus();
1881
1882 UniValue deploymentinfo(UniValue::VOBJ);
1883 deploymentinfo.pushKV("hash", blockindex->GetBlockHash().ToString());
1884 deploymentinfo.pushKV("height", blockindex->nHeight);
1885 deploymentinfo.pushKV("deployments", DeploymentInfo(blockindex, consensusParams));
1886 return deploymentinfo;
1887 },
1888 };
1889}
1890
1891/** Comparison function for sorting the getchaintips heads. */
1892struct CompareBlocksByHeight

Callers

nothing calls this directly

Calls 12

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ParseHashVFunction · 0.85
JSONRPCErrorFunction · 0.85
DeploymentInfoFunction · 0.85
LookupBlockIndexMethod · 0.80
ParamsClass · 0.50
isNullMethod · 0.45
TipMethod · 0.45
pushKVMethod · 0.45
ToStringMethod · 0.45
GetBlockHashMethod · 0.45

Tested by

no test coverage detected