Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out TransferDomain TXs #1988

Merged
merged 1 commit into from
May 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,21 +506,30 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector<std::string> &fa

std::vector<uint256> 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<unsigned char> 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<CTransactionRef> txsToRestore;
std::vector<CTransactionRef> txsToRemove;
std::set<uint256> 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<uint256>::size_type i{}; i < size; ++i) {
for (const auto &tx : pblock->vtx) {
Expand All @@ -529,7 +538,7 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector<std::string> &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;
}
Expand All @@ -546,11 +555,7 @@ void BlockAssembler::RemoveFailedTransactions(const std::vector<std::string> &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());
Expand Down