aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2020-12-18 14:24:55 -0500
committerCarl Dong <contact@carldong.me>2021-03-08 15:54:31 -0500
commit8a1d580b2156268e3ab30f902b3fc9aa87bd2819 (patch)
treea641c0473ffa75118a58d0291256718b46863a0f
parent4cde4a701b8856ac4ec9721b0226dbbfc52a71c3 (diff)
node/ifaces: NodeImpl: Use existing NodeContext member
-rw-r--r--src/node/interfaces.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index acd6d7847e..fd0c4dc2e0 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -182,18 +182,21 @@ public:
int getNumBlocks() override
{
LOCK(::cs_main);
- return ::ChainActive().Height();
+ assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
+ return m_context->chainman->ActiveChain().Height();
}
uint256 getBestBlockHash() override
{
- const CBlockIndex* tip = WITH_LOCK(::cs_main, return ::ChainActive().Tip());
+ assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
+ const CBlockIndex* tip = WITH_LOCK(::cs_main, return m_context->chainman->ActiveChain().Tip());
return tip ? tip->GetBlockHash() : Params().GenesisBlock().GetHash();
}
int64_t getLastBlockTime() override
{
LOCK(::cs_main);
- if (::ChainActive().Tip()) {
- return ::ChainActive().Tip()->GetBlockTime();
+ assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
+ if (m_context->chainman->ActiveChain().Tip()) {
+ return m_context->chainman->ActiveChain().Tip()->GetBlockTime();
}
return Params().GenesisBlock().GetBlockTime(); // Genesis block's time of current network
}
@@ -202,11 +205,15 @@ public:
const CBlockIndex* tip;
{
LOCK(::cs_main);
- tip = ::ChainActive().Tip();
+ assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
+ tip = m_context->chainman->ActiveChain().Tip();
}
return GuessVerificationProgress(Params().TxData(), tip);
}
- bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); }
+ bool isInitialBlockDownload() override {
+ assert(std::addressof(::ChainstateActive()) == std::addressof(m_context->chainman->ActiveChainstate()));
+ return m_context->chainman->ActiveChainstate().IsInitialBlockDownload();
+ }
bool getReindex() override { return ::fReindex; }
bool getImporting() override { return ::fImporting; }
void setNetworkActive(bool active) override
@@ -231,7 +238,8 @@ public:
bool getUnspentOutput(const COutPoint& output, Coin& coin) override
{
LOCK(::cs_main);
- return ::ChainstateActive().CoinsTip().GetCoin(output, coin);
+ assert(std::addressof(::ChainstateActive()) == std::addressof(m_context->chainman->ActiveChainstate()));
+ return m_context->chainman->ActiveChainstate().CoinsTip().GetCoin(output, coin);
}
WalletClient& walletClient() override
{