[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/01: fix cost computation, formatting
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/01: fix cost computation, formatting |
Date: |
Tue, 12 May 2020 21:50:58 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to tag v0.7.1-dev.3
in repository wallet-core.
commit 6e17a6069282b87fa7e872de44505b9676bc3e78
Author: Florian Dold <address@hidden>
AuthorDate: Wed May 13 01:20:40 2020 +0530
fix cost computation, formatting
---
src/operations/withdraw.ts | 50 +++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 14 deletions(-)
diff --git a/src/operations/withdraw.ts b/src/operations/withdraw.ts
index 977d998f..21c30d7a 100644
--- a/src/operations/withdraw.ts
+++ b/src/operations/withdraw.ts
@@ -105,7 +105,10 @@ export function getWithdrawDenomList(
totalCoinValue,
Amounts.mult(d.value, count).amount,
).amount;
- totalWithdrawCost = Amounts.add(totalWithdrawCost, cost).amount;
+ totalWithdrawCost = Amounts.add(
+ totalWithdrawCost,
+ Amounts.mult(cost, count).amount,
+ ).amount;
selectedDenoms.push({
count,
denom: d,
@@ -195,7 +198,11 @@ async function processPlanchet(
if (!planchet) {
let ci = 0;
let denomPubHash: string | undefined;
- for (let di = 0; di < withdrawalGroup.denomsSel.selectedDenoms.length;
di++) {
+ for (
+ let di = 0;
+ di < withdrawalGroup.denomsSel.selectedDenoms.length;
+ di++
+ ) {
const d = withdrawalGroup.denomsSel.selectedDenoms[di];
if (coinIdx >= ci && coinIdx < ci + d.count) {
denomPubHash = d.denomPubHash;
@@ -206,14 +213,20 @@ async function processPlanchet(
if (!denomPubHash) {
throw Error("invariant violated");
}
- const denom = await
ws.db.getIndexed(Stores.denominations.denomPubHashIndex, denomPubHash);
+ const denom = await ws.db.getIndexed(
+ Stores.denominations.denomPubHashIndex,
+ denomPubHash,
+ );
if (!denom) {
throw Error("invariant violated");
}
if (withdrawalGroup.source.type != WithdrawalSourceType.Reserve) {
throw Error("invariant violated");
}
- const reserve = await ws.db.get(Stores.reserves,
withdrawalGroup.source.reservePub);
+ const reserve = await ws.db.get(
+ Stores.reserves,
+ withdrawalGroup.source.reservePub,
+ );
if (!reserve) {
throw Error("invariant violated");
}
@@ -279,7 +292,9 @@ async function processPlanchet(
return;
}
- logger.trace(`processing planchet #${coinIdx} in withdrawal
${withdrawalGroupId}`);
+ logger.trace(
+ `processing planchet #${coinIdx} in withdrawal ${withdrawalGroupId}`,
+ );
const wd: any = {};
wd.denom_pub_hash = planchet.denomPubHash;
@@ -362,14 +377,18 @@ async function processPlanchet(
let numDone = 0;
- await tx.iterIndexed(Stores.planchets.byGroup,
withdrawalGroupId).forEach((x) => {
- if (x.withdrawalDone) {
- numDone++;
- }
- });
+ await tx
+ .iterIndexed(Stores.planchets.byGroup, withdrawalGroupId)
+ .forEach((x) => {
+ if (x.withdrawalDone) {
+ numDone++;
+ }
+ });
if (numDone > numTotal) {
- throw Error("invariant violated (created more planchets than
expected)");
+ throw Error(
+ "invariant violated (created more planchets than expected)",
+ );
}
if (numDone == numTotal) {
@@ -513,7 +532,10 @@ async function resetWithdrawalGroupRetry(
});
}
-async function processInBatches(workGen: Iterator<Promise<void>>, batchSize:
number): Promise<void> {
+async function processInBatches(
+ workGen: Iterator<Promise<void>>,
+ batchSize: number,
+): Promise<void> {
for (;;) {
const batch: Promise<void>[] = [];
for (let i = 0; i < batchSize; i++) {
@@ -550,7 +572,7 @@ async function processWithdrawGroupImpl(
}
const numDenoms = withdrawalGroup.denomsSel.selectedDenoms.length;
- const genWork = function*(): Iterator<Promise<void>> {
+ const genWork = function* (): Iterator<Promise<void>> {
let coinIdx = 0;
for (let i = 0; i < numDenoms; i++) {
const count = withdrawalGroup.denomsSel.selectedDenoms[i].count;
@@ -559,7 +581,7 @@ async function processWithdrawGroupImpl(
coinIdx++;
}
}
- }
+ };
// Withdraw coins in batches.
// The batch size is relatively large
--
To stop receiving notification emails like this one, please contact
address@hidden.