Skip to content

Commit c5930ba

Browse files
authored
private: Support latest Constellation configuration format, and maintain backward compatibility (#127)
1 parent 852ac74 commit c5930ba

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

private/constellation/config.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ import (
55
)
66

77
type Config struct {
8-
Url string `toml:"url"`
9-
Port int `toml:"port"`
8+
Socket string `toml:"socket"`
9+
PublicKeys []string `toml:"publickeys"`
10+
11+
// Deprecated
1012
SocketPath string `toml:"socketPath"`
11-
OtherNodeUrls []string `toml:"otherNodeUrls"`
1213
PublicKeyPath string `toml:"publicKeyPath"`
13-
PrivateKeyPath string `toml:"privateKeyPath"`
14-
StoragePath string `toml:"storagePath"`
1514
}
1615

1716
func LoadConfig(configPath string) (*Config, error) {
1817
cfg := new(Config)
1918
if _, err := toml.DecodeFile(configPath, cfg); err != nil {
2019
return nil, err
2120
}
21+
// Fall back to Constellation 0.0.1 config format if necessary
22+
if cfg.Socket == "" {
23+
cfg.Socket = cfg.SocketPath
24+
}
25+
if len(cfg.PublicKeys) == 0 {
26+
cfg.PublicKeys = append(cfg.PublicKeys, cfg.PublicKeyPath)
27+
}
2228
return cfg, nil
2329
}

private/constellation/constellation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ func New(configPath string) (*Constellation, error) {
5656
if err != nil {
5757
return nil, err
5858
}
59-
err = RunNode(configPath, cfg.SocketPath)
59+
err = RunNode(configPath, cfg.Socket)
6060
if err != nil {
6161
return nil, err
6262
}
63-
n, err := NewClient(cfg.PublicKeyPath, cfg.SocketPath)
63+
n, err := NewClient(cfg.PublicKeys[0], cfg.Socket)
6464
if err != nil {
6565
return nil, err
6666
}

0 commit comments

Comments
 (0)