3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 07:12:17 +00:00

Use the new Transaction.SORT_TX_BY_UPDATE_TIME comparator and refresh comments.

This commit is contained in:
Andreas Schildbach 2014-09-05 19:05:15 +02:00
parent 2b80e4cfd1
commit 302bb3e21d
2 changed files with 6 additions and 8 deletions

View File

@ -53,7 +53,10 @@ import static com.google.common.base.Preconditions.checkState;
* are building a wallet, how to present confidence to your users is something to consider carefully.</p>
*/
public class Transaction extends ChildMessage implements Serializable {
/** A comparator that can be used to sort transactions by their updateTime field. */
/**
* A comparator that can be used to sort transactions by their updateTime field. The ordering goes from most recent
* into the past.
*/
public static final Comparator<Transaction> SORT_TX_BY_UPDATE_TIME = new Comparator<Transaction>() {
@Override
public int compare(final Transaction tx1, final Transaction tx2) {

View File

@ -2294,13 +2294,8 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
numTransactions = size;
}
ArrayList<Transaction> all = new ArrayList<Transaction>(getTransactions(includeDead));
// Order by date.
Collections.sort(all, Collections.reverseOrder(new Comparator<Transaction>() {
@Override
public int compare(Transaction t1, Transaction t2) {
return t1.getUpdateTime().compareTo(t2.getUpdateTime());
}
}));
// Order by update time.
Collections.sort(all, Transaction.SORT_TX_BY_UPDATE_TIME);
if (numTransactions == all.size()) {
return all;
} else {