aboutsummaryrefslogtreecommitdiff
path: root/src/rest.cpp
diff options
context:
space:
mode:
authorJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-01-12 00:23:09 +0000
committerJoão Barbosa <joao.paulo.barbosa@gmail.com>2018-03-06 19:52:19 +0000
commit92fabcd443322dcfdf2b3477515fae79e8647d86 (patch)
tree5511c22adffa3eaccb75afdd2ec53c81550ff7d3 /src/rest.cpp
parent43a32b739551b5a6cac8102afd52e2b9efc81726 (diff)
downloadbitcoin-92fabcd443322dcfdf2b3477515fae79e8647d86.tar.xz
Add LookupBlockIndex function
Diffstat (limited to 'src/rest.cpp')
-rw-r--r--src/rest.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rest.cpp b/src/rest.cpp
index 8cba59dbbc..f47b40343b 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -147,8 +147,7 @@ static bool rest_headers(HTTPRequest* req,
headers.reserve(count);
{
LOCK(cs_main);
- BlockMap::const_iterator it = mapBlockIndex.find(hash);
- const CBlockIndex *pindex = (it != mapBlockIndex.end()) ? it->second : nullptr;
+ const CBlockIndex* pindex = LookupBlockIndex(hash);
while (pindex != nullptr && chainActive.Contains(pindex)) {
headers.push_back(pindex);
if (headers.size() == (unsigned long)count)
@@ -212,10 +211,11 @@ static bool rest_block(HTTPRequest* req,
CBlockIndex* pblockindex = nullptr;
{
LOCK(cs_main);
- if (mapBlockIndex.count(hash) == 0)
+ pblockindex = LookupBlockIndex(hash);
+ if (!pblockindex) {
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found");
+ }
- pblockindex = mapBlockIndex[hash];
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)");