forked from irinazheltisheva/powergate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
92 lines (76 loc) · 2.21 KB
/
Copy pathtypes.go
File metadata and controls
92 lines (76 loc) · 2.21 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package api
import (
"errors"
"github.com/ipfs/go-cid"
"github.com/textileio/powergate/ffs"
)
var (
// ErrNotFound returned when instance configuration doesn't exist.
ErrNotFound = errors.New("stored item not found")
)
// InstanceStore is a repository for all state of a Api.
type InstanceStore interface {
PutConfig(c Config) error
GetConfig() (Config, error)
GetCidConfig(cid.Cid) (ffs.CidConfig, error)
PutCidConfig(ffs.CidConfig) error
RemoveCidConfig(cid.Cid) error
GetCids() ([]cid.Cid, error)
}
// Config has general information about a Api instance.
type Config struct {
ID ffs.APIID
Addrs map[string]AddrInfo
DefaultConfig ffs.DefaultConfig
}
// AddrInfo provides information about a wallet address
type AddrInfo struct {
Name string
Addr string
Type string
}
// InstanceInfo has general information about a running Api instance.
type InstanceInfo struct {
ID ffs.APIID
DefaultConfig ffs.DefaultConfig
Balances []BalanceInfo
Pins []cid.Cid
}
// BalanceInfo contains the balance for the associated wallet address.
type BalanceInfo struct {
AddrInfo
Balance uint64
}
// NewAddressConfig contains options for creating a new wallet address
type NewAddressConfig struct {
makeDefault bool
addressType string
}
// NewAddressOption is a function that changes a NewAddressConfig
type NewAddressOption func(config *NewAddressConfig)
// WithMakeDefault specifies if the new address should become the default
func WithMakeDefault(makeDefault bool) NewAddressOption {
return func(c *NewAddressConfig) {
c.makeDefault = makeDefault
}
}
// WithAddressType specifies the type of address to create
func WithAddressType(addressType string) NewAddressOption {
return func(c *NewAddressConfig) {
c.addressType = addressType
}
}
// GetLogsConfig contains configuration for a stream-log
// of human-friendly messages for a Cid execution.
type GetLogsConfig struct {
jid ffs.JobID
}
// GetLogsOption is a function that changes GetLogsConfig.
type GetLogsOption func(config *GetLogsConfig)
// WithJidFilter filters only log messages of a Cid related to
// the Job with id jid.
func WithJidFilter(jid ffs.JobID) GetLogsOption {
return func(c *GetLogsConfig) {
c.jid = jid
}
}