summaryrefslogtreecommitdiff
path: root/c2ec/db.go
diff options
context:
space:
mode:
Diffstat (limited to 'c2ec/db.go')
-rw-r--r--c2ec/db.go52
1 files changed, 28 insertions, 24 deletions
diff --git a/c2ec/db.go b/c2ec/db.go
index 6607415..b48d88f 100644
--- a/c2ec/db.go
+++ b/c2ec/db.go
@@ -39,6 +39,9 @@ const TRANSFER_FIELD_NAME_AMOUNT = "amount"
const TRANSFER_FIELD_NAME_EXCHANGE_BASE_URL = "exchange_base_url"
const TRANSFER_FIELD_NAME_WTID = "wtid"
const TRANSFER_FIELD_NAME_CREDIT_ACCOUNT = "credit_account"
+const TRANSFER_FIELD_NAME_TS = "transfer_ts"
+const TRANSFER_FIELD_NAME_STATUS = "transfer_status"
+const TRANSFER_FIELD_NAME_RETRIES = "retries"
type Provider struct {
ProviderId int64 `db:"provider_id"`
@@ -79,12 +82,14 @@ type TalerAmountCurrency struct {
type Transfer struct {
RowId int `db:"row_id"`
- RequestUid HashCode `db:"request_uid"`
+ RequestUid []byte `db:"request_uid"`
Amount *TalerAmountCurrency `db:"amount"`
ExchangeBaseUrl string `db:"exchange_base_url"`
Wtid string `db:"wtid"`
CreditAccount string `db:"credit_account"`
- TransactionTs int64 `db:"transaction_ts"`
+ TransferTs int64 `db:"transfer_ts"`
+ Status int16 `db:"transfer_status"`
+ Retries int16 `db:"retries"`
}
type Notification struct {
@@ -169,17 +174,26 @@ type C2ECDatabase interface {
GetTerminalById(id int) (*Terminal, error)
// Returns the transfer for the given hashcode.
- GetTransferById(requestUid HashCode) (*Transfer, error)
+ GetTransferById(requestUid []byte) (*Transfer, error)
// Inserts a new transfer into the database.
AddTransfer(
- requestUid HashCode,
+ requestUid []byte,
amount *Amount,
exchangeBaseUrl string,
wtid string,
credit_account string,
) error
+ // Updates the transfer, if retries is changed, the transfer will be
+ // triggered again.
+ UpdateTransfer(
+ requestUid []byte,
+ timestamp int64,
+ status int16,
+ retries int16,
+ ) error
+
// The wire gateway allows the exchange to retrieve transactions
// starting at a certain starting point up until a certain delta
// if the delta is negative, previous transactions relative to the
@@ -187,24 +201,14 @@ type C2ECDatabase interface {
// id shall be used as starting point.
GetTransfers(start int, delta int) ([]*Transfer, error)
- // This will listen for notifications on the
- // channel withdrawal notifications are sent.
- // Results will be written to the out channel.
- // Errors will be propagated through the errs
- // channel. Supply a context with timeout if
- // you want to use time limitations.
- ListenForWithdrawalStatusChange(
- ctx context.Context,
- wopid WithdrawalIdentifier,
- out chan WithdrawalOperationStatus,
- errs chan error,
- )
-
- // A listener can listen for the specified channel.
- // It will send received notifications through the channel
- // supplied. The specific implementation must convert the
- // database specific message to the generic Notification
- // type in order to decouple the database implementation
- // from the rest of the logic.
- Listen(ctx context.Context, channel string) (chan *Notification, chan error, error)
+ // A listener can listen for notifications ont the specified
+ // channel. Returns a listen function, which must be called
+ // by the caller to start listening on the channel. The returned
+ // listen function will return an error if it fails, and takes
+ // a context as argument which allows the underneath implementation
+ // to control the execution context of the listener.
+ NewListener(
+ channel string,
+ out chan *Notification,
+ ) (func(context.Context) error, error)
}