mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
[wallet] Move getBlockHeight from Chain::Lock interface to simple Chain
Add HaveChain to assert chain access for wallet-tool in LoadToWallet.
This commit is contained in:
@@ -55,15 +55,6 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec
|
||||
|
||||
class LockImpl : public Chain::Lock, public UniqueLock<RecursiveMutex>
|
||||
{
|
||||
Optional<int> getBlockHeight(const uint256& hash) override
|
||||
{
|
||||
LockAssertion lock(::cs_main);
|
||||
CBlockIndex* block = LookupBlockIndex(hash);
|
||||
if (block && ::ChainActive().Contains(block)) {
|
||||
return block->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
}
|
||||
uint256 getBlockHash(int height) override
|
||||
{
|
||||
LockAssertion lock(::cs_main);
|
||||
@@ -234,6 +225,15 @@ public:
|
||||
}
|
||||
return nullopt;
|
||||
}
|
||||
Optional<int> getBlockHeight(const uint256& hash) override
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
CBlockIndex* block = LookupBlockIndex(hash);
|
||||
if (block && ::ChainActive().Contains(block)) {
|
||||
return block->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
}
|
||||
bool findBlock(const uint256& hash, const FoundBlock& block) override
|
||||
{
|
||||
WAIT_LOCK(cs_main, lock);
|
||||
|
||||
Reference in New Issue
Block a user