Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | if (param.isNum()) { | ||||
return active_chain[height]; | return active_chain[height]; | ||||
} else { | } else { | ||||
const BlockHash hash{ParseHashV(param, "hash_or_height")}; | const BlockHash hash{ParseHashV(param, "hash_or_height")}; | ||||
CBlockIndex *pindex = chainman.m_blockman.LookupBlockIndex(hash); | CBlockIndex *pindex = chainman.m_blockman.LookupBlockIndex(hash); | ||||
if (!pindex) { | if (!pindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
if (!active_chain.Contains(pindex)) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | |||||
strprintf("Block is not in chain %s", | |||||
Params().NetworkIDString())); | |||||
} | |||||
return pindex; | return pindex; | ||||
} | } | ||||
} | } | ||||
UniValue blockheaderToJSON(const CBlockIndex *tip, | UniValue blockheaderToJSON(const CBlockIndex *tip, | ||||
const CBlockIndex *blockindex) { | const CBlockIndex *blockindex) { | ||||
// Serialize passed information without accessing chain state of the active | // Serialize passed information without accessing chain state of the active | ||||
// chain! | // chain! | ||||
// For performance reasons | // For performance reasons | ||||
▲ Show 20 Lines • Show All 3,166 Lines • Show Last 20 Lines |