aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.cpp
diff options
context:
space:
mode:
authorAntoine Riard <ariard@student.42.fr>2019-07-09 20:07:39 -0400
committerAntoine Riard <ariard@student.42.fr>2020-04-30 14:31:19 -0400
commitb855592d835bf4b3fb1263b88d4f96669a1722b1 (patch)
tree8e36d5158106b46fb12b4bb1813eb0685a03d0a7 /src/interfaces/chain.cpp
parent0f204dd3f21b997334a0e99954c939db154b64ca (diff)
downloadbitcoin-b855592d835bf4b3fb1263b88d4f96669a1722b1.tar.xz
[wallet] Move getHeight from Chain::Lock interface to simple Chain
Instead of calling getHeight, we rely on CWallet::m_last_block processed_height where it's possible.
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 0e7641ae32..b891cf2ee5 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> getHeight() override
- {
- LockAssertion lock(::cs_main);
- int height = ::ChainActive().Height();
- if (height >= 0) {
- return height;
- }
- return nullopt;
- }
Optional<int> getBlockHeight(const uint256& hash) override
{
LockAssertion lock(::cs_main);
@@ -234,6 +225,15 @@ public:
std::unique_ptr<Chain::Lock> result = std::move(lock); // Temporary to avoid CWG 1579
return result;
}
+ Optional<int> getHeight() override
+ {
+ LOCK(::cs_main);
+ int height = ::ChainActive().Height();
+ if (height >= 0) {
+ return height;
+ }
+ return nullopt;
+ }
bool findBlock(const uint256& hash, const FoundBlock& block) override
{
WAIT_LOCK(cs_main, lock);