From 5d6192b0cd356f7e56fa8d6193a2e74233a52f4b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 11 May 2020 18:03:25 +0530 Subject: make planchet management during withdrawal O(n) instead of O(n^2) --- src/operations/history.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/operations/history.ts') diff --git a/src/operations/history.ts b/src/operations/history.ts index f32dbbe2d..669a6cf85 100644 --- a/src/operations/history.ts +++ b/src/operations/history.ts @@ -22,7 +22,6 @@ import { Stores, ProposalStatus, ProposalRecord, - PlanchetRecord, } from "../types/dbTypes"; import { Amounts } from "../util/amounts"; import { AmountJson } from "../util/amounts"; @@ -34,7 +33,6 @@ import { ReserveType, ReserveCreationDetail, VerbosePayCoinDetails, - VerboseWithdrawDetails, VerboseRefreshDetails, } from "../types/history"; import { assertUnreachable } from "../util/assertUnreachable"; @@ -177,6 +175,7 @@ export async function getHistory( Stores.tips, Stores.withdrawalGroups, Stores.payEvents, + Stores.planchets, Stores.refundEvents, Stores.reserveUpdatedEvents, Stores.recoupGroups, @@ -209,23 +208,6 @@ export async function getHistory( tx.iter(Stores.withdrawalGroups).forEach((wsr) => { if (wsr.timestampFinish) { - const cs: PlanchetRecord[] = []; - wsr.planchets.forEach((x) => { - if (x) { - cs.push(x); - } - }); - - let verboseDetails: VerboseWithdrawDetails | undefined = undefined; - if (historyQuery?.extraDebug) { - verboseDetails = { - coins: cs.map((x) => ({ - value: Amounts.stringify(x.coinValue), - denomPub: x.denomPub, - })), - }; - } - history.push({ type: HistoryEventType.Withdrawn, withdrawalGroupId: wsr.withdrawalGroupId, @@ -233,12 +215,12 @@ export async function getHistory( HistoryEventType.Withdrawn, wsr.withdrawalGroupId, ), - amountWithdrawnEffective: Amounts.stringify(wsr.totalCoinValue), + amountWithdrawnEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountWithdrawnRaw: Amounts.stringify(wsr.rawWithdrawalAmount), exchangeBaseUrl: wsr.exchangeBaseUrl, timestamp: wsr.timestampFinish, withdrawalSource: wsr.source, - verboseDetails, + verboseDetails: undefined, }); } }); -- cgit v1.2.3