configuration

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package configuration holds shared configuration structs for Monet, EVM-Lite and Babble.

Index

Constants

View Source
const (
	// config
	ConfigDir = "monetd-config"
	BabbleDir = "babble"
	EthDir    = "eth"
	POADir    = "poa"

	// data
	DatabaseDir = "monetd-data"

	// keystore
	KeyStoreDir = "keystore"
)

Directory Constants

View Source
const (
	MonetdTomlDirDot  = ".monet"
	MonetdTomlDirCaps = "Monet"
)

Monetd Configuration Directory

View Source
const (
	PeersJSON        = "peers.json"
	PeersGenesisJSON = "peers.genesis.json"
	GenesisJSON      = "genesis.json"
	MonetTomlFile    = "monetd.toml"
	EthDB            = "eth-db"
	BabbleDB         = "babble-db"
	WalletTomlFile   = "wallet.toml"
	ServerPIDFile    = "server.pid"
	BabblePrivKey    = "priv_key"
)

Filename constants

View Source
const (
	DefaultGossipPort = "1337"
	DefaultAPIAddr    = ":8080"
)

Network Constants

View Source
const (
	DefaultKeyfile        = "keyfile.json"
	DefaultPrivateKeyFile = "priv_key"
)

Keys constants

View Source
const (
	DefaultAccountBalance            = "1234567890000000000000"
	DefaultContractAddress           = "abbaabbaabbaabbaabbaabbaabbaabbaabbaabba"
	DefaultControllerContractAddress = "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabb"
	GenesisContract                  = "contract0.sol"
	GenesisABI                       = "contract0.abi"
	ControllerContract               = "contract1.sol"
	ControllerABI                    = "contract1.abi"
	CompileResultFile                = "compile.toml"
)

Genesis Constants

Variables

View Source
var (
	// Global is a global Config object used by commands in cmd/ to manipulate
	// configuration options.
	Global = DefaultConfig()
)

Functions

func DefaultConfigDir

func DefaultConfigDir() string

DefaultConfigDir returns the full path of the config directory where static configuration files are stored.

func DefaultDataDir added in v0.3.0

func DefaultDataDir() string

DefaultDataDir returns the full path of the data directory where databases are stored.

func DefaultKeystoreDir added in v0.3.0

func DefaultKeystoreDir() string

DefaultKeystoreDir returns the full path of the keystore where encrypted keyfiles are stored.

func DefaultMonetDir added in v0.3.0

func DefaultMonetDir() string

DefaultMonetDir returns a the full path for the default location Monet configuration files based on the underlying OS.

func DumpGlobalTOML added in v0.3.0

func DumpGlobalTOML(configDir, fileName string, interactive bool) error

DumpGlobalTOML takes the global Config object, encodes it into a TOML string, and writes it to a file.

func GlobalTOML

func GlobalTOML() (string, error)

GlobalTOML converts the global Config object into a TOML string

Types

type BabbleConfig

type BabbleConfig struct {

	// 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 and will advertise the private IPv4
	// address to the rest of the cluster. 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"`

	// Gossip heartbeat
	Heartbeat time.Duration `mapstructure:"heartbeat"`

	// TCP timeout
	TCPTimeout time.Duration `mapstructure:"timeout"`

	// Max number of items in caches
	CacheSize int `mapstructure:"cache-size"`

	// Max number of Event in SyncResponse
	SyncLimit int `mapstructure:"sync-limit"`

	// Max number of connections in net pool
	MaxPool int `mapstructure:"max-pool"`

	// Bootstrap from database
	Bootstrap bool `mapstructure:"bootstrap"`

	// MaintenanceMode when set to true causes Babble to initialise in a
	// suspended state. I.e. it does not start gossipping
	MaintenanceMode bool `mapstructure:"maintenance-mode"`

	// SuspendLimit is the number of undetermined-events produced since the last
	// run, that will cause the node to be automaitically suspended.
	SuspendLimit int `mapstructure:"suspend-limit"`

	// Moniker is a friendly name to indentify this peer
	Moniker string `mapstructure:"moniker"`
}

BabbleConfig contains the configuration for the Babble node used by monetd. It only presents a subset of the options Babble can accept, because monetd forces some configurations values. In particular, the --fast-sync and --store flags are disabled because monetd does not support the FastSync protocol, and it requires a persistant database.

func DefaultBabbleConfig

func DefaultBabbleConfig() *BabbleConfig

DefaultBabbleConfig returns the default configuration for a Babble node

type BaseConfig

type BaseConfig struct {
	// ConfigDir contains static configuration files
	ConfigDir string `mapstructure:"config"`

	// DataDir contains babble and eth databases
	DataDir string `mapstructure:"data"`

	// Verbose
	Verbose bool `mapstructure:"verbose"`

	// IP/PORT of API
	APIAddr string `mapstructure:"api-listen"`
	// contains filtered or unexported fields
}

BaseConfig contains the top level configuration for an EVM-Babble node

func DefaultBaseConfig

func DefaultBaseConfig() BaseConfig

DefaultBaseConfig returns the default top-level configuration for EVM-Babble

type Config

type Config struct {

	// Top level options use an anonymous struct
	BaseConfig `mapstructure:",squash"`

	// Options for evm-lite
	Eth *EthConfig `mapstructure:"eth"`

	// Options for Babble
	Babble *BabbleConfig `mapstructure:"babble"`
}

Config contains the configuration for MONET node

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for a MONET node

func (*Config) LogLevel

func (c *Config) LogLevel() string

LogLevel returns a logrus-style log-level based on the verbose option.

func (*Config) Logger

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

Logger returns a new prefixed logrus Entry with custom formatting

func (*Config) ToBabbleConfig

func (c *Config) ToBabbleConfig() *babble_config.Config

ToBabbleConfig extracts the babble configuration and returns a config object as used by the Babble library. It enforces the values of Store and EnableFastSync to true and false respectively.

func (*Config) ToEVMLConfig

func (c *Config) ToEVMLConfig() *evml_config.Config

ToEVMLConfig extracts evm-lite configuration and returns a config object as used by the evm-lite library.

type EthConfig

type EthConfig struct {
	// Megabytes of memory allocated to internal caching (min 16MB / database forced)
	Cache int `mapstructure:"cache"`

	// Minimum gasprice for transactions submitted via this node
	MinGasPrice string `mapstructure:"min-gas-price"`
}

EthConfig contains the configuration relative to the accounts, EVM, trie/db, and service API

func DefaultEthConfig

func DefaultEthConfig() *EthConfig

DefaultEthConfig return the default configuration for Eth services

Jump to

Keyboard shortcuts

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