mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
rpc: minize getTipHash() calls in gbt
Set tip at the start of the function and only update it for a long poll. Additionally have getTipHash return an optional, so the caller can explicitly check that a tip exists.
This commit is contained in:
parent
7b4d3249ce
commit
dda0b0834f
3 changed files with 17 additions and 9 deletions
|
|
@ -847,11 +847,11 @@ public:
|
|||
return chainman().GetParams().IsTestChain();
|
||||
}
|
||||
|
||||
uint256 getTipHash() override
|
||||
std::optional<uint256> getTipHash() override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
CBlockIndex* tip{chainman().ActiveChain().Tip()};
|
||||
if (!tip) return uint256{0};
|
||||
if (!tip) return {};
|
||||
return tip->GetBlockHash();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue