Merge pull request #1612 from luke-jr/opti_getblkhash

Optimize JSON-RPC getblockhash
This commit is contained in:
Gregory Maxwell
2012-08-01 11:49:26 -07:00
3 changed files with 21 additions and 4 deletions

View File

@@ -2047,10 +2047,7 @@ Value getblockhash(const Array& params, bool fHelp)
if (nHeight < 0 || nHeight > nBestHeight)
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);
return pblockindex->phashBlock->GetHex();
}