Skip to content

Commit

Permalink
Remove getBlockDepth method from Chain::interface
Browse files Browse the repository at this point in the history
Pass conflicting height in CWallet::MarkConflicted
  • Loading branch information
Antoine Riard committed Jul 9, 2019
1 parent 0a53dfe commit 1458ded
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
6 changes: 0 additions & 6 deletions src/interfaces/chain.cpp
Expand Up @@ -57,12 +57,6 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
}
return nullopt;
}
int getBlockDepth(const uint256& hash) override
{
const Optional<int> tip_height = getHeight();
const Optional<int> height = getBlockHeight(hash);
return tip_height && height ? *tip_height - *height + 1 : 0;
}
uint256 getBlockHash(int height) override
{
LockAssertion lock(::cs_main);
Expand Down
4 changes: 0 additions & 4 deletions src/interfaces/chain.h
Expand Up @@ -80,10 +80,6 @@ class Chain
//! included in the current chain.
virtual Optional<int> 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;

Expand Down
3 changes: 1 addition & 2 deletions src/wallet/wallet.cpp
Expand Up @@ -1207,10 +1207,9 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)

void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, const uint256& hashTx)
{
auto locked_chain = chain().lock();
LOCK(cs_wallet);

int conflictconfirms = -locked_chain->getBlockDepth(hashBlock);
int conflictconfirms = -conflicting_height;
// 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
Expand Down

0 comments on commit 1458ded

Please sign in to comment.