Skip to content

Commit

Permalink
Skip processing in SyncTransaction when chain is not synced yet (#2920)
Browse files Browse the repository at this point in the history
Applies to CInstantSendManager and CChainLocksHandler. This fixes extremely
high RAM usage on reindex and resync, which happens to many/all transactions
being kept track of non-locked TXs (nonLockedTxs) and TXs per
block (blockTxs).
  • Loading branch information
codablock authored and UdjinM6 committed May 13, 2019
1 parent c8a80b2 commit 394bec4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ void CChainLocksHandler::TrySignChainTip()

void CChainLocksHandler::SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int posInBlock)
{
if (!masternodeSync.IsBlockchainSynced()) {
return;
}

bool handleTx = true;
if (tx.IsCoinBase() || tx.vin.empty()) {
handleTx = false;
Expand Down
4 changes: 4 additions & 0 deletions src/llmq/quorums_instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,10 @@ void CInstantSendManager::SyncTransaction(const CTransaction& tx, const CBlockIn
}
}

if (!masternodeSync.IsBlockchainSynced()) {
return;
}

bool chainlocked = pindex && chainLocksHandler->HasChainLock(pindex->nHeight, pindex->GetBlockHash());
if (islockHash.IsNull() && !chainlocked) {
ProcessTx(tx, Params().GetConsensus());
Expand Down

0 comments on commit 394bec4

Please sign in to comment.