mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Added best block hash to the NotifyHeaderTip and NotifyBlockTip signals.
[ClientModel] best header/block hash cached.
This commit is contained in:
parent
cfe22a5f9e
commit
2f867203b0
11 changed files with 57 additions and 34 deletions
|
|
@ -187,6 +187,11 @@ public:
|
|||
LOCK(::cs_main);
|
||||
return ::ChainActive().Height();
|
||||
}
|
||||
uint256 getBestBlockHash() override
|
||||
{
|
||||
const CBlockIndex* tip = WITH_LOCK(::cs_main, return ::ChainActive().Tip());
|
||||
return tip ? tip->GetBlockHash() : Params().GenesisBlock().GetHash();
|
||||
}
|
||||
int64_t getLastBlockTime() override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
|
@ -310,7 +315,7 @@ public:
|
|||
std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn) override
|
||||
{
|
||||
return MakeHandler(::uiInterface.NotifyBlockTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) {
|
||||
fn(sync_state, block->nHeight, block->GetBlockTime(),
|
||||
fn(sync_state, block->GetBlockHash(), block->nHeight, block->GetBlockTime(),
|
||||
GuessVerificationProgress(Params().TxData(), block));
|
||||
}));
|
||||
}
|
||||
|
|
@ -318,7 +323,7 @@ public:
|
|||
{
|
||||
return MakeHandler(
|
||||
::uiInterface.NotifyHeaderTip_connect([fn](SynchronizationState sync_state, const CBlockIndex* block) {
|
||||
fn(sync_state, block->nHeight, block->GetBlockTime(),
|
||||
fn(sync_state, block->GetBlockHash(), block->nHeight, block->GetBlockTime(),
|
||||
/* verification progress is unused when a header was received */ 0);
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue