forked from hyperledger-archives/burrow
/
config.go
54 lines (47 loc) · 1.95 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
package config
import (
"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"`
ValidatorPassphrase *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"`
}
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) TendermintConfig() *tmConfig.Config {
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)
}