config

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKeyfile defines the default name of the file containing the
	// validator's private key
	DefaultKeyfile = "priv_key"

	// DefaultBadgerFile defines the default name of the folder containing the
	// Badger database
	DefaultBadgerFile = "badger_db"
)

Variables

This section is empty.

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir return the default directory name for top-level Babble config based on the underlying OS, attempting to respect conventions.

func DefaultDatabaseDir added in v0.5.8

func DefaultDatabaseDir() string

DefaultDatabaseDir returns the default path for the badger database files.

func HomeDir

func HomeDir() string

HomeDir returns the user's home directory.

func LogLevel

func LogLevel(l string) logrus.Level

LogLevel parses a string into a Logrus log level.

Types

type Config

type Config struct {
	// DataDir is the top-level directory containing Babble configuration and
	// data
	DataDir string `mapstructure:"datadir"`

	// LogLevel determines the chattiness of the log output.
	LogLevel string `mapstructure:"log"`

	// BindAddr is the local address:port where this node gossips with other
	// nodes. By default, this is "0.0.0.0", meaning Babble will bind to all
	// addresses on the local machine. However, in some cases, there may be a
	// routable address that cannot be bound. Use AdvertiseAddr to enable
	// gossiping a different address to support this. If this address is not
	// routable, the node will be in a constant flapping state as other nodes
	// will treat the non-routability as a failure
	BindAddr string `mapstructure:"listen"`

	// AdvertiseAddr is used to change the address that we advertise to other
	// nodes in the cluster
	AdvertiseAddr string `mapstructure:"advertise"`

	// NoService disables the HTTP API service.
	NoService bool `mapstructure:"no-service"`

	// ServiceAddr is the address:port that serves the user-facing API. If not
	// specified, and "no-service" is not set, the API handlers are registered
	// with the DefaultServerMux of the http package. It is possible that
	// another server in the same process is simultaneously using the
	// DefaultServerMux. In which case, the handlers will be accessible from
	// both servers. This is usefull when Babble is used in-memory and expecpted
	// to use the same endpoint (address:port) as the application's API.
	ServiceAddr string `mapstructure:"service-listen"`

	// HeartbeatTimeout is the frequency of the gossip timer when the node has
	// something to gossip about.
	HeartbeatTimeout time.Duration `mapstructure:"heartbeat"`

	// SlowHeartbeatTimeout is the frequency of the gossip timer when the node
	// has nothing to gossip about.
	SlowHeartbeatTimeout time.Duration `mapstructure:"slow-heartbeat"`

	// MaxPool controls how many connections are pooled per target in the gossip
	// routines.
	MaxPool int `mapstructure:"max-pool"`

	// TCPTimeout is the timeout of gossip TCP connections.
	TCPTimeout time.Duration `mapstructure:"timeout"`

	// JoinTimeout is the timeout of Join Requests
	JoinTimeout time.Duration `mapstructure:"join_timeout"`

	// SyncLimit defines the max number of hashgraph events to include in a
	// SyncResponse or EagerSyncRequest
	SyncLimit int `mapstructure:"sync-limit"`

	// EnableFastSync determines whether or not to enable the FastSync protocol.
	EnableFastSync bool `mapstructure:"fast-sync"`

	// Store is a flag that determines whether or not to use persistant storage.
	Store bool `mapstructure:"store"`

	// DatabaseDir is the directory containing database files.
	DatabaseDir string `mapstructure:"db"`

	// CacheSize is the max number of items in in-memory caches.
	CacheSize int `mapstructure:"cache-size"`

	// Bootstrap determines whether or not to load Babble from an existing
	// database file. Forces Store, ie. bootstrap only works with a persistant
	// database store.
	Bootstrap bool `mapstructure:"bootstrap"`

	// MaintenanceMode when set to true causes Babble to initialise in a
	// suspended state. I.e. it does not start gossipping. Forces Bootstrap,
	// which itself forces Store. I.e. MaintenanceMode only works if the node is
	// bootstrapped from an existing database.
	MaintenanceMode bool `mapstructure:"maintenance-mode"`

	// SuspendLimit is the number of Undetermined Events (Events which haven't
	// reached consensus) that will cause the node to become suspended
	SuspendLimit int `mapstructure:"suspend-limit"`

	// Moniker defines the friendly name of this node
	Moniker string `mapstructure:"moniker"`

	// LoadPeers determines whether or not to attempt loading the peer-set from
	// a local json file.
	LoadPeers bool `mapstructure:"loadpeers"`

	// Proxy is the application proxy that enables Babble to communicate with
	// application.
	Proxy proxy.AppProxy

	// Key is the private key of the validator.
	Key *ecdsa.PrivateKey
	// contains filtered or unexported fields
}

Config contains all the configuration properties of a Babble node.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns the a config object with default values.

func NewTestConfig

func NewTestConfig(t testing.TB, level logrus.Level) *Config

NewTestConfig returns a config object with default values and a special logger. the logger forces formatting and colors even when there is no tty attached, which makes for more readable logs. The logger also provides info about the calling function.

func (*Config) Keyfile

func (c *Config) Keyfile() string

Keyfile returns the full path of the file containing the private key.

func (*Config) Logger

func (c *Config) Logger() *logrus.Entry

Logger returns a formatted logrus Entry, with prefix set to "babble".

func (*Config) SetDataDir added in v0.5.8

func (c *Config) SetDataDir(dataDir string)

SetDataDir sets the top-level Babble directory, and updates the database directory if it is currently set to the default value. If the database directory is not currently the default, it means the user has explicitely set it to something else, so avoid changing it again here.

Jump to

Keyboard shortcuts

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