From 77e9a4a83beb3ff94ea229cf0c9c01662754806a Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 16 Feb 2021 18:54:19 +0300 Subject: [PATCH] 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. --- src/llmq/quorums_chainlocks.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/llmq/quorums_chainlocks.cpp b/src/llmq/quorums_chainlocks.cpp index 8072d5c05b..2ed877015f 100644 --- a/src/llmq/quorums_chainlocks.cpp +++ b/src/llmq/quorums_chainlocks.cpp @@ -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