cosmetics and comments

This commit is contained in:
Florian Dold 2020-04-02 20:44:12 +05:30
parent 05e43bb259
commit 95e638f513
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
7 changed files with 35 additions and 24 deletions

View File

@ -404,7 +404,10 @@ export async function getHistory(
type: ReserveType.Manual, type: ReserveType.Manual,
}; };
} }
const s = summarizeReserveHistory(reserve.reserveTransactions, reserve.currency); const s = summarizeReserveHistory(
reserve.reserveTransactions,
reserve.currency,
);
history.push({ history.push({
type: HistoryEventType.ReserveBalanceUpdated, type: HistoryEventType.ReserveBalanceUpdated,
eventId: makeEventId( eventId: makeEventId(

View File

@ -492,7 +492,10 @@ async function updateReserve(
reserveInfo.history, reserveInfo.history,
); );
console.log("reconciled history:", JSON.stringify(reconciled, undefined, 2)); console.log(
"reconciled history:",
JSON.stringify(reconciled, undefined, 2),
);
const summary = summarizeReserveHistory( const summary = summarizeReserveHistory(
reconciled.updatedLocalHistory, reconciled.updatedLocalHistory,

View File

@ -247,7 +247,6 @@ async function processTipImpl(
const planchets: PlanchetRecord[] = []; const planchets: PlanchetRecord[] = [];
for (let i = 0; i < tipRecord.planchets.length; i++) { for (let i = 0; i < tipRecord.planchets.length; i++) {
const tipPlanchet = tipRecord.planchets[i]; const tipPlanchet = tipRecord.planchets[i];
const coinEvHash = await ws.cryptoApi.hashEncoded(tipPlanchet.coinEv); const coinEvHash = await ws.cryptoApi.hashEncoded(tipPlanchet.coinEv);

View File

@ -52,7 +52,10 @@ import {
timestampCmp, timestampCmp,
timestampSubtractDuraction, timestampSubtractDuraction,
} from "../util/time"; } from "../util/time";
import { summarizeReserveHistory, ReserveHistorySummary } from "../util/reserveHistoryUtil"; import {
summarizeReserveHistory,
ReserveHistorySummary,
} from "../util/reserveHistoryUtil";
const logger = new Logger("withdraw.ts"); const logger = new Logger("withdraw.ts");
@ -372,22 +375,19 @@ async function incrementWithdrawalRetry(
withdrawalGroupId: string, withdrawalGroupId: string,
err: OperationError | undefined, err: OperationError | undefined,
): Promise<void> { ): Promise<void> {
await ws.db.runWithWriteTransaction( await ws.db.runWithWriteTransaction([Stores.withdrawalGroups], async (tx) => {
[Stores.withdrawalGroups], const wsr = await tx.get(Stores.withdrawalGroups, withdrawalGroupId);
async (tx) => { if (!wsr) {
const wsr = await tx.get(Stores.withdrawalGroups, withdrawalGroupId); return;
if (!wsr) { }
return; if (!wsr.retryInfo) {
} return;
if (!wsr.retryInfo) { }
return; wsr.retryInfo.retryCounter++;
} updateRetryInfoTimeout(wsr.retryInfo);
wsr.retryInfo.retryCounter++; wsr.lastError = err;
updateRetryInfoTimeout(wsr.retryInfo); await tx.put(Stores.withdrawalGroups, wsr);
wsr.lastError = err; });
await tx.put(Stores.withdrawalGroups, wsr);
},
);
ws.notify({ type: NotificationType.WithdrawOperationError }); ws.notify({ type: NotificationType.WithdrawOperationError });
} }

View File

@ -28,7 +28,6 @@ import {
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { timestampCmp } from "./time"; import { timestampCmp } from "./time";
import { deepCopy } from "./helpers"; import { deepCopy } from "./helpers";
import { AmountString } from "../types/talerTypes";
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
/** /**
@ -143,6 +142,9 @@ export function isLocalRemoteHistoryMatch(
return false; return false;
} }
/**
* Compute totals for the wallet's view of the reserve history.
*/
export function summarizeReserveHistory( export function summarizeReserveHistory(
localHistory: WalletReserveHistoryItem[], localHistory: WalletReserveHistoryItem[],
currency: string, currency: string,
@ -231,6 +233,10 @@ export function summarizeReserveHistory(
}; };
} }
/**
* Reconcile the wallet's local model of the reserve history
* with the reserve history of the exchange.
*/
export function reconcileReserveHistory( export function reconcileReserveHistory(
localHistory: WalletReserveHistoryItem[], localHistory: WalletReserveHistoryItem[],
remoteHistory: ReserveTransaction[], remoteHistory: ReserveTransaction[],