diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d80bddecfc..c43067a6a6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5551,17 +5551,22 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const bool CMerkleTx::IsLockedByInstantSend() const { - return llmq::quorumInstantSendManager->IsLocked(GetHash()); + if (!fIsInstantSendLocked) { + fIsInstantSendLocked = llmq::quorumInstantSendManager->IsLocked(GetHash()); + } + return fIsInstantSendLocked; } bool CMerkleTx::IsChainLocked() const { - AssertLockHeld(cs_main); - BlockMap::iterator mi = mapBlockIndex.find(hashBlock); - if (mi != mapBlockIndex.end() && mi->second != nullptr) { - return llmq::chainLocksHandler->HasChainLock(mi->second->nHeight, hashBlock); + if (!fIsChainlocked) { + AssertLockHeld(cs_main); + BlockMap::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && mi->second != nullptr) { + fIsChainlocked = llmq::chainLocksHandler->HasChainLock(mi->second->nHeight, hashBlock); + } } - return false; + return fIsChainlocked; } int CMerkleTx::GetBlocksToMaturity() const diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e447cb8e13..65041e8148 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -206,6 +206,9 @@ private: /** Constant used in hashBlock to indicate tx has been abandoned */ static const uint256 ABANDON_HASH; + mutable bool fIsChainlocked{false}; + mutable bool fIsInstantSendLocked{false}; + public: CTransactionRef tx; uint256 hashBlock;