Yes, override Transaction.Type.isDuplicate() to check for such duplicate transactions, trying to cancel the same order, similar to the way it is already done for alias assignment transactions.
Let's decide what a criterion to use for choosing a duplicate. We remove:
1. A transaction with
lower fee2. A transaction with
earlier timestamp3. A transaction that is
received laterCurrently transactions are sorted based on the Transaction.compareTo() method which is:
public int compareTo(Transaction o) {
if (height < o.height) {
return -1;
} else if (height > o.height) {
return 1;
} else {
// equivalent to: fee * 1048576L / getSize() > o.fee * 1048576L / o.getSize()
if (fee * o.getSize() > o.fee * getSize()) {
return -1;
} else if (fee * o.getSize() < o.fee * getSize()) {
return 1;
} else {
if (timestamp < o.timestamp) {
return -1;
} else if (timestamp > o.timestamp) {
return 1;
} else {
if (index < o.index) {
return -1;
} else if (index > o.index) {
return 1;
} else {
return 0;
}
}
}
}
}
and the first transaction in that sort order wins in case of duplicates. I don't want to complicate it and have the logic different for different types of transactions, let's keep it same for all.