File tree Expand file tree Collapse file tree 2 files changed +10
-17
lines changed
Expand file tree Collapse file tree 2 files changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -4321,24 +4321,11 @@ CWalletKey::CWalletKey(int64_t nExpires)
43214321
43224322int CWalletTx::GetDepthInMainChain () const
43234323{
4324+ assert (pwallet != nullptr );
4325+ AssertLockHeld (pwallet->cs_wallet );
43244326 if (isUnconfirmed () || isAbandoned ()) return 0 ;
4325- AssertLockHeld (cs_main);
4326- int nResult;
4327-
4328- // Find the block it claims to be in
4329- BlockMap::iterator mi = mapBlockIndex.find (m_confirm.hashBlock );
4330- if (mi == mapBlockIndex.end ()) {
4331- nResult = 0 ;
4332- } else {
4333- CBlockIndex* pindex = (*mi).second ;
4334- if (!pindex || !chainActive.Contains (pindex)) {
4335- nResult = 0 ;
4336- } else {
4337- nResult = (isConflicted () ? (-1 ) : 1 ) * (chainActive.Height () - pindex->nHeight + 1 );
4338- }
4339- }
43404327
4341- return nResult ;
4328+ return (pwallet-> GetLastBlockHeight () - m_confirm. block_height + 1 ) * ( isConflicted () ? - 1 : 1 ) ;
43424329}
43434330
43444331int CWalletTx::GetBlocksToMaturity () const
Original file line number Diff line number Diff line change @@ -520,7 +520,13 @@ class CWalletTx
520520 * 0 : in memory pool, waiting to be included in a block
521521 * >=1 : this many blocks deep in the main chain
522522 */
523- int GetDepthInMainChain () const ;
523+ // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
524+ // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation
525+ // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to
526+ // resolve the issue of member access into incomplete type CWallet. Note
527+ // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
528+ // in place.
529+ int GetDepthInMainChain () const NO_THREAD_SAFETY_ANALYSIS;
524530 bool IsInMainChainImmature () const ;
525531 int GetBlocksToMaturity () const ;
526532
You can’t perform that action at this time.
0 commit comments