-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstore.go
49 lines (36 loc) · 1.92 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
package commitment
import (
"context"
"errors"
"github.com/code-payments/code-server/pkg/database/query"
)
var (
ErrCommitmentNotFound = errors.New("commitment not found")
ErrInvalidCommitment = errors.New("commitment record is invalid")
)
type Store interface {
// Save saves a commitment account's state
Save(ctx context.Context, record *Record) error
// GetByAddress gets a commitment account's state by its address
GetByAddress(ctx context.Context, address string) (*Record, error)
// GetByVault gets a commitment account's state by the vault address
GetByVault(ctx context.Context, vault string) (*Record, error)
// GetByAction gets a commitment account's state by the action it's involved in
GetByAction(ctx context.Context, intentId string, actionId uint32) (*Record, error)
// GetAllByState gets all commitment accounts in the provided state
GetAllByState(ctx context.Context, state State, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)
// GetUpgradeableByOwner gets commitment records that are upgradeable and owned
// by a provided owner account.
GetUpgradeableByOwner(ctx context.Context, owner string, limit uint64) ([]*Record, error)
// GetUsedTreasuryPoolDeficit gets the used deficit, in Kin quarks, to a treasury
// pool given the associated commitments
GetUsedTreasuryPoolDeficit(ctx context.Context, pool string) (uint64, error)
// GetTotalTreasuryPoolDeficit gets the total deficit, in Kin quarks, to a treasury
// pool given the associated commitments
GetTotalTreasuryPoolDeficit(ctx context.Context, pool string) (uint64, error)
// CountByState counts the number of commitment records in a given state
CountByState(ctx context.Context, state State) (uint64, error)
// CountRepaymentsDivertedToVault counts the number of commitments whose repayments
// are diverted to the provided vault.
CountRepaymentsDivertedToVault(ctx context.Context, vault string) (uint64, error)
}