Skip to content

Commit 8a1d580

Browse files
committed
node/ifaces: NodeImpl: Use existing NodeContext member
1 parent 4cde4a7 commit 8a1d580

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/node/interfaces.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,21 @@ class NodeImpl : public Node
182182
int getNumBlocks() override
183183
{
184184
LOCK(::cs_main);
185-
return ::ChainActive().Height();
185+
assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
186+
return m_context->chainman->ActiveChain().Height();
186187
}
187188
uint256 getBestBlockHash() override
188189
{
189-
const CBlockIndex* tip = WITH_LOCK(::cs_main, return ::ChainActive().Tip());
190+
assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
191+
const CBlockIndex* tip = WITH_LOCK(::cs_main, return m_context->chainman->ActiveChain().Tip());
190192
return tip ? tip->GetBlockHash() : Params().GenesisBlock().GetHash();
191193
}
192194
int64_t getLastBlockTime() override
193195
{
194196
LOCK(::cs_main);
195-
if (::ChainActive().Tip()) {
196-
return ::ChainActive().Tip()->GetBlockTime();
197+
assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
198+
if (m_context->chainman->ActiveChain().Tip()) {
199+
return m_context->chainman->ActiveChain().Tip()->GetBlockTime();
197200
}
198201
return Params().GenesisBlock().GetBlockTime(); // Genesis block's time of current network
199202
}
@@ -202,11 +205,15 @@ class NodeImpl : public Node
202205
const CBlockIndex* tip;
203206
{
204207
LOCK(::cs_main);
205-
tip = ::ChainActive().Tip();
208+
assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
209+
tip = m_context->chainman->ActiveChain().Tip();
206210
}
207211
return GuessVerificationProgress(Params().TxData(), tip);
208212
}
209-
bool isInitialBlockDownload() override { return ::ChainstateActive().IsInitialBlockDownload(); }
213+
bool isInitialBlockDownload() override {
214+
assert(std::addressof(::ChainstateActive()) == std::addressof(m_context->chainman->ActiveChainstate()));
215+
return m_context->chainman->ActiveChainstate().IsInitialBlockDownload();
216+
}
210217
bool getReindex() override { return ::fReindex; }
211218
bool getImporting() override { return ::fImporting; }
212219
void setNetworkActive(bool active) override
@@ -231,7 +238,8 @@ class NodeImpl : public Node
231238
bool getUnspentOutput(const COutPoint& output, Coin& coin) override
232239
{
233240
LOCK(::cs_main);
234-
return ::ChainstateActive().CoinsTip().GetCoin(output, coin);
241+
assert(std::addressof(::ChainstateActive()) == std::addressof(m_context->chainman->ActiveChainstate()));
242+
return m_context->chainman->ActiveChainstate().CoinsTip().GetCoin(output, coin);
235243
}
236244
WalletClient& walletClient() override
237245
{

0 commit comments

Comments
 (0)