|
6 | 6 | #include <llmq/quorums.h> |
7 | 7 | #include <llmq/instantsend.h> |
8 | 8 | #include <llmq/signing_shares.h> |
| 9 | +#include <evo/cbtx.h> |
9 | 10 |
|
10 | 11 | #include <chain.h> |
11 | 12 | #include <chainparams.h> |
@@ -373,27 +374,36 @@ void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pbl |
373 | 374 | // We need this information later when we try to sign a new tip, so that we can determine if all included TXs are |
374 | 375 | // safe. |
375 | 376 |
|
376 | | - LOCK(cs); |
| 377 | + { |
| 378 | + LOCK(cs); |
377 | 379 |
|
378 | | - auto it = blockTxs.find(pindex->GetBlockHash()); |
379 | | - if (it == blockTxs.end()) { |
380 | | - // we must create this entry even if there are no lockable transactions in the block, so that TrySignChainTip |
381 | | - // later knows about this block |
382 | | - it = blockTxs.emplace(pindex->GetBlockHash(), std::make_shared<std::unordered_set<uint256, StaticSaltedHasher>>()).first; |
383 | | - } |
384 | | - auto& txids = *it->second; |
| 380 | + auto it = blockTxs.find(pindex->GetBlockHash()); |
| 381 | + if (it == blockTxs.end()) { |
| 382 | + // we must create this entry even if there are no lockable transactions in the block, so that TrySignChainTip later knows about this block |
| 383 | + it = blockTxs |
| 384 | + .emplace(pindex->GetBlockHash(), std::make_shared<std::unordered_set<uint256, StaticSaltedHasher>>()) |
| 385 | + .first; |
| 386 | + } |
| 387 | + auto& txids = *it->second; |
385 | 388 |
|
386 | | - int64_t curTime = GetTime<std::chrono::seconds>().count(); |
| 389 | + int64_t curTime = GetTime<std::chrono::seconds>().count(); |
387 | 390 |
|
388 | | - for (const auto& tx : pblock->vtx) { |
389 | | - if (tx->IsCoinBase() || tx->vin.empty()) { |
390 | | - continue; |
391 | | - } |
| 391 | + for (const auto& tx : pblock->vtx) { |
| 392 | + if (tx->IsCoinBase() || tx->vin.empty()) { |
| 393 | + continue; |
| 394 | + } |
392 | 395 |
|
393 | | - txids.emplace(tx->GetHash()); |
394 | | - txFirstSeenTime.emplace(tx->GetHash(), curTime); |
| 396 | + txids.emplace(tx->GetHash()); |
| 397 | + txFirstSeenTime.emplace(tx->GetHash(), curTime); |
| 398 | + } |
395 | 399 | } |
| 400 | + auto cbtx = GetCoinbaseTx(pindex); |
| 401 | + auto clsig_height = pindex->nHeight - cbtx->bestCLHeightDiff; |
396 | 402 |
|
| 403 | + if (clsig_height > uint32_t(WITH_LOCK(cs, return bestChainLock.getHeight()))) { |
| 404 | + auto clsig = CChainLockSig(clsig_height, pindex->GetAncestor(clsig_height)->GetBlockHash(), cbtx->bestCLSignature); |
| 405 | + ProcessNewChainLock(-1, clsig, ::SerializeHash(clsig)); |
| 406 | + } |
397 | 407 | } |
398 | 408 |
|
399 | 409 | void CChainLocksHandler::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, gsl::not_null<const CBlockIndex*> pindexDisconnected) |
|
0 commit comments