mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-14 20:20:43 +02:00
Remove getBlockDepth method from Chain::interface
Pass conflicting height in CWallet::MarkConflicted
This commit is contained in:
parent
b66c429c56
commit
36b68de5b2
@ -58,12 +58,6 @@ class LockImpl : public Chain::Lock, public UniqueLock<CCriticalSection>
|
|||||||
}
|
}
|
||||||
return nullopt;
|
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
|
uint256 getBlockHash(int height) override
|
||||||
{
|
{
|
||||||
LockAssertion lock(::cs_main);
|
LockAssertion lock(::cs_main);
|
||||||
|
@ -76,10 +76,6 @@ public:
|
|||||||
//! included in the current chain.
|
//! included in the current chain.
|
||||||
virtual Optional<int> getBlockHeight(const uint256& hash) = 0;
|
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.
|
//! Get block hash. Height must be valid or this function will abort.
|
||||||
virtual uint256 getBlockHash(int height) = 0;
|
virtual uint256 getBlockHash(int height) = 0;
|
||||||
|
|
||||||
|
@ -986,7 +986,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
|
|||||||
auto locked_chain = chain().lock();
|
auto locked_chain = chain().lock();
|
||||||
LOCK(cs_wallet);
|
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
|
// If number of conflict confirms cannot be determined, this means
|
||||||
// that the block is still unknown or not yet part of the main chain,
|
// 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
|
// for example when loading the wallet during a reindex. Do nothing in that
|
||||||
|
Loading…
Reference in New Issue
Block a user