wallet: Add CL/IS caches in CMerkleTx

This commit is contained in:
xdustinface 2020-10-05 02:44:04 +02:00
parent 12c840f8ce
commit 4dca83ba25
2 changed files with 14 additions and 6 deletions

View File

@ -5551,17 +5551,22 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const
bool CMerkleTx::IsLockedByInstantSend() const bool CMerkleTx::IsLockedByInstantSend() const
{ {
return llmq::quorumInstantSendManager->IsLocked(GetHash()); if (!fIsInstantSendLocked) {
fIsInstantSendLocked = llmq::quorumInstantSendManager->IsLocked(GetHash());
}
return fIsInstantSendLocked;
} }
bool CMerkleTx::IsChainLocked() const bool CMerkleTx::IsChainLocked() const
{ {
if (!fIsChainlocked) {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
BlockMap::iterator mi = mapBlockIndex.find(hashBlock); BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && mi->second != nullptr) { if (mi != mapBlockIndex.end() && mi->second != nullptr) {
return llmq::chainLocksHandler->HasChainLock(mi->second->nHeight, hashBlock); fIsChainlocked = llmq::chainLocksHandler->HasChainLock(mi->second->nHeight, hashBlock);
} }
return false; }
return fIsChainlocked;
} }
int CMerkleTx::GetBlocksToMaturity() const int CMerkleTx::GetBlocksToMaturity() const

View File

@ -206,6 +206,9 @@ private:
/** Constant used in hashBlock to indicate tx has been abandoned */ /** Constant used in hashBlock to indicate tx has been abandoned */
static const uint256 ABANDON_HASH; static const uint256 ABANDON_HASH;
mutable bool fIsChainlocked{false};
mutable bool fIsInstantSendLocked{false};
public: public:
CTransactionRef tx; CTransactionRef tx;
uint256 hashBlock; uint256 hashBlock;