From be8e487a4d16f27f840aa9c6e108a869abd391d0 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Mon, 15 May 2023 12:51:37 +0100 Subject: [PATCH] Filter out TransferDomain TXs --- src/miner.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index bef46e32b2..52dc18cd1c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -506,21 +506,30 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector &fa std::vector txsToErase; for (const auto &txStr : failedTransactions) { - txsToErase.push_back(uint256S(txStr)); + const auto failedHash = uint256S(txStr); + for (const auto &tx : pblock->vtx) { + if (tx->GetHash() == failedHash) { + std::vector metadata; + const auto txType = GuessCustomTxType(*tx, metadata, false); + if (txType == CustomTxType::TransferDomain) { + txsToErase.push_back(failedHash); + } + } + } } // Get a copy of the TXs to be erased for restoring to the mempool later - std::vector txsToRestore; + std::vector txsToRemove; std::set txsToEraseSet(txsToErase.begin(), txsToErase.end()); for (const auto &tx : pblock->vtx) { if (tx && txsToEraseSet.count(tx->GetHash())) { - txsToRestore.push_back(tx); + txsToRemove.push_back(tx); } } // Add descendants and in turn add their descendants. This needs to - // be done in the order that the TXs are in the block for txsToRestore. + // be done in the order that the TXs are in the block for txsToRemove. auto size = txsToErase.size(); for (std::vector::size_type i{}; i < size; ++i) { for (const auto &tx : pblock->vtx) { @@ -529,7 +538,7 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector &fa if (vin.prevout.hash == txsToErase[i] && std::find(txsToErase.begin(), txsToErase.end(), tx->GetHash()) == txsToErase.end()) { - txsToRestore.push_back(tx); + txsToRemove.push_back(tx); txsToErase.push_back(tx->GetHash()); ++size; } @@ -546,11 +555,7 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector &fa return tx && txsToEraseSet.count(tx.get()->GetHash()); }),pblock->vtx.end()); - for (const auto &tx : txsToRestore) { - // Broadcast TXs, this will restore them to the mempool without actually relaying them. - std::string error; - std::ignore = BroadcastTransaction(tx, error, {COIN / 10}, false, false); - + for (const auto &tx : txsToRemove) { // Remove fees. if (txFees.count(tx->GetHash())) { nFees -= txFees.at(tx->GetHash());