chainlocks: Relay clsig inv only after bestChainLock(Hash) are assigned (#3990)

Fixes a race condidion when we might reply with `notfound` to other nodes because we might still be waiting for locks here.
This commit is contained in:
UdjinM6 2021-02-16 18:54:19 +03:00 committed by GitHub
parent ebea362d06
commit 77e9a4a83b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,13 +135,13 @@ void CChainLocksHandler::ProcessNewChainLock(const NodeId from, const llmq::CCha
return;
}
g_connman->RelayInv(clsigInv, LLMQS_PROTO_VERSION);
{
LOCK2(cs_main, cs);
bestChainLockHash = hash;
bestChainLock = clsig;
g_connman->RelayInv(clsigInv, LLMQS_PROTO_VERSION);
const CBlockIndex* pindex = LookupBlockIndex(clsig.blockHash);
if (!pindex) {
// we don't know the block/header for this CLSIG yet, so bail out for now