pending fixes
This commit is contained in:
parent
4159367d8c
commit
e01f94e345
@ -139,25 +139,17 @@ async function gatherReservePending(
|
|||||||
if (!reserve.retryInfo.active) {
|
if (!reserve.retryInfo.active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resp.nextRetryDelay = updateRetryDelay(
|
|
||||||
resp.nextRetryDelay,
|
|
||||||
now,
|
|
||||||
reserve.retryInfo.nextRetry,
|
|
||||||
);
|
|
||||||
if (onlyDue && reserve.retryInfo.nextRetry.t_ms > now.t_ms) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (reserve.reserveStatus) {
|
switch (reserve.reserveStatus) {
|
||||||
case ReserveRecordStatus.DORMANT:
|
case ReserveRecordStatus.DORMANT:
|
||||||
// nothing to report as pending
|
// nothing to report as pending
|
||||||
break;
|
break;
|
||||||
case ReserveRecordStatus.WITHDRAWING:
|
|
||||||
case ReserveRecordStatus.UNCONFIRMED:
|
case ReserveRecordStatus.UNCONFIRMED:
|
||||||
case ReserveRecordStatus.QUERYING_STATUS:
|
if (onlyDue) {
|
||||||
case ReserveRecordStatus.REGISTERING_BANK:
|
break;
|
||||||
|
}
|
||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: "reserve",
|
type: "reserve",
|
||||||
givesLifeness: true,
|
givesLifeness: false,
|
||||||
stage: reserve.reserveStatus,
|
stage: reserve.reserveStatus,
|
||||||
timestampCreated: reserve.created,
|
timestampCreated: reserve.created,
|
||||||
reserveType,
|
reserveType,
|
||||||
@ -166,6 +158,31 @@ async function gatherReservePending(
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
|
case ReserveRecordStatus.WAIT_CONFIRM_BANK:
|
||||||
|
if (onlyDue) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resp.pendingOperations.push({
|
||||||
|
type: "reserve",
|
||||||
|
givesLifeness: false,
|
||||||
|
stage: reserve.reserveStatus,
|
||||||
|
timestampCreated: reserve.created,
|
||||||
|
reserveType,
|
||||||
|
reservePub: reserve.reservePub,
|
||||||
|
bankWithdrawConfirmUrl: reserve.bankWithdrawConfirmUrl,
|
||||||
|
retryInfo: reserve.retryInfo,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case ReserveRecordStatus.WITHDRAWING:
|
||||||
|
case ReserveRecordStatus.QUERYING_STATUS:
|
||||||
|
case ReserveRecordStatus.REGISTERING_BANK:
|
||||||
|
resp.nextRetryDelay = updateRetryDelay(
|
||||||
|
resp.nextRetryDelay,
|
||||||
|
now,
|
||||||
|
reserve.retryInfo.nextRetry,
|
||||||
|
);
|
||||||
|
if (onlyDue && reserve.retryInfo.nextRetry.t_ms > now.t_ms) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: "reserve",
|
type: "reserve",
|
||||||
givesLifeness: true,
|
givesLifeness: true,
|
||||||
@ -173,7 +190,6 @@ async function gatherReservePending(
|
|||||||
timestampCreated: reserve.created,
|
timestampCreated: reserve.created,
|
||||||
reserveType,
|
reserveType,
|
||||||
reservePub: reserve.reservePub,
|
reservePub: reserve.reservePub,
|
||||||
bankWithdrawConfirmUrl: reserve.bankWithdrawConfirmUrl,
|
|
||||||
retryInfo: reserve.retryInfo,
|
retryInfo: reserve.retryInfo,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -265,7 +281,10 @@ async function gatherWithdrawalPending(
|
|||||||
if (onlyDue && wsr.retryInfo.nextRetry.t_ms > now.t_ms) {
|
if (onlyDue && wsr.retryInfo.nextRetry.t_ms > now.t_ms) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const numCoinsWithdrawn = wsr.withdrawn.reduce((a, x) => a + (x ? 1 : 0), 0);
|
const numCoinsWithdrawn = wsr.withdrawn.reduce(
|
||||||
|
(a, x) => a + (x ? 1 : 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
const numCoinsTotal = wsr.withdrawn.length;
|
const numCoinsTotal = wsr.withdrawn.length;
|
||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: "withdraw",
|
type: "withdraw",
|
||||||
@ -352,7 +371,7 @@ async function gatherPurchasePending(
|
|||||||
resp: PendingOperationsResponse,
|
resp: PendingOperationsResponse,
|
||||||
onlyDue: boolean = false,
|
onlyDue: boolean = false,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await tx.iter(Stores.purchases).forEach((pr) => {
|
await tx.iter(Stores.purchases).forEach(pr => {
|
||||||
if (!pr.firstSuccessfulPayTimestamp) {
|
if (!pr.firstSuccessfulPayTimestamp) {
|
||||||
resp.nextRetryDelay = updateRetryDelay(
|
resp.nextRetryDelay = updateRetryDelay(
|
||||||
resp.nextRetryDelay,
|
resp.nextRetryDelay,
|
||||||
|
@ -174,6 +174,8 @@ export async function createReserve(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ws.notify({ type: NotificationType.ReserveCreated });
|
||||||
|
|
||||||
// Asynchronously process the reserve, but return
|
// Asynchronously process the reserve, but return
|
||||||
// to the caller already.
|
// to the caller already.
|
||||||
processReserve(ws, resp.reservePub, true).catch(e => {
|
processReserve(ws, resp.reservePub, true).catch(e => {
|
||||||
@ -244,6 +246,7 @@ async function registerReserveWithBank(
|
|||||||
r.retryInfo = initRetryInfo();
|
r.retryInfo = initRetryInfo();
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
|
ws.notify( { type: NotificationType.Wildcard });
|
||||||
return processReserveBankStatus(ws, reservePub);
|
return processReserveBankStatus(ws, reservePub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +287,8 @@ async function processReserveBankStatusImpl(
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws.notify( { type: NotificationType.Wildcard });
|
||||||
|
|
||||||
if (status.selection_done) {
|
if (status.selection_done) {
|
||||||
if (reserve.reserveStatus === ReserveRecordStatus.REGISTERING_BANK) {
|
if (reserve.reserveStatus === ReserveRecordStatus.REGISTERING_BANK) {
|
||||||
await registerReserveWithBank(ws, reservePub);
|
await registerReserveWithBank(ws, reservePub);
|
||||||
@ -322,6 +327,7 @@ async function processReserveBankStatusImpl(
|
|||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ws.notify( { type: NotificationType.Wildcard });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function incrementReserveRetry(
|
async function incrementReserveRetry(
|
||||||
|
@ -519,6 +519,7 @@ export const enum NotificationType {
|
|||||||
ReserveUpdated = "reserve-updated",
|
ReserveUpdated = "reserve-updated",
|
||||||
ReserveConfirmed = "reserve-confirmed",
|
ReserveConfirmed = "reserve-confirmed",
|
||||||
ReserveDepleted = "reserve-depleted",
|
ReserveDepleted = "reserve-depleted",
|
||||||
|
ReserveCreated = "reserve-created",
|
||||||
WithdrawSessionCreated = "withdraw-session-created",
|
WithdrawSessionCreated = "withdraw-session-created",
|
||||||
WithdrawSessionFinished = "withdraw-session-finished",
|
WithdrawSessionFinished = "withdraw-session-finished",
|
||||||
WaitingForRetry = "waiting-for-retry",
|
WaitingForRetry = "waiting-for-retry",
|
||||||
@ -534,6 +535,7 @@ export const enum NotificationType {
|
|||||||
PayOperationError = "pay-error",
|
PayOperationError = "pay-error",
|
||||||
WithdrawOperationError = "withdraw-error",
|
WithdrawOperationError = "withdraw-error",
|
||||||
ReserveOperationError = "reserve-error",
|
ReserveOperationError = "reserve-error",
|
||||||
|
Wildcard = "wildcard",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProposalAcceptedNotification {
|
export interface ProposalAcceptedNotification {
|
||||||
@ -656,6 +658,14 @@ export interface ReserveOperationErrorNotification {
|
|||||||
type: NotificationType.ReserveOperationError;
|
type: NotificationType.ReserveOperationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ReserveCreatedNotification {
|
||||||
|
type: NotificationType.ReserveCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WildcardNotification {
|
||||||
|
type: NotificationType.Wildcard;
|
||||||
|
}
|
||||||
|
|
||||||
export type WalletNotification =
|
export type WalletNotification =
|
||||||
| WithdrawOperationErrorNotification
|
| WithdrawOperationErrorNotification
|
||||||
| ReserveOperationErrorNotification
|
| ReserveOperationErrorNotification
|
||||||
@ -676,6 +686,7 @@ export type WalletNotification =
|
|||||||
| RefreshStartedNotification
|
| RefreshStartedNotification
|
||||||
| RefreshRefusedNotification
|
| RefreshRefusedNotification
|
||||||
| ReserveUpdatedNotification
|
| ReserveUpdatedNotification
|
||||||
|
| ReserveCreatedNotification
|
||||||
| ReserveConfirmedNotification
|
| ReserveConfirmedNotification
|
||||||
| WithdrawSessionFinishedNotification
|
| WithdrawSessionFinishedNotification
|
||||||
| ReserveDepletedNotification
|
| ReserveDepletedNotification
|
||||||
@ -684,7 +695,8 @@ export type WalletNotification =
|
|||||||
| RefundFinishedNotification
|
| RefundFinishedNotification
|
||||||
| RefundQueriedNotification
|
| RefundQueriedNotification
|
||||||
| WithdrawSessionCreatedNotification
|
| WithdrawSessionCreatedNotification
|
||||||
| CoinWithdrawnNotification;
|
| CoinWithdrawnNotification
|
||||||
|
| WildcardNotification;
|
||||||
|
|
||||||
export interface OperationError {
|
export interface OperationError {
|
||||||
type: string;
|
type: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user