mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
node/ifaces: NodeImpl: Use existing NodeContext member
This commit is contained in:
parent
4cde4a701b
commit
8a1d580b21
1 changed files with 15 additions and 7 deletions
|
@ -182,18 +182,21 @@ public:
|
||||||
int getNumBlocks() override
|
int getNumBlocks() override
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
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
|
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();
|
return tip ? tip->GetBlockHash() : Params().GenesisBlock().GetHash();
|
||||||
}
|
}
|
||||||
int64_t getLastBlockTime() override
|
int64_t getLastBlockTime() override
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
LOCK(::cs_main);
|
||||||
if (::ChainActive().Tip()) {
|
assert(std::addressof(::ChainActive()) == std::addressof(m_context->chainman->ActiveChain()));
|
||||||
return ::ChainActive().Tip()->GetBlockTime();
|
if (m_context->chainman->ActiveChain().Tip()) {
|
||||||
|
return m_context->chainman->ActiveChain().Tip()->GetBlockTime();
|
||||||
}
|
}
|
||||||
return Params().GenesisBlock().GetBlockTime(); // Genesis block's time of current network
|
return Params().GenesisBlock().GetBlockTime(); // Genesis block's time of current network
|
||||||
}
|
}
|
||||||
|
@ -202,11 +205,15 @@ public:
|
||||||
const CBlockIndex* tip;
|
const CBlockIndex* tip;
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
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);
|
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 getReindex() override { return ::fReindex; }
|
||||||
bool getImporting() override { return ::fImporting; }
|
bool getImporting() override { return ::fImporting; }
|
||||||
void setNetworkActive(bool active) override
|
void setNetworkActive(bool active) override
|
||||||
|
@ -231,7 +238,8 @@ public:
|
||||||
bool getUnspentOutput(const COutPoint& output, Coin& coin) override
|
bool getUnspentOutput(const COutPoint& output, Coin& coin) override
|
||||||
{
|
{
|
||||||
LOCK(::cs_main);
|
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
|
WalletClient& walletClient() override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue