mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
refactor: Move HasChainLock()
calls out of loops
This commit is contained in:
parent
6370c7a9e5
commit
38a0b5ac04
@ -1124,13 +1124,14 @@ void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pb
|
||||
}
|
||||
|
||||
if (m_mn_sync.IsBlockchainSynced()) {
|
||||
const bool has_chainlock = clhandler.HasChainLock(pindex->nHeight, pindex->GetBlockHash());
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
if (tx->IsCoinBase() || tx->vin.empty()) {
|
||||
// coinbase and TXs with no inputs can't be locked
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsLocked(tx->GetHash()) && !clhandler.HasChainLock(pindex->nHeight, pindex->GetBlockHash())) {
|
||||
if (!IsLocked(tx->GetHash()) && !has_chainlock) {
|
||||
ProcessTx(*tx, true, Params().GetConsensus());
|
||||
// TX is not locked, so make sure it is tracked
|
||||
AddNonLockedTx(tx, pindex);
|
||||
|
@ -2186,11 +2186,12 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||
|
||||
if (m_isman->RejectConflictingBlocks()) {
|
||||
// Require other nodes to comply, send them some data in case they are missing it.
|
||||
const bool has_chainlock = m_clhandler->HasChainLock(pindex->nHeight, pindex->GetBlockHash());
|
||||
for (const auto& tx : block.vtx) {
|
||||
// skip txes that have no inputs
|
||||
if (tx->vin.empty()) continue;
|
||||
while (llmq::CInstantSendLockPtr conflictLock = m_isman->GetConflictingLock(*tx)) {
|
||||
if (m_clhandler->HasChainLock(pindex->nHeight, pindex->GetBlockHash())) {
|
||||
if (has_chainlock) {
|
||||
LogPrint(BCLog::ALL, "ConnectBlock(DASH): chain-locked transaction %s overrides islock %s\n",
|
||||
tx->GetHash().ToString(), ::SerializeHash(*conflictLock).ToString());
|
||||
m_isman->RemoveConflictingLock(::SerializeHash(*conflictLock), *conflictLock);
|
||||
|
Loading…
Reference in New Issue
Block a user