aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.cpp
diff options
context:
space:
mode:
authorAntoine Riard <ariard@student.42.fr>2019-07-15 18:20:12 -0400
committerAntoine Riard <ariard@student.42.fr>2020-04-30 14:37:21 -0400
commitde13363a472ea30dff2f8f55c6ae572281115380 (patch)
tree7e220b1927512f48b0c39d6c0120e6e99e22074b /src/interfaces/chain.cpp
parentb855592d835bf4b3fb1263b88d4f96669a1722b1 (diff)
downloadbitcoin-de13363a472ea30dff2f8f55c6ae572281115380.tar.xz
[wallet] Move getBlockHeight from Chain::Lock interface to simple Chain
Add HaveChain to assert chain access for wallet-tool in LoadToWallet.
Diffstat (limited to 'src/interfaces/chain.cpp')
-rw-r--r--src/interfaces/chain.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index b891cf2ee5..ccdbf1f1d1 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -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);