Skip to content

Commit c0faae0

Browse files
committed
fix: reuse best clsig to avoid potential race condition
1 parent 98dc874 commit c0faae0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/node/miner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_hand
173173

174174
// Inserting our best CL
175175
bestCLHeightDiff = pindexPrev->nHeight - best_clsig.getHeight();
176-
bestCLSignature = chainlock_handler.GetBestChainLock().getSig();
176+
bestCLSignature = best_clsig.getSig();
177177

178178
return true;
179179
}

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,9 @@ static RPCHelpMan getassetunlockstatuses()
667667
}
668668
else {
669669
const auto pBlockIndexBestCL = [&]() -> const CBlockIndex* {
670-
if (!llmq_ctx.clhandler->GetBestChainLock().IsNull()) {
671-
return pTipBlockIndex->GetAncestor(llmq_ctx.clhandler->GetBestChainLock().getHeight());
670+
const auto best_clsig = llmq_ctx.clhandler->GetBestChainLock();
671+
if (!best_clsig.IsNull()) {
672+
return pTipBlockIndex->GetAncestor(best_clsig.getHeight());
672673
}
673674
// If no CL info is available, try to use CbTx CL information
674675
if (const auto cbtx_best_cl = GetNonNullCoinbaseChainlock(pTipBlockIndex)) {

0 commit comments

Comments
 (0)