diff options
author | TheCharlatan <seb.kung@gmail.com> | 2023-02-18 15:49:41 +0100 |
---|---|---|
committer | TheCharlatan <seb.kung@gmail.com> | 2023-05-10 19:06:53 +0200 |
commit | f0bb1021f0d60f5f19176e67a66fcf7c325f88d1 (patch) | |
tree | 042a49839ae28506b5de80a32895ddf6812264bb /src/rest.cpp | |
parent | cfbb2124939822e95265a39242ffca3d86bac6e8 (diff) | |
download | bitcoin-f0bb1021f0d60f5f19176e67a66fcf7c325f88d1.tar.xz |
refactor: Move functions to BlockManager methods
This is a commit in preparation for the next few commits. The functions
are moved to methods to avoid their re-declaration for the purpose of
passing in BlockManager options.
The functions that were now moved into the BlockManager should no longer
use the params as an argument, but instead use the member variable.
In the moved ReadBlockFromDisk and UndoReadFromDisk, change
the function signature to accept a reference to a CBlockIndex instead of
a raw pointer. The pointer is expected to be non-null, so reflect that
in the type.
To allow for the move of functions to BlockManager methods all call
sites require an instantiated BlockManager, or a callback to one.
Diffstat (limited to 'src/rest.cpp')
-rw-r--r-- | src/rest.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/rest.cpp b/src/rest.cpp index e46406f1ad..dae064f89d 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -36,7 +36,6 @@ using node::GetTransaction; using node::NodeContext; -using node::ReadBlockFromDisk; static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once static constexpr unsigned int MAX_REST_HEADERS_RESULTS = 2000; @@ -311,7 +310,7 @@ static bool rest_block(const std::any& context, } - if (!ReadBlockFromDisk(block, pblockindex, chainman.GetParams().GetConsensus())) { + if (!chainman.m_blockman.ReadBlockFromDisk(block, *pblockindex)) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } @@ -716,7 +715,7 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string const NodeContext* const node = GetNodeContext(context, req); if (!node) return false; uint256 hashBlock = uint256(); - const CTransactionRef tx = GetTransaction(/*block_index=*/nullptr, node->mempool.get(), hash, Params().GetConsensus(), hashBlock); + const CTransactionRef tx = GetTransaction(/*block_index=*/nullptr, node->mempool.get(), hash, hashBlock, node->chainman->m_blockman); if (!tx) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } |