[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: fix logic bug in recoup (refr
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: fix logic bug in recoup (refresh variant) |
Date: |
Thu, 26 Mar 2020 18:04:20 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 5d1b0df8 fix logic bug in recoup (refresh variant)
5d1b0df8 is described below
commit 5d1b0df8a44c79cac46d40ff157f0150a668d6f4
Author: Florian Dold <address@hidden>
AuthorDate: Thu Mar 26 22:34:14 2020 +0530
fix logic bug in recoup (refresh variant)
---
src/operations/recoup.ts | 18 +++++++++++++-----
src/operations/refresh.ts | 1 -
src/types/dbTypes.ts | 2 ++
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/operations/recoup.ts b/src/operations/recoup.ts
index 107b9044..de2e6c9a 100644
--- a/src/operations/recoup.ts
+++ b/src/operations/recoup.ts
@@ -238,19 +238,24 @@ async function recoupRefreshCoin(
return;
}
const oldCoin = await tx.get(Stores.coins, cs.oldCoinPub);
- const updatedCoin = await tx.get(Stores.coins, coin.coinPub);
- if (!updatedCoin) {
+ const revokedCoin = await tx.get(Stores.coins, coin.coinPub);
+ if (!revokedCoin) {
return;
}
if (!oldCoin) {
return;
}
- updatedCoin.status = CoinStatus.Dormant;
+ revokedCoin.status = CoinStatus.Dormant;
oldCoin.currentAmount = Amounts.add(
oldCoin.currentAmount,
- updatedCoin.currentAmount,
+ recoupGroup.oldAmountPerCoin[coinIdx],
).amount;
- await tx.put(Stores.coins, updatedCoin);
+ console.log(
+ "recoup: setting old coin amount to",
+ Amounts.toString(oldCoin.currentAmount),
+ );
+ await tx.put(Stores.coins, revokedCoin);
+ await tx.put(Stores.coins, oldCoin);
await putGroupAsFinished(tx, recoupGroup, coinIdx);
return await createRefreshGroup(
tx,
@@ -333,6 +338,8 @@ export async function createRecoupGroup(
timestampStarted: getTimestampNow(),
retryInfo: initRetryInfo(),
recoupFinishedPerCoin: coinPubs.map(() => false),
+ // Will be populated later
+ oldAmountPerCoin: [],
};
for (let coinIdx = 0; coinIdx < coinPubs.length; coinIdx++) {
@@ -346,6 +353,7 @@ export async function createRecoupGroup(
await putGroupAsFinished(tx, recoupGroup, coinIdx);
continue;
}
+ recoupGroup.oldAmountPerCoin[coinIdx] = coin.currentAmount;
coin.currentAmount = Amounts.getZero(coin.currentAmount.currency);
await tx.put(Stores.coins, coin);
}
diff --git a/src/operations/refresh.ts b/src/operations/refresh.ts
index c04b7927..f196fc5e 100644
--- a/src/operations/refresh.ts
+++ b/src/operations/refresh.ts
@@ -145,7 +145,6 @@ async function refreshCreateSession(
return;
}
rg.finishedPerCoin[coinIndex] = true;
- rg.finishedPerCoin[coinIndex] = true;
let allDone = true;
for (const f of rg.finishedPerCoin) {
if (!f) {
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index 5a5ac7c3..c8c4ed61 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -1397,6 +1397,8 @@ export interface RecoupGroupRecord {
*/
recoupFinishedPerCoin: boolean[];
+ oldAmountPerCoin: AmountJson[];
+
/**
* Retry info.
*/
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: fix logic bug in recoup (refresh variant),
gnunet <=