This repository has been archived by the owner on May 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 346
/
config.go
66 lines (56 loc) · 2.26 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package config
import (
"fmt"
"github.com/alecthomas/jsonschema"
"github.com/hyperledger/burrow/config/source"
"github.com/hyperledger/burrow/consensus/tendermint"
"github.com/hyperledger/burrow/crypto"
"github.com/hyperledger/burrow/execution"
"github.com/hyperledger/burrow/genesis"
"github.com/hyperledger/burrow/keys"
"github.com/hyperledger/burrow/logging/logconfig"
"github.com/hyperledger/burrow/rpc"
tmConfig "github.com/tendermint/tendermint/config"
)
const DefaultBurrowConfigTOMLFileName = "burrow.toml"
const DefaultBurrowConfigEnvironmentVariable = "BURROW_CONFIG_JSON"
const DefaultGenesisDocJSONFileName = "genesis.json"
type BurrowConfig struct {
// Set on startup
ValidatorAddress *crypto.Address `json:",omitempty" toml:",omitempty"`
Passphrase *string `json:",omitempty" toml:",omitempty"`
// From config file
BurrowDir string
GenesisDoc *genesis.GenesisDoc `json:",omitempty" toml:",omitempty"`
Tendermint *tendermint.BurrowTendermintConfig `json:",omitempty" toml:",omitempty"`
Execution *execution.ExecutionConfig `json:",omitempty" toml:",omitempty"`
Keys *keys.KeysConfig `json:",omitempty" toml:",omitempty"`
RPC *rpc.RPCConfig `json:",omitempty" toml:",omitempty"`
Logging *logconfig.LoggingConfig `json:",omitempty" toml:",omitempty"`
}
var burrowConfigSchema = jsonschema.Reflect(&BurrowConfig{})
func DefaultBurrowConfig() *BurrowConfig {
return &BurrowConfig{
BurrowDir: ".burrow",
Tendermint: tendermint.DefaultBurrowTendermintConfig(),
Keys: keys.DefaultKeysConfig(),
RPC: rpc.DefaultRPCConfig(),
Execution: execution.DefaultExecutionConfig(),
Logging: logconfig.DefaultNodeLoggingConfig(),
}
}
func (conf *BurrowConfig) Verify() error {
if conf.ValidatorAddress == nil {
return fmt.Errorf("could not finalise address - please provide one in config or via --account-address")
}
return nil
}
func (conf *BurrowConfig) TendermintConfig() (*tmConfig.Config, error) {
return conf.Tendermint.Config(conf.BurrowDir, conf.Execution.TimeoutFactor)
}
func (conf *BurrowConfig) JSONString() string {
return source.JSONString(conf)
}
func (conf *BurrowConfig) TOMLString() string {
return source.TOMLString(conf)
}