summaryrefslogtreecommitdiff
path: root/src/operations/reserves.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-16 16:20:45 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-16 16:20:45 +0100
commit35a7b76a7d935dc2c749fd39ac80c6af1096b795 (patch)
treeb7f0bb167d3c912a085e7b842e887d5c834208fb /src/operations/reserves.ts
parentfa4621e70c48500a372504eb8ae9b9481531c555 (diff)
downloadwallet-core-35a7b76a7d935dc2c749fd39ac80c6af1096b795.tar.gz
wallet-core-35a7b76a7d935dc2c749fd39ac80c6af1096b795.tar.bz2
wallet-core-35a7b76a7d935dc2c749fd39ac80c6af1096b795.zip
history WIP, DB naming
Diffstat (limited to 'src/operations/reserves.ts')
-rw-r--r--src/operations/reserves.ts34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index 56e9c25d6..7b0a6886e 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -77,13 +77,13 @@ export async function createReserve(
const currency = req.amount.currency;
const reserveRecord: ReserveRecord = {
- created: now,
- withdrawAllocatedAmount: Amounts.getZero(currency),
- withdrawCompletedAmount: Amounts.getZero(currency),
- withdrawRemainingAmount: Amounts.getZero(currency),
+ timestampCreated: now,
+ amountWithdrawAllocated: Amounts.getZero(currency),
+ amountWithdrawCompleted: Amounts.getZero(currency),
+ amountWithdrawRemaining: Amounts.getZero(currency),
exchangeBaseUrl: canonExchange,
hasPayback: false,
- initiallyRequestedAmount: req.amount,
+ amountInitiallyRequested: req.amount,
reservePriv: keypair.priv,
reservePub: keypair.pub,
senderWire: req.senderWire,
@@ -414,20 +414,20 @@ async function updateReserve(
// FIXME: check / compare history!
if (!r.lastSuccessfulStatusQuery) {
// FIXME: check if this matches initial expectations
- r.withdrawRemainingAmount = balance;
+ r.amountWithdrawRemaining = balance;
const reserveUpdate: ReserveUpdatedEventRecord = {
reservePub: r.reservePub,
timestamp: getTimestampNow(),
amountReserveBalance: Amounts.toString(balance),
- amountExpected: Amounts.toString(reserve.initiallyRequestedAmount),
+ amountExpected: Amounts.toString(reserve.amountInitiallyRequested),
newHistoryTransactions,
reserveUpdateId,
};
await tx.put(Stores.reserveUpdatedEvents, reserveUpdate);
} else {
const expectedBalance = Amounts.sub(
- r.withdrawAllocatedAmount,
- r.withdrawCompletedAmount,
+ r.amountWithdrawAllocated,
+ r.amountWithdrawCompleted,
);
const cmp = Amounts.cmp(balance, expectedBalance.amount);
if (cmp == 0) {
@@ -436,8 +436,8 @@ async function updateReserve(
}
if (cmp > 0) {
const extra = Amounts.sub(balance, expectedBalance.amount).amount;
- r.withdrawRemainingAmount = Amounts.add(
- r.withdrawRemainingAmount,
+ r.amountWithdrawRemaining = Amounts.add(
+ r.amountWithdrawRemaining,
extra,
).amount;
} else {
@@ -549,7 +549,7 @@ async function depleteReserve(
}
logger.trace(`depleting reserve ${reservePub}`);
- const withdrawAmount = reserve.withdrawRemainingAmount;
+ const withdrawAmount = reserve.amountWithdrawRemaining;
logger.trace(`getting denom list`);
@@ -585,7 +585,7 @@ async function depleteReserve(
reservePub: reserve.reservePub,
},
rawWithdrawalAmount: withdrawAmount,
- startTimestamp: getTimestampNow(),
+ timestampStart: getTimestampNow(),
denoms: denomsForWithdraw.map(x => x.denomPub),
withdrawn: denomsForWithdraw.map(x => false),
planchets: denomsForWithdraw.map(x => undefined),
@@ -603,7 +603,7 @@ async function depleteReserve(
function mutateReserve(r: ReserveRecord): ReserveRecord {
const remaining = Amounts.sub(
- r.withdrawRemainingAmount,
+ r.amountWithdrawRemaining,
totalWithdrawAmount,
);
if (remaining.saturated) {
@@ -611,15 +611,15 @@ async function depleteReserve(
throw TransactionAbort;
}
const allocated = Amounts.add(
- r.withdrawAllocatedAmount,
+ r.amountWithdrawAllocated,
totalWithdrawAmount,
);
if (allocated.saturated) {
console.error("can't create planchets, saturated");
throw TransactionAbort;
}
- r.withdrawRemainingAmount = remaining.amount;
- r.withdrawAllocatedAmount = allocated.amount;
+ r.amountWithdrawRemaining = remaining.amount;
+ r.amountWithdrawAllocated = allocated.amount;
r.reserveStatus = ReserveRecordStatus.DORMANT;
r.retryInfo = initRetryInfo(false);
return r;