aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2020-08-25 17:39:57 -0400
committerCarl Dong <contact@carldong.me>2021-01-28 14:15:26 -0500
commiteae54e6e60d7ed05b29d8345c0bb055397149ce8 (patch)
treeca337597b1656e3a68bb585d70eacd8868bdcd50 /src/node
parent15d20f40e1321b24963b40c12958c7d30ad112ec (diff)
scripted-diff: Use BlockManager::LookupBlockIndex
[META] In a previous commit, we moved ::LookupBlockIndex to become a member function of BlockManager. This commit is split out from that one since it can be expressed nicely as a scripted-diff. -BEGIN VERIFY SCRIPT- find_regex='LookupBlockIndex' \ && git grep -l -E "$find_regex" -- src \ | grep -v '^src/validation\.\(cpp\|h\)$' \ | xargs sed -i -E "s@${find_regex}@g_chainman.m_blockman.LookupBlockIndex@g" -END VERIFY SCRIPT-
Diffstat (limited to 'src/node')
-rw-r--r--src/node/coinstats.cpp2
-rw-r--r--src/node/interfaces.cpp16
2 files changed, 9 insertions, 9 deletions
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index 02e50c4dbe..56113cb731 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -63,7 +63,7 @@ static bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, const
stats.hashBlock = pcursor->GetBestBlock();
{
LOCK(cs_main);
- stats.nHeight = LookupBlockIndex(stats.hashBlock)->nHeight;
+ stats.nHeight = g_chainman.m_blockman.LookupBlockIndex(stats.hashBlock)->nHeight;
}
PrepareHash(hash_obj, stats);
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index e07eaa33d8..e0bd07bc5a 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -456,7 +456,7 @@ public:
{
WAIT_LOCK(cs_main, lock);
const CChain& active = Assert(m_node.chainman)->ActiveChain();
- return FillBlock(LookupBlockIndex(hash), block, lock, active);
+ return FillBlock(g_chainman.m_blockman.LookupBlockIndex(hash), block, lock, active);
}
bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock& block) override
{
@@ -468,7 +468,7 @@ public:
{
WAIT_LOCK(cs_main, lock);
const CChain& active = Assert(m_node.chainman)->ActiveChain();
- if (const CBlockIndex* block = LookupBlockIndex(block_hash)) {
+ if (const CBlockIndex* block = g_chainman.m_blockman.LookupBlockIndex(block_hash)) {
if (const CBlockIndex* ancestor = block->GetAncestor(ancestor_height)) {
return FillBlock(ancestor, ancestor_out, lock, active);
}
@@ -479,8 +479,8 @@ public:
{
WAIT_LOCK(cs_main, lock);
const CChain& active = Assert(m_node.chainman)->ActiveChain();
- const CBlockIndex* block = LookupBlockIndex(block_hash);
- const CBlockIndex* ancestor = LookupBlockIndex(ancestor_hash);
+ const CBlockIndex* block = g_chainman.m_blockman.LookupBlockIndex(block_hash);
+ const CBlockIndex* ancestor = g_chainman.m_blockman.LookupBlockIndex(ancestor_hash);
if (block && ancestor && block->GetAncestor(ancestor->nHeight) != ancestor) ancestor = nullptr;
return FillBlock(ancestor, ancestor_out, lock, active);
}
@@ -488,8 +488,8 @@ public:
{
WAIT_LOCK(cs_main, lock);
const CChain& active = Assert(m_node.chainman)->ActiveChain();
- const CBlockIndex* block1 = LookupBlockIndex(block_hash1);
- const CBlockIndex* block2 = LookupBlockIndex(block_hash2);
+ const CBlockIndex* block1 = g_chainman.m_blockman.LookupBlockIndex(block_hash1);
+ const CBlockIndex* block2 = g_chainman.m_blockman.LookupBlockIndex(block_hash2);
const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
// Using & instead of && below to avoid short circuiting and leaving
// output uninitialized.
@@ -499,7 +499,7 @@ public:
double guessVerificationProgress(const uint256& block_hash) override
{
LOCK(cs_main);
- return GuessVerificationProgress(Params().TxData(), LookupBlockIndex(block_hash));
+ return GuessVerificationProgress(Params().TxData(), g_chainman.m_blockman.LookupBlockIndex(block_hash));
}
bool hasBlocks(const uint256& block_hash, int min_height, Optional<int> max_height) override
{
@@ -511,7 +511,7 @@ public:
// used to limit the range, and passing min_height that's too low or
// max_height that's too high will not crash or change the result.
LOCK(::cs_main);
- if (CBlockIndex* block = LookupBlockIndex(block_hash)) {
+ if (CBlockIndex* block = g_chainman.m_blockman.LookupBlockIndex(block_hash)) {
if (max_height && block->nHeight >= *max_height) block = block->GetAncestor(*max_height);
for (; block->nStatus & BLOCK_HAVE_DATA; block = block->pprev) {
// Check pprev to not segfault if min_height is too low