forked from stellar-deprecated/kelp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
43 lines (36 loc) · 1.21 KB
/
config.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
package terminator
import (
"fmt"
"github.com/stellar/kelp/support/utils"
)
// Config represents the configuration params for the bot
type Config struct {
SourceSecretSeed string `valid:"-" toml:"SOURCE_SECRET_SEED"`
TradingSecretSeed string `valid:"-" toml:"TRADING_SECRET_SEED"`
AllowInactiveMinutes int32 `valid:"-" toml:"ALLOW_INACTIVE_MINUTES"` // bots that are inactive for more than this time will have its offers deleted
TickIntervalSeconds int32 `valid:"-" toml:"TICK_INTERVAL_SECONDS"`
HorizonURL string `valid:"-" toml:"HORIZON_URL"`
TradingAccount *string
SourceAccount *string // can be nil
}
// String impl.
func (c Config) String() string {
return utils.StructString(c, 0, map[string]func(interface{}) interface{}{
"SOURCE_SECRET_SEED": utils.SecretKey2PublicKey,
"TRADING_SECRET_SEED": utils.SecretKey2PublicKey,
})
}
// Init initializes this config
func (c *Config) Init() error {
var e error
c.TradingAccount, e = utils.ParseSecret(c.TradingSecretSeed)
if e != nil {
return e
}
// trading account should never be nil
if c.TradingAccount == nil {
return fmt.Errorf("no trading account specified")
}
c.SourceAccount, e = utils.ParseSecret(c.SourceSecretSeed)
return e
}