-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstore.go
68 lines (56 loc) · 2.86 KB
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package payment
import (
"context"
"github.com/code-payments/code-server/pkg/database/query"
"github.com/pkg/errors"
)
var (
ErrNotFound = errors.New("no records could be found")
ErrExists = errors.New("the transaction index for this signature already exists")
)
type Store interface {
// Get finds the record for a given id
//
// ErrNotFound is returned if the record cannot be found
Get(ctx context.Context, txId string, index uint32) (*Record, error)
// GetAllForTransaction returns payment records in the store for a
// given transaction signature.
//
// ErrNotFound is returned if no rows are found.
GetAllForTransaction(ctx context.Context, txId string) ([]*Record, error)
// GetAllForAccount returns payment records in the store for a
// given "account" after a provided "cursor" value and limited to at most
// "limit" results.
//
// ErrNotFound is returned if no rows are found.
GetAllForAccount(ctx context.Context, account string, cursor uint64, limit uint, ordering query.Ordering) ([]*Record, error)
// GetAllForAccountByType returns payment records in the store for a
// given "account" after a provided "cursor" value and limited to at most
// "limit" results.
//
// ErrNotFound is returned if no rows are found.
GetAllForAccountByType(ctx context.Context, account string, cursor uint64, limit uint, ordering query.Ordering, paymentType PaymentType) ([]*Record, error)
// GetAllForAccountByTypeAfterBlock returns payment records in the store for a
// given "account" after a "block" after a provided "cursor" value and limited
// to at most "limit" results.
//
// ErrNotFound is returned if no rows are found.
GetAllForAccountByTypeAfterBlock(ctx context.Context, account string, block uint64, cursor uint64, limit uint, ordering query.Ordering, paymentType PaymentType) ([]*Record, error)
// GetAllForAccountByTypeWithinBlockRange returns payment records in the store
// for a given "account" within a "block" range (lowerBound, upperBOund) after a
// provided "cursor" value and limited to at most "limit" results.
//
// ErrNotFound is returned if no rows are found.
GetAllForAccountByTypeWithinBlockRange(ctx context.Context, account string, lowerBound, upperBound uint64, cursor uint64, limit uint, ordering query.Ordering, paymentType PaymentType) ([]*Record, error)
// GetExternalDepositAmount gets the total amount of Kin in quarks deposited to
// an account via a deposit from an external account.
GetExternalDepositAmount(ctx context.Context, account string) (uint64, error)
// Put saves payment metadata to the store.
//
// ErrTransactionIndexExists is returned if a transaction with the same signature already exists.
Put(ctx context.Context, record *Record) error
// Update an existing record on the backend store/database
//
// ErrNotFound is returned if the record cannot be found
Update(ctx context.Context, record *Record) error
}