Post
Topic
Board Announcements (Altcoins)
Re: NXT :: descendant of Bitcoin - Updated Information
by
Jean-Luc
on 05/02/2014, 10:46:24 UTC
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 fee
2. A transaction with earlier timestamp
3. A transaction that is received later
Currently transactions are sorted based on the Transaction.compareTo() method which is:

Code:
   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.