Skip to content

Commit 7b4ee6b

Browse files
committed
trivial: document transaction confirmation safety threshold
1 parent 25f05c1 commit 7b4ee6b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/chainlock/chainlock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ void CChainLocksHandler::Cleanup()
476476
const auto* pindex = m_chainstate.m_blockman.LookupBlockIndex(hashBlock);
477477
assert(pindex); // GetTransaction gave us that hashBlock, it should resolve to a valid block index
478478
if (m_chainstate.m_chain.Tip()->GetAncestor(pindex->nHeight) == pindex &&
479-
m_chainstate.m_chain.Height() - pindex->nHeight >= 6) {
480-
// tx got confirmed >= 6 times, so we can stop keeping track of it
479+
m_chainstate.m_chain.Height() - pindex->nHeight > chainlock::TX_CONFIRM_THRESHOLD) {
480+
// tx is sufficiently deep, we can stop tracking it
481481
it = txFirstSeenTime.erase(it);
482482
} else {
483483
++it;

src/chainlock/signing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ void ChainLockSigner::TrySignChainTip(const llmq::CInstantSendManager& isman)
9595
if (isman.IsInstantSendEnabled() && isman.RejectConflictingBlocks()) {
9696
const auto* pindexWalk = pindex;
9797
while (pindexWalk != nullptr) {
98-
if (pindex->nHeight - pindexWalk->nHeight > 5) {
99-
// no need to check further down, 6 confs is safe to assume that TXs below this height won't be
98+
if (pindex->nHeight - pindexWalk->nHeight > TX_CONFIRM_THRESHOLD) {
99+
// no need to check further down, safe to assume that TXs below this height won't be
100100
// islocked anymore if they aren't already
101-
LogPrint(BCLog::CHAINLOCKS, "%s -- tip and previous 5 blocks all safe\n", __func__);
101+
LogPrint(BCLog::CHAINLOCKS, "%s -- tip and previous %d blocks all safe\n", __func__, TX_CONFIRM_THRESHOLD);
102102
break;
103103
}
104104
if (m_clhandler.HasChainLock(pindexWalk->nHeight, pindexWalk->GetBlockHash())) {

src/chainlock/signing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class CSigSharesManager;
2020
} // namespace llmq
2121

2222
namespace chainlock {
23+
//! Depth of block including transactions before it's considered safe
24+
static constexpr int32_t TX_CONFIRM_THRESHOLD{5};
25+
2326
class ChainLockSignerParent
2427
{
2528
public:

0 commit comments

Comments
 (0)