config

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateFile is the full file name of the file that persists the validator's
	// last state.
	StateFile = "signctrl_state.json"

	// PermStateFile determines the default file permissions for the
	// signctrl_state.json file.
	PermStateFile = os.FileMode(0644)
)
View Source
const (
	// PermConfigDir determines the default file permissions for the configuration
	// directory.
	PermConfigDir = os.FileMode(0744)

	// PermConfigToml determines the default file permissions for the configuration
	// file.
	PermConfigToml = os.FileMode(0644)
)
View Source
const (
	// File is the full file name of the configuration file.
	File = "config.toml"
)

Variables

This section is empty.

Functions

func Create

func Create(cfgDir string, sections ...Section) error

Create writes configuration templates to the configuration file at the specified configuration directory. The base and privval sections are created by default.

func Dir

func Dir() string

Dir returns the configuration directory in use. It is always set in the following order:

1) Custom environment variable $SIGNCTRL_CONFIG_DIR 2) $HOME/.signctrl 3) Current working directory

If one is not set, the directory falls back to the next one.

func FilePath

func FilePath(cfgDir string) string

FilePath returns the absolute path to the configuration file.

func GetRetryDialTime

func GetRetryDialTime(timeString string) time.Duration

GetRetryDialTime converts the string representation of RetryDialAfter into time.Duration and returns it.

func StateFilePath

func StateFilePath(cfgDir string) string

StateFilePath returns the absolute path to the signctrl_state.json file.

Types

type Base

type Base struct {
	// LogLevel determines the minimum log level for SignCTRL logs.
	// Can be DEBUG, INFO, WARN or ERR.
	LogLevel string `mapstructure:"log_level"`

	// SetSize determines the number of validators in the SignCTRL set.
	SetSize int `mapstructure:"set_size"`

	// Threshold determines the threshold value of missed blocks in a row that
	// triggers a rank update in the SignCTRL set.
	Threshold int `mapstructure:"threshold"`

	// StartRank determines the validator's rank on startup and therefore whether it
	// has permission to sign votes/proposals or not.
	StartRank int `mapstructure:"start_rank"`

	// ValidatorListenAddress is the TCP socket address the validator listens on for
	// an external PrivValidator process. SignCTRL dials this address to establish a
	// connection with the validator.
	ValidatorListenAddress string `mapstructure:"validator_laddr"`

	// ValidatorListenAddressRPC is the TCP socket address the validator's RPC server
	// listens on.
	ValidatorListenAddressRPC string `mapstructure:"validator_laddr_rpc"`

	// RetryDialAfter is the time after which SignCTRL assumes it lost connection to
	// the validator and retries dialing it.
	RetryDialAfter string `mapstructure:"retry_dial_after"`
}

Base defines the base configuration parameters for SignCTRL.

type Config

type Config struct {
	// Base defines the [base] section of the configuration file.
	Base Base `mapstructure:"base"`

	// Privval defines the [privval] section of the configuration file.
	Privval PrivValidator `mapstructure:"privval"`
}

Config defines the structure of SignCTRL's configuration file.

func Load

func Load() (c Config, err error)

Load loads and validates the configuration file.

type PrivValidator

type PrivValidator struct {
	// ChainID is the chain that the validator validates for.
	ChainID string `mapstructure:"chain_id"`
}

PrivValidator defines the types of private validators that sign incoming sign requests.

type Section

type Section uint8

Section is a custom type for specific sections in the configuration file.

const (
	// BaseSection defines the [base] section of the configuration file.
	BaseSection Section = iota

	// PrivvalSection defines the [privval] section of the configuration file.
	PrivvalSection
)

type State

type State struct {
	LastHeight int64 `json:"last_height"`
	LastRank   int   `json:"last_rank"`
}

State defines the contents of the signctrl_state.json file.

func LoadOrGenState

func LoadOrGenState(cfgDir string) (State, error)

LoadOrGenState loads the contents of the signctrl_state.json file and returns them if it exists, or generetas a new one.

func (*State) Save

func (s *State) Save(cfgDir string) error

Save saves the current state to the signctrl_state.json file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL