Skip to content

Commit 36b68de

Browse files
author
Antoine Riard
committed
Remove getBlockDepth method from Chain::interface
Pass conflicting height in CWallet::MarkConflicted
1 parent b66c429 commit 36b68de

File tree

3 files changed

+1
-11
lines changed

3 files changed

+1
-11
lines changed

src/interfaces/chain.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
5858
}
5959
return nullopt;
6060
}
61-
int getBlockDepth(const uint256& hash) override
62-
{
63-
const Optional<int> tip_height = getHeight();
64-
const Optional<int> height = getBlockHeight(hash);
65-
return tip_height && height ? *tip_height - *height + 1 : 0;
66-
}
6761
uint256 getBlockHash(int height) override
6862
{
6963
LockAssertion lock(::cs_main);

src/interfaces/chain.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ class Chain
7676
//! included in the current chain.
7777
virtual Optional<int> getBlockHeight(const uint256& hash) = 0;
7878

79-
//! Get block depth. Returns 1 for chain tip, 2 for preceding block, and
80-
//! so on. Returns 0 for a block not included in the current chain.
81-
virtual int getBlockDepth(const uint256& hash) = 0;
82-
8379
//! Get block hash. Height must be valid or this function will abort.
8480
virtual uint256 getBlockHash(int height) = 0;
8581

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
986986
auto locked_chain = chain().lock();
987987
LOCK(cs_wallet);
988988

989-
int conflictconfirms = -locked_chain->getBlockDepth(hashBlock);
989+
int conflictconfirms = (m_last_block_processed_height - conflicting_height + 1) * -1;
990990
// If number of conflict confirms cannot be determined, this means
991991
// that the block is still unknown or not yet part of the main chain,
992992
// for example when loading the wallet during a reindex. Do nothing in that

0 commit comments

Comments
 (0)