diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-15 16:59:00 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-15 16:59:00 +0100 |
commit | 4966376839365536923cd6cfbb86d15071432e1a (patch) | |
tree | 6658b4a84df5ba6a0189e6d79e37fb0cc7fb597a /src/types | |
parent | f4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00 (diff) | |
download | wallet-core-4966376839365536923cd6cfbb86d15071432e1a.tar.xz |
group refresh sessions into groups for nicer history
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/dbTypes.ts | 57 | ||||
-rw-r--r-- | src/types/history.ts | 14 | ||||
-rw-r--r-- | src/types/pending.ts | 87 | ||||
-rw-r--r-- | src/types/walletTypes.ts | 26 |
4 files changed, 107 insertions, 77 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts index 6a00a497d..c05aa68d7 100644 --- a/src/types/dbTypes.ts +++ b/src/types/dbTypes.ts @@ -41,6 +41,7 @@ import { OperationError, Duration, getTimestampNow, + RefreshReason, } from "./walletTypes"; export enum ReserveRecordStatus { @@ -572,10 +573,6 @@ export enum CoinStatus { */ Fresh = "fresh", /** - * Used for a completed transaction and now dirty. - */ - Dirty = "dirty", - /** * A coin that has been spent and refreshed. */ Dormant = "dormant", @@ -849,6 +846,39 @@ export interface TipRecord { retryInfo: RetryInfo; } +export interface RefreshGroupRecord { + /** + * Retry info, even present when the operation isn't active to allow indexing + * on the next retry timestamp. + */ + retryInfo: RetryInfo; + + lastError: OperationError | undefined; + + lastErrorPerCoin: (OperationError | undefined)[]; + + refreshGroupId: string; + + reason: RefreshReason; + + oldCoinPubs: string[]; + + refreshSessionPerCoin: (RefreshSessionRecord | undefined)[]; + + /** + * Flag for each coin whether refreshing finished. + * If a coin can't be refreshed (remaining value too small), + * it will be marked as finished, but no refresh session will + * be created. + */ + finishedPerCoin: boolean[]; + + /** + * Timestamp when the refresh session finished. + */ + finishedTimestamp: Timestamp | undefined; +} + /** * Ongoing refresh */ @@ -913,30 +943,19 @@ export interface RefreshSessionRecord { hash: string; /** - * Base URL for the exchange we're doing the refresh with. - */ - exchangeBaseUrl: string; - - /** * Timestamp when the refresh session finished. */ finishedTimestamp: Timestamp | undefined; /** - * A 32-byte base32-crockford encoded random identifier. - */ - refreshSessionId: string; - - /** * When has this refresh session been created? */ created: Timestamp; /** - * Retry info, even present when the operation isn't active to allow indexing - * on the next retry timestamp. + * Base URL for the exchange we're doing the refresh with. */ - retryInfo: RetryInfo; + exchangeBaseUrl: string; } /** @@ -1366,8 +1385,8 @@ export namespace Stores { export const denominations = new DenominationsStore(); export const exchanges = new ExchangesStore(); export const proposals = new ProposalsStore(); - export const refresh = new Store<RefreshSessionRecord>("refresh", { - keyPath: "refreshSessionId", + export const refreshGroups = new Store<RefreshGroupRecord>("refreshGroups", { + keyPath: "refreshGroupId", }); export const reserves = new ReservesStore(); export const purchases = new PurchasesStore(); diff --git a/src/types/history.ts b/src/types/history.ts index 06b863005..54004b122 100644 --- a/src/types/history.ts +++ b/src/types/history.ts @@ -1,4 +1,4 @@ -import { Timestamp } from "./walletTypes"; +import { Timestamp, RefreshReason } from "./walletTypes"; /* This file is part of GNU Taler @@ -604,18 +604,6 @@ export interface HistoryRefund { } /** - * Reasons for why a coin is being refreshed. - */ -export const enum RefreshReason { - Manual = "manual", - Pay = "pay", - Refund = "refund", - AbortPay = "abort-pay", - Recoup = "recoup", - BackupRestored = "backup-restored", -} - -/** * Event to indicate that a group of refresh sessions has completed. */ export interface HistoryRefreshedEvent { diff --git a/src/types/pending.ts b/src/types/pending.ts index 5e381d09a..d08d2c54e 100644 --- a/src/types/pending.ts +++ b/src/types/pending.ts @@ -24,27 +24,41 @@ import { OperationError, Timestamp, Duration } from "./walletTypes"; import { WithdrawalSource, RetryInfo } from "./dbTypes"; +export const enum PendingOperationType { + Bug = "bug", + ExchangeUpdate = "exchange-update", + Pay = "pay", + ProposalChoice = "proposal-choice", + ProposalDownload = "proposal-download", + Refresh = "refresh", + Reserve = "reserve", + RefundApply = "refund-apply", + RefundQuery = "refund-query", + TipChoice = "tip-choice", + TipPickup = "tip-pickup", + Withdraw = "withdraw", +} + /** * Information about a pending operation. */ export type PendingOperationInfo = PendingOperationInfoCommon & ( - | PendingWithdrawOperation - | PendingReserveOperation | PendingBugOperation - | PendingDirtyCoinOperation | PendingExchangeUpdateOperation - | PendingRefreshOperation - | PendingTipOperation - | PendingProposalDownloadOperation - | PendingProposalChoiceOperation | PendingPayOperation - | PendingRefundQueryOperation + | PendingProposalChoiceOperation + | PendingProposalDownloadOperation + | PendingRefreshOperation | PendingRefundApplyOperation + | PendingRefundQueryOperation + | PendingReserveOperation + | PendingTipPickupOperation + | PendingWithdrawOperation ); export interface PendingExchangeUpdateOperation { - type: "exchange-update"; + type: PendingOperationType.ExchangeUpdate; stage: string; reason: string; exchangeBaseUrl: string; @@ -52,13 +66,13 @@ export interface PendingExchangeUpdateOperation { } export interface PendingBugOperation { - type: "bug"; + type: PendingOperationType.Bug; message: string; details: any; } export interface PendingReserveOperation { - type: "reserve"; + type: PendingOperationType.Reserve; retryInfo: RetryInfo | undefined; stage: string; timestampCreated: Timestamp; @@ -68,21 +82,13 @@ export interface PendingReserveOperation { } export interface PendingRefreshOperation { - type: "refresh"; + type: PendingOperationType.Refresh; lastError?: OperationError; - refreshSessionId: string; - oldCoinPub: string; - refreshStatus: string; - refreshOutputSize: number; -} - -export interface PendingDirtyCoinOperation { - type: "dirty-coin"; - coinPub: string; + refreshGroupId: string; } export interface PendingProposalDownloadOperation { - type: "proposal-download"; + type: PendingOperationType.ProposalDownload; merchantBaseUrl: string; proposalTimestamp: Timestamp; proposalId: string; @@ -96,66 +102,57 @@ export interface PendingProposalDownloadOperation { * proposed contract terms. */ export interface PendingProposalChoiceOperation { - type: "proposal-choice"; + type: PendingOperationType.ProposalChoice; merchantBaseUrl: string; proposalTimestamp: Timestamp; proposalId: string; } -export interface PendingTipOperation { - type: "tip"; +export interface PendingTipPickupOperation { + type: PendingOperationType.TipPickup; tipId: string; merchantBaseUrl: string; merchantTipId: string; } export interface PendingPayOperation { - type: "pay"; + type: PendingOperationType.Pay; proposalId: string; isReplay: boolean; - retryInfo: RetryInfo, + retryInfo: RetryInfo; lastError: OperationError | undefined; } export interface PendingRefundQueryOperation { - type: "refund-query"; + type: PendingOperationType.RefundQuery; proposalId: string; - retryInfo: RetryInfo, + retryInfo: RetryInfo; lastError: OperationError | undefined; } export interface PendingRefundApplyOperation { - type: "refund-apply"; + type: PendingOperationType.RefundApply; proposalId: string; - retryInfo: RetryInfo, + retryInfo: RetryInfo; lastError: OperationError | undefined; numRefundsPending: number; numRefundsDone: number; } -export interface PendingOperationInfoCommon { - type: string; - givesLifeness: boolean; -} - - export interface PendingWithdrawOperation { - type: "withdraw"; + type: PendingOperationType.Withdraw; source: WithdrawalSource; withdrawSessionId: string; numCoinsWithdrawn: number; numCoinsTotal: number; } -export interface PendingRefreshOperation { - type: "refresh"; -} - -export interface PendingPayOperation { - type: "pay"; +export interface PendingOperationInfoCommon { + type: PendingOperationType; + givesLifeness: boolean; } export interface PendingOperationsResponse { pendingOperations: PendingOperationInfo[]; nextRetryDelay: Duration; -}
\ No newline at end of file +} diff --git a/src/types/walletTypes.ts b/src/types/walletTypes.ts index 903852b1b..eedae6f2c 100644 --- a/src/types/walletTypes.ts +++ b/src/types/walletTypes.ts @@ -506,3 +506,29 @@ export interface PlanchetCreationRequest { reservePub: string; reservePriv: string; } + +/** + * Reasons for why a coin is being refreshed. + */ +export const enum RefreshReason { + Manual = "manual", + Pay = "pay", + Refund = "refund", + AbortPay = "abort-pay", + Recoup = "recoup", + BackupRestored = "backup-restored", +} + +/** + * Wrapper for coin public keys. + */ +export interface CoinPublicKey { + readonly coinPub: string; +} + +/** + * Wrapper for refresh group IDs. + */ +export interface RefreshGroupId { + readonly refreshGroupId: string; +} |