diff options
| author | Antoine Riard <[email protected]> | 2019-04-22 14:22:25 -0400 |
|---|---|---|
| committer | Antoine Riard <[email protected]> | 2019-11-06 13:36:43 -0500 |
| commit | 0ff03871add000f8b4d8f82aeb168eed2fc9dc5f (patch) | |
| tree | 8700c1569ae9e6d419f4f0d6d3dc51c7221e0185 /src/wallet/wallet.cpp | |
| parent | Only return early from BlockUntilSyncedToCurrentChain if current tip (diff) | |
| download | discoin-0ff03871add000f8b4d8f82aeb168eed2fc9dc5f.tar.xz discoin-0ff03871add000f8b4d8f82aeb168eed2fc9dc5f.zip | |
Use CWallet::m_last_block_processed_height in GetDepthInMainChain
Avoid to lock chain to query state thanks to tracking last block
height in CWallet.
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9fdb07ce8..949977104 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3936,9 +3936,11 @@ CKeyPool::CKeyPool(const CPubKey& vchPubKeyIn, bool internalIn) int CWalletTx::GetDepthInMainChain(interfaces::Chain::Lock& locked_chain) const { + assert(pwallet != nullptr); + AssertLockHeld(pwallet->cs_wallet); if (isUnconfirmed() || isAbandoned()) return 0; - return locked_chain.getBlockDepth(m_confirm.hashBlock) * (isConflicted() ? -1 : 1); + return (pwallet->GetLastBlockHeight() - m_confirm.block_height + 1) * (isConflicted() ? -1 : 1); } int CWalletTx::GetBlocksToMaturity(interfaces::Chain::Lock& locked_chain) const |