Skip to content

Commit 474f25b

Browse files
committed
Push islock invs when syncing mempool (#3250)
* Push islock invs when syncing mempool * Send islock invs right away instead of stacking them for later
1 parent 3b0f8ff commit 474f25b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/llmq/quorums_instantsend.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,17 @@ bool CInstantSendManager::GetInstantSendLockByHash(const uint256& hash, llmq::CI
14381438
return true;
14391439
}
14401440

1441+
bool CInstantSendManager::GetInstantSendLockHashByTxid(const uint256& txid, uint256& ret)
1442+
{
1443+
if (!IsInstantSendEnabled()) {
1444+
return false;
1445+
}
1446+
1447+
LOCK(cs);
1448+
ret = db.GetInstantSendLockHashByTxid(txid);
1449+
return !ret.IsNull();
1450+
}
1451+
14411452
bool CInstantSendManager::IsLocked(const uint256& txHash)
14421453
{
14431454
if (!IsInstantSendEnabled()) {

src/llmq/quorums_instantsend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ class CInstantSendManager : public CRecoveredSigsListener
164164

165165
bool AlreadyHave(const CInv& inv);
166166
bool GetInstantSendLockByHash(const uint256& hash, CInstantSendLock& ret);
167+
bool GetInstantSendLockHashByTxid(const uint256& txid, uint256& ret);
167168

168169
size_t GetInstantSendLockCount();
169170

src/net_processing.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3799,6 +3799,19 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
37993799
connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
38003800
vInv.clear();
38013801
}
3802+
3803+
uint256 islockHash;
3804+
if (!llmq::quorumInstantSendManager->GetInstantSendLockHashByTxid(hash, islockHash)) continue;
3805+
CInv islockInv(MSG_ISLOCK, islockHash);
3806+
pto->filterInventoryKnown.insert(islockHash);
3807+
3808+
LogPrint(BCLog::NET, "SendMessages -- queued inv: %s index=%d peer=%d\n", inv.ToString(), vInv.size(), pto->GetId());
3809+
vInv.push_back(inv);
3810+
if (vInv.size() == MAX_INV_SZ) {
3811+
LogPrint(BCLog::NET, "SendMessages -- pushing inv's: count=%d peer=%d\n", vInv.size(), pto->GetId());
3812+
connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
3813+
vInv.clear();
3814+
}
38023815
}
38033816
pto->timeLastMempoolReq = GetTime();
38043817
}

0 commit comments

Comments
 (0)