config

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModeProd refers to production mode
	ModeProd = iota + 1
	// ModeDev refers to development mode
	ModeDev
	// ModeTest refers to test mode
	ModeTest
)
View Source
const (
	GenDataTypeAccount = "account"
	GenDataTypeRepo    = "repo"
)

Genesis data type

View Source
const DefaultNetVersion = uint64(1)

DefaultNetVersion is the default network version used when no network version is provided.

View Source
const MainNetVersion = uint64(1)

MainNetVersion is the main net version number

Variables

View Source
var (

	// AppName is the name of the application
	AppName = "kit"

	// DefaultDataDir is the path to the data directory
	DefaultDataDir = os.ExpandEnv("$HOME/." + AppName)

	// KeystoreDirName is the name of the directory where accounts are stored
	KeystoreDirName = "keystore"

	// AppEnvPrefix is used as the prefix for environment variables
	AppEnvPrefix = AppName

	// DefaultNodeAddress is the default Node listening address
	DefaultNodeAddress = ":9000"

	// DefaultTMRPCAddress is the default RPC listening address for the tendermint
	DefaultTMRPCAddress = "127.0.0.1:9001"

	// DefaultRemoteServerAddress is the default remote server listening address
	DefaultRemoteServerAddress = ":9002"

	// DefaultDHTAddress is the default DHT listening address
	DefaultDHTAddress = ":9003"

	// DefaultPassAgentPort is the port on which the passphrase cache agent listens on
	DefaultPassAgentPort = "9004"

	// NoColorFormatting indicates that stdout/stderr output should have no color
	NoColorFormatting = false

	// DefaultLightNodeTrustPeriod is the trusting period that headers can be
	// verified within. Should be significantly less than the unbonding period.
	// TODO: Determine actual value for production env
	DefaultLightNodeTrustPeriod = 168 * time.Hour
)
View Source
var DevChain = &ChainInfo{
	Name:        "dev",
	NetVersion:  "1000",
	GenesisTime: 1595700581,
	Validators:  []string{},
	Configurer: func(cfg *AppConfig, tmc *tmcfg.Config) {
		tmc.Consensus.CreateEmptyBlocksInterval = 5 * time.Second

	},
}

DevChain contains configurations for development

View Source
var MainChain = &ChainInfo{
	Name:        "main-dev",
	NetVersion:  "1",
	GenesisTime: 1595700581,
	Validators:  []string{},
	Configurer: func(cfg *AppConfig, tmc *tmcfg.Config) {
		tmc.Consensus.CreateEmptyBlocksInterval = 120 * time.Second
	},
}

MainChain contains configurations for mainnet

View Source
var TestnetChainV1 = &ChainInfo{
	Name:        "testnet-v1",
	NetVersion:  "2000",
	GenesisTime: 1595700581,
	Validators: []string{
		"47shQ9ihsZBf2nYL6tAYR8q8Twb47KTNjimowxaNFRyGPL93oZL",
		"48LZFEsZsRPda1q2kiNZKToiTaeSx63GJdq6DWq9m9C4mSvWhHD",
		"48pFW5Yd5BLm4EVUJW8g9oG1BkNQz4wp2saLB8XmkvMRwRAB2FH",
		"48GKXaSLgJ5ox2C1jDshFGtD6Y4Zhd1doxK6iTDp3KCSZjzdWKt",
	},
	ChainSeedPeers: []string{
		"a2f1e5786d3564c14faafffd6a050d2f81c655d9@s1.makeos.org:9000",
		"9cd75740de0c9d7b2a5d3921b78abbbb39b1bebe@s2.makeos.org:9000",
		"3ccd79a6f332f83b85f63290ca53187022aada0a@s3.makeos.org:9000",
		"d0165f00485e22ec0197e15a836ce66587515a84@s4.makeos.org:9000",
	},
	DHTSeedPeers: []string{
		"/dns4/s1.makeos.org/tcp/9003/p2p/12D3KooWAeorTJTi3uRDC3nSMa1V9CujJQg5XcN3UjSSV2HDceQU",
		"/dns4/s2.makeos.org/tcp/9003/p2p/12D3KooWEksv3Nvbv5dRwKRkLJjoLvsuC6hyokj5sERx8mWrxMoB",
		"/dns4/s3.makeos.org/tcp/9003/p2p/12D3KooWJzM4Hf5KWrXnAJjgJkro7zK2edtDu8ocYt8UgU7vsmFa",
		"/dns4/s4.makeos.org/tcp/9003/p2p/12D3KooWE7KybnAaoxuw6UiMpof2LT9hMky8k83tZgpdNCqRWx9P",
	},
	Configurer: func(cfg *AppConfig, tmc *tmcfg.Config) {
		tmc.Consensus.CreateEmptyBlocksInterval = 10 * time.Minute
	},
}

TestnetChainV1 contains configurations for testnet v1 chain

Functions

func Configure

func Configure(appCfg *AppConfig, tmcfg *config.Config, initializing bool)

Configure sets up the application command structure, tendermint and kit configuration. This is where all configuration and settings are prepared

func GetInterrupt

func GetInterrupt() *util.Interrupt

GetInterrupt returns the component interrupt channel

func GetNetVersion

func GetNetVersion() uint64

GetNetVersion returns the current network version

func GetRawGenesisData

func GetRawGenesisData(devMode bool) json.RawMessage

GetRawGenesisData returns the genesis data in raw JSON format. If devMode is true, the development genesis file is used.

func IsMainNet

func IsMainNet() bool

IsMainNet returns true if the current network is the mainnet

func IsMainNetVersion

func IsMainNetVersion(version uint64) bool

IsMainNetVersion checks whether a given version represents the mainnet version

func IsTendermintInitialized

func IsTendermintInitialized(tmcfg *config.Config) bool

IsTendermintInitialized checks if node is initialized

func SetVersion

func SetVersion(netVersion uint64)

SetVersion sets the protocol version. All protocol handlers will be prefixed with the version to create a

Types

type AppConfig

type AppConfig struct {

	// Node holds the node configurations
	Node *NodeConfig `json:"node" mapstructure:"node"`

	// Repo holds repo-related configuration
	Repo *RepoConfig `json:"repo" mapstructure:"repo"`

	// Net holds network configurations
	Net *NetConfig `json:"net" mapstructure:"net"`

	// RPC holds RPC configurations
	RPC *RPCConfig `json:"rpc" mapstructure:"rpc"`

	// DHT holds DHT configurations
	DHT *DHTConfig `json:"dht" mapstructure:"dht"`

	// Remote holds repository remote configurations
	Remote *RemoteConfig `json:"remote" mapstructure:"remote"`

	// Mempool holds mempool configurations
	Mempool *MempoolConfig `json:"mempool" mapstructure:"mempool"`

	// GenesisFileEntries includes the initial state objects
	GenesisFileEntries []*GenDataEntry `json:"gendata" mapstructure:"gendata"`

	// VersionInfo holds version information
	VersionInfo *VersionInfo `json:"-" mapstructure:"-"`
	// contains filtered or unexported fields
}

AppConfig represents the applications configuration

func EmptyAppConfig

func EmptyAppConfig() *AppConfig

EmptyAppConfig returns an empty Config Object

func GetConfig

func GetConfig() *AppConfig

GetConfig get the app config

func (*AppConfig) DataDir

func (c *AppConfig) DataDir() string

DataDir returns the application's data directory

func (*AppConfig) G

func (c *AppConfig) G() *Globals

G returns the global object

func (*AppConfig) GetAppDBDir

func (c *AppConfig) GetAppDBDir() string

GetAppDBDir returns the path where app's database files are stored.

func (*AppConfig) GetAppName

func (c *AppConfig) GetAppName() string

GetAppName returns the app's name

func (*AppConfig) GetConsoleHistoryPath

func (c *AppConfig) GetConsoleHistoryPath() string

GetConsoleHistoryPath returns the filepath where the console input history is stored

func (*AppConfig) GetDBRootDir

func (c *AppConfig) GetDBRootDir() string

GetDBRootDir returns the directory where all database files are stored

func (*AppConfig) GetDHTStoreDir

func (c *AppConfig) GetDHTStoreDir() string

GetDHTStoreDir returns the path where dht database files are stored

func (*AppConfig) GetExtensionDir

func (c *AppConfig) GetExtensionDir() string

GetExtensionDir returns the extension directory

func (*AppConfig) GetRepoPath added in v0.0.30

func (c *AppConfig) GetRepoPath(name string) string

GetRepoPath returns the full path of a repository

func (*AppConfig) GetRepoRoot

func (c *AppConfig) GetRepoRoot() string

GetRepoRoot returns the repo root directory

func (*AppConfig) GetStateTreeDBDir

func (c *AppConfig) GetStateTreeDBDir() string

GetStateTreeDBDir returns the path where state's database files are stored

func (*AppConfig) IsAttachMode

func (c *AppConfig) IsAttachMode() bool

IsAttachMode checks whether the node was started in attach mode

func (*AppConfig) IsDev

func (c *AppConfig) IsDev() bool

IsDev checks whether the current environment is 'development'

func (*AppConfig) IsLightNode

func (c *AppConfig) IsLightNode() bool

IsLightNode checks if the node is in light mode

func (*AppConfig) IsProd

func (c *AppConfig) IsProd() bool

IsProd checks whether the current environment is 'production'

func (*AppConfig) IsTest

func (c *AppConfig) IsTest() bool

IsTest checks whether the current environment is 'test'

func (*AppConfig) IsValidatorNode

func (c *AppConfig) IsValidatorNode() bool

IsValidatorNode checks if the node is in validator mode

func (*AppConfig) KeystoreDir

func (c *AppConfig) KeystoreDir() string

KeystoreDir returns the application's accounts directory

func (*AppConfig) LoadKeys

func (c *AppConfig) LoadKeys(nodeKeyFile, privValKeyFile, privValStateFile string) *p2p.NodeKey

LoadKeys gets the node key from the node key file and caches it for fast access

func (*AppConfig) NetDataDir

func (c *AppConfig) NetDataDir() string

NetDataDir returns the network's data directory

func (*AppConfig) SetDataDir

func (c *AppConfig) SetDataDir(d string)

SetDataDir sets the application's data directory

func (*AppConfig) SetNetDataDir

func (c *AppConfig) SetNetDataDir(d string)

SetNetDataDir sets the network's data directory

func (*AppConfig) SetRepoRoot

func (c *AppConfig) SetRepoRoot(dir string)

SetRepoRoot sets the repo root directory

type ChainInfo

type ChainInfo struct {
	NetVersion     string
	GenesisTime    uint64
	Validators     []string
	Name           string
	ChainSeedPeers []string
	DHTSeedPeers   []string
	Configurer     func(cfg *AppConfig, tmcfg *tmcfg.Config)
}

ChainInfo implements Info

func (*ChainInfo) Configure added in v0.0.29

func (ci *ChainInfo) Configure(cfg *AppConfig, tmcfg *tmcfg.Config)

Configure updates the given config objects

func (*ChainInfo) GetName

func (ci *ChainInfo) GetName() string

GetName returns the name of the name

func (*ChainInfo) GetVersion

func (ci *ChainInfo) GetVersion() string

GetVersion returns the chain's numeric version

type DHTConfig

type DHTConfig struct {
	On             bool   `json:"on" mapstructure:"on"`
	Address        string `json:"address" mapstructure:"address"`
	BootstrapPeers string `json:"addpeer" mapstructure:"addpeer"`
}

DHTConfig describes DHT config parameters

type GenDataEntry

type GenDataEntry struct {
	Type    string `json:"type" mapstructure:"type"`
	Balance string `json:"balance" mapstructure:"balance"`

	// Type: Account
	Address string `json:"address" mapstructure:"address"`

	// Type: Repo
	Name   string                 `json:"name" mapstructure:"name"`
	Helm   bool                   `json:"helm" mapstructure:"helm"`
	Owners map[string]*RepoOwner  `json:"owners" mapstructure:"owners"`
	Config map[string]interface{} `json:"config" mapstructure:"config"`
}

GenDataEntry describes a genesis file data entry

func RawStateToGenesisData

func RawStateToGenesisData(state json.RawMessage) (entries []*GenDataEntry)

RawStateToGenesisData returns the genesis data

type Globals

type Globals struct {
	Log      logger.Logger
	Bus      *emitter.Emitter
	NodeKey  *p2p.NodeKey
	TMConfig *tmcfg.Config
	PrivVal  *ed25519.FilePV
}

Globals holds references to global objects

type Info

type Info interface {
	GetVersion() string
	GetName() string
	Configure(cfg *AppConfig, tmc *tmcfg.Config)
}

Info describes a chain version

func Get

func Get(version string) Info

Get finds a chain's info by version

type MempoolConfig

type MempoolConfig struct {
	Size       int   `json:"size" mapstructure:"size"`
	CacheSize  int   `json:"cacheSize" mapstructure:"cacheSize"`
	MaxTxSize  int   `json:"maxTxSize" mapstructure:"maxTxSize"`
	MaxTxsSize int64 `json:"maxTxsSize" mapstructure:"maxTxsSize"`
}

MempoolConfig describes mempool config parameters

type NetConfig

type NetConfig struct {
	Version uint64 `json:"version" mapstructure:"version"`
}

NetConfig describes network configurations

type NodeConfig

type NodeConfig struct {

	// Mode determines the current environment type
	Mode int `json:"mode" mapstructure:"mode"`

	// ListeningAddr is the node's listening address
	ListeningAddr string `json:"address" mapstructure:"address"`

	// PersistentPeers is a comma separated list of persistent peers to connect to.
	PersistentPeers string `json:"addpeer" mapstructure:"addpeer"`

	// GitBinPath is the path to the git executable
	GitBinPath string `json:"gitpath" mapstructure:"gitpath"`

	// Extensions contains list of extensions to run on startup
	Extensions []string `json:"exts" mapstructure:"exts"`

	// ExtensionsArgs contains arguments for extensions
	ExtensionsArgs map[string]string `json:"extsargs" mapstructure:"extsargs"`

	// Validator indicates whether to run the node in validator mode
	Validator bool `json:"validator" mapstructure:"validator"`

	// IgnoreSeeds will prevent seed address from being used
	IgnoreSeeds bool `json:"ignoreSeeds" mapstructure:"ignoreSeeds"`

	// Light indicates whether to run the node in light mode
	Light bool `json:"light" mapstructure:"light"`

	// LightNodePrimaryAddr is the light node's primary node address
	LightNodePrimaryAddr string `json:"primary" mapstructure:"primary"`

	// LightNodeWitnessAddrs is a list of witness addresses to pass to the light node
	LightNodeWitnessAddrs []string `json:"witaddress" mapstructure:"witaddress"`

	// LightMaxOpenConnections is the maximum number of open connections to the light node RPC proxy service
	LightMaxOpenConnections int `json:"maxopenconns" mapstructure:"maxopenconns"`

	// LightNodeTrustingPeriod is the time within which headers can be verified.
	// Should be significantly less than the unbonding period.
	LightNodeTrustingPeriod string `json:"period" mapstructure:"period"`

	// LightNodeTrustedHeaderHeight is the light node trusted header height
	LightNodeTrustedHeaderHeight int64 `json:"height" mapstructure:"height"`

	// LightNodeTrustedHeaderHash is the light node trusted header hash
	LightNodeTrustedHeaderHash string `json:"hash" mapstructure:"hash"`

	// LightNodeTrustLevel is the trust level to attain before a header is accepted.
	// Must be between 1/3 and 3/3.
	LightNodeTrustLevel string `json:"trustlevel" mapstructure:"trustlevel"`

	// LightNodeSequentialVerification allows the node to verify all headers sequentially
	// instead of skipping verification.
	LightNodeSequentialVerification bool `json:"sequential" mapstructure:"sequential"`
}

NodeConfig represents node's configuration

type RPCConfig

type RPCConfig struct {
	On            bool   `json:"on" mapstructure:"on"`
	User          string `json:"user" mapstructure:"user"`
	Password      string `json:"password" mapstructure:"password"`
	DisableAuth   bool   `json:"disableauth" mapstructure:"disableauth"`
	AuthPubMethod bool   `json:"authpubmethod" mapstructure:"authpubmethod"`
	HTTPS         bool   `json:"https" mapstructure:"https"`
	TMRPCAddress  string `json:"tmaddress" mapstructure:"tmaddress"`
}

RPCConfig describes RPC config settings

type RemoteConfig

type RemoteConfig struct {
	Address string `json:"address" mapstructure:"address"`
	Name    string `json:"name" mapstructure:"name"`
}

RemoteConfig describes repository manager config parameters

type RepoConfig

type RepoConfig struct {

	// Track contains names of repositories to be tracked
	Track []string `json:"track" mapstructure:"track"`

	// Untrack contains the names of repositories to be untracked
	Untrack []string `json:"untrack" mapstructure:"untrack"`

	// UntrackAll indicates that all currently tracked repositories are to be untracked
	UntrackAll bool `json:"untrackall" mapstructure:"untrackall"`
}

RepoConfig represents repo-related configuration

type RepoOwner

type RepoOwner struct {
	Creator  bool   `json:"creator" mapstructure:"creator" msgpack:"creator"`
	JoinedAt uint64 `json:"joinedAt" mapstructure:"joinedAt" msgpack:"joinedAt"`
	Veto     bool   `json:"veto" mapstructure:"veto" msgpack:"veto"`
}

RepoOwner describes an owner of a repository

type VersionInfo

type VersionInfo struct {
	BuildVersion string `json:"buildVersion" mapstructure:"buildVersion"`
	BuildCommit  string `json:"buildCommit" mapstructure:"buildCommit"`
	BuildDate    string `json:"buildDate" mapstructure:"buildDate"`
	GoVersion    string `json:"goVersion" mapstructure:"goVersion"`
}

VersionInfo describes the clients components and runtime version information

Jump to

Keyboard shortcuts

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