-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstore.go
38 lines (28 loc) · 1.43 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
package treasury
import (
"context"
"errors"
"github.com/code-payments/code-server/pkg/database/query"
)
var (
ErrTreasuryPoolNotFound = errors.New("no records could be found")
ErrTreasuryPoolBlockhashNotFound = errors.New("treasury pool blockhash not found")
ErrStaleTreasuryPoolState = errors.New("treasury pool state is stale")
ErrNegativeFunding = errors.New("treasury pool has negative funding")
)
type Store interface {
// Save saves a treasury pool account's state
Save(ctx context.Context, record *Record) error
// GetByName gets a treasury pool account by its name
GetByName(ctx context.Context, name string) (*Record, error)
// GetByAddress gets a treasury pool account by its address
GetByAddress(ctx context.Context, address string) (*Record, error)
// GetByVault gets a treasury pool account by its vault address
GetByVault(ctx context.Context, vault string) (*Record, error)
// GetAllByState gets all treasury pool accounts in the provided state
GetAllByState(ctx context.Context, state TreasuryPoolState, cursor query.Cursor, limit uint64, direction query.Ordering) ([]*Record, error)
// SaveFunding saves a funding history record for a treasury pool vault
SaveFunding(ctx context.Context, record *FundingHistoryRecord) error
// GetTotalAvailableFunds gets the total available funds for a treasury pool's vault
GetTotalAvailableFunds(ctx context.Context, vault string) (uint64, error)
}