From 36b68de5b2938722911db900ca299f7008780d01 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 29 Apr 2019 10:18:50 -0400 Subject: Remove getBlockDepth method from Chain::interface Pass conflicting height in CWallet::MarkConflicted --- src/interfaces/chain.cpp | 6 ------ src/interfaces/chain.h | 4 ---- src/wallet/wallet.cpp | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index 0635909cae..26856a00d3 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -58,12 +58,6 @@ class LockImpl : public Chain::Lock, public UniqueLock } return nullopt; } - int getBlockDepth(const uint256& hash) override - { - const Optional tip_height = getHeight(); - const Optional height = getBlockHeight(hash); - return tip_height && height ? *tip_height - *height + 1 : 0; - } uint256 getBlockHash(int height) override { LockAssertion lock(::cs_main); diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index e07ec1b371..349af152d5 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -76,10 +76,6 @@ public: //! included in the current chain. virtual Optional getBlockHeight(const uint256& hash) = 0; - //! Get block depth. Returns 1 for chain tip, 2 for preceding block, and - //! so on. Returns 0 for a block not included in the current chain. - virtual int getBlockDepth(const uint256& hash) = 0; - //! Get block hash. Height must be valid or this function will abort. virtual uint256 getBlockHash(int height) = 0; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4936e3851b..2bc39ea3d9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -986,7 +986,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c auto locked_chain = chain().lock(); LOCK(cs_wallet); - int conflictconfirms = -locked_chain->getBlockDepth(hashBlock); + int conflictconfirms = (m_last_block_processed_height - conflicting_height + 1) * -1; // If number of conflict confirms cannot be determined, this means // that the block is still unknown or not yet part of the main chain, // for example when loading the wallet during a reindex. Do nothing in that -- cgit v1.2.3