diff options
author | Carl Dong <contact@carldong.me> | 2020-12-24 20:06:34 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-04-19 14:34:56 -0400 |
commit | 3308ecd3fc254ee4ef9f803c09f00ba4dc968520 (patch) | |
tree | 20898e5727d2c23d45ef6f786225b5291f201c28 /src/rest.cpp | |
parent | c96524113c48553c4bbad63077a25494eca8159e (diff) |
move-mostly: Make fHavePruned a BlockMan member
[META] In the next commit, we move the clearing of fHavePruned to
BlockManager::Unload()
Diffstat (limited to 'src/rest.cpp')
-rw-r--r-- | src/rest.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/rest.cpp b/src/rest.cpp index a8eba05c3f..2aeb9c68c3 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -37,7 +37,6 @@ #include <univalue.h> using node::GetTransaction; -using node::IsBlockPruned; using node::NodeContext; using node::ReadBlockFromDisk; @@ -295,10 +294,10 @@ static bool rest_block(const std::any& context, CBlock block; const CBlockIndex* pblockindex = nullptr; const CBlockIndex* tip = nullptr; + ChainstateManager* maybe_chainman = GetChainman(context, req); + if (!maybe_chainman) return false; + ChainstateManager& chainman = *maybe_chainman; { - ChainstateManager* maybe_chainman = GetChainman(context, req); - if (!maybe_chainman) return false; - ChainstateManager& chainman = *maybe_chainman; LOCK(cs_main); tip = chainman.ActiveChain().Tip(); pblockindex = chainman.m_blockman.LookupBlockIndex(hash); @@ -306,7 +305,7 @@ static bool rest_block(const std::any& context, return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } - if (IsBlockPruned(pblockindex)) + if (chainman.m_blockman.IsBlockPruned(pblockindex)) return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)"); if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus())) @@ -333,7 +332,7 @@ static bool rest_block(const std::any& context, } case RESTResponseFormat::JSON: { - UniValue objBlock = blockToJSON(block, tip, pblockindex, tx_verbosity); + UniValue objBlock = blockToJSON(chainman.m_blockman, block, tip, pblockindex, tx_verbosity); std::string strJSON = objBlock.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); |