Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/node.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | public: | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
int getNumBlocks() override { | int getNumBlocks() override { | ||||
LOCK(::cs_main); | LOCK(::cs_main); | ||||
return ::ChainActive().Height(); | return ::ChainActive().Height(); | ||||
} | } | ||||
BlockHash getBestBlockHash() override { | |||||
const CBlockIndex *tip = | |||||
WITH_LOCK(::cs_main, return ::ChainActive().Tip()); | |||||
return tip ? tip->GetBlockHash() | |||||
: Params().GenesisBlock().GetHash(); | |||||
} | |||||
int64_t getLastBlockTime() override { | int64_t getLastBlockTime() override { | ||||
LOCK(::cs_main); | LOCK(::cs_main); | ||||
if (::ChainActive().Tip()) { | if (::ChainActive().Tip()) { | ||||
return ::ChainActive().Tip()->GetBlockTime(); | return ::ChainActive().Tip()->GetBlockTime(); | ||||
} | } | ||||
// Genesis block's time of current network | // Genesis block's time of current network | ||||
return Params().GenesisBlock().GetBlockTime(); | return Params().GenesisBlock().GetBlockTime(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | public: | ||||
handleBannedListChanged(BannedListChangedFn fn) override { | handleBannedListChanged(BannedListChangedFn fn) override { | ||||
return MakeHandler(::uiInterface.BannedListChanged_connect(fn)); | return MakeHandler(::uiInterface.BannedListChanged_connect(fn)); | ||||
} | } | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleNotifyBlockTip(NotifyBlockTipFn fn) override { | handleNotifyBlockTip(NotifyBlockTipFn fn) override { | ||||
return MakeHandler(::uiInterface.NotifyBlockTip_connect( | return MakeHandler(::uiInterface.NotifyBlockTip_connect( | ||||
[fn](SynchronizationState sync_state, | [fn](SynchronizationState sync_state, | ||||
const CBlockIndex *block) { | const CBlockIndex *block) { | ||||
fn(sync_state, block->nHeight, block->GetBlockTime(), | fn(sync_state, block->GetBlockHash(), block->nHeight, | ||||
block->GetBlockTime(), | |||||
GuessVerificationProgress(Params().TxData(), block)); | GuessVerificationProgress(Params().TxData(), block)); | ||||
})); | })); | ||||
} | } | ||||
std::unique_ptr<Handler> | std::unique_ptr<Handler> | ||||
handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { | handleNotifyHeaderTip(NotifyHeaderTipFn fn) override { | ||||
/* verification progress is unused when a header was received */ | /* verification progress is unused when a header was received */ | ||||
return MakeHandler(::uiInterface.NotifyHeaderTip_connect( | return MakeHandler(::uiInterface.NotifyHeaderTip_connect( | ||||
[fn](SynchronizationState sync_state, | [fn](SynchronizationState sync_state, | ||||
const CBlockIndex *block) { | const CBlockIndex *block) { | ||||
fn(sync_state, block->nHeight, block->GetBlockTime(), 0); | fn(sync_state, block->GetBlockHash(), block->nHeight, | ||||
block->GetBlockTime(), 0); | |||||
})); | })); | ||||
} | } | ||||
NodeContext *context() override { return m_context; } | NodeContext *context() override { return m_context; } | ||||
void setContext(NodeContext *context) override { | void setContext(NodeContext *context) override { | ||||
m_context = context; | m_context = context; | ||||
if (context) { | if (context) { | ||||
m_context_ref.Set(*context); | m_context_ref.Set(*context); | ||||
} else { | } else { | ||||
Show All 13 Lines |