Commit c8faa327 authored by Pavel Vasin's avatar Pavel Vasin

rpc: optimize getblockbynumber

parent 884b05ae
......@@ -262,11 +262,9 @@ Value getblockbynumber(const Array& params, bool fHelp)
throw runtime_error("Block number out of range.");
CBlock block;
CBlockIndex* pblockindex = mapBlockIndex[hashBestChain];
while (pblockindex->nHeight > nHeight)
pblockindex = pblockindex->pprev;
CBlockIndex* pblockindex = FindBlockByHeight(nHeight);
uint256 hash = *pblockindex->phashBlock;
const uint256& hash = *pblockindex->phashBlock;
pblockindex = mapBlockIndex[hash];
block.ReadFromDisk(pblockindex, true);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment