tx ordering

This commit is contained in:
Florian Dold 2020-05-15 23:52:58 +05:30
parent cf3aaee28a
commit ff50526560
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -18,7 +18,12 @@
* Imports.
*/
import { InternalWalletState } from "./state";
import { Stores, ReserveRecordStatus, PurchaseRecord, WithdrawalSourceType } from "../types/dbTypes";
import {
Stores,
ReserveRecordStatus,
PurchaseRecord,
WithdrawalSourceType,
} from "../types/dbTypes";
import { Amounts, AmountJson } from "../util/amounts";
import { timestampCmp } from "../util/time";
import {
@ -299,7 +304,11 @@ export async function getTransactions(
},
);
transactions.sort((h1, h2) => timestampCmp(h1.timestamp, h2.timestamp));
const txPending = transactions.filter((x) => x.pending);
const txNotPending = transactions.filter((x) => !x.pending);
return { transactions };
txPending.sort((h1, h2) => timestampCmp(h1.timestamp, h2.timestamp));
txNotPending.sort((h1, h2) => timestampCmp(h1.timestamp, h2.timestamp));
return { transactions: [...txPending, ...txNotPending] };
}