node/ifaces: NodeImpl: Use existing NodeContext member

This commit is contained in:
Carl Dong 2020-12-18 14:24:55 -05:00
parent 4cde4a701b
commit 8a1d580b21

View file

@ -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
{