repo

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectMode = "direct"
	RelayMode  = "relay"
	UnionMode  = "union"
)
View Source
const (
	// DefaultPathName is the default config dir name
	DefaultPathName = ".pier"

	// DefaultPathRoot is the path to the default config dir location.
	DefaultPathRoot = "~/" + DefaultPathName

	// EnvDir is the environment variable used to change the path root.
	EnvDir = "PIER_PATH"

	// ConfigName is config name
	ConfigName = "pier.toml"

	// config path
	ConfigPath = "../../config"

	// KeyName
	KeyName = "key.json"

	// NodeKeyName
	NodeKeyName = "node.priv"

	// KeyPassword
	KeyPassword = "bitxhub"

	// API name
	APIName = "api"

	// Bitxhub type
	BitxhubType = "bitxhub"
)

Variables

View Source
var RootPath string

Functions

func GetAPI

func GetAPI(repoRoot string) (string, error)

func InitConfig

func InitConfig(path string) error

InitConfig initialize configuration

func Initialize

func Initialize(repoRoot string) error

Initialize creates .pier path and necessary configuration, account file and so on.

func KeyPath

func KeyPath(repoRoot string) string

func LoadNodePrivateKey added in v1.4.0

func LoadNodePrivateKey(repoRoot string) (crypto.PrivateKey, error)

func LoadPrivateKey

func LoadPrivateKey(repoRoot string) (crypto.PrivateKey, error)

LoadPrivateKey loads private key from config path

func NodeKeyPath added in v1.4.0

func NodeKeyPath(repoRoot string) string

func PathRoot

func PathRoot() (string, error)

PathRoot returns root path (default .pier)

func PathRootWithDefault

func PathRootWithDefault(path string) (string, error)

PathRootWithDefault gets current config path with default value

func PluginPath

func PluginPath() (string, error)

PluginPath returns the plugin path

func SetPath

func SetPath(root string)

SetPath sets global config path

Types

type Appchain

type Appchain struct {
	Config string `toml:"config" json:"config"`
	Plugin string `toml:"plugin" json:"plugin"`
}

Appchain are configs about appchain

type Config

type Config struct {
	RepoRoot string
	Title    string   `toml:"title" json:"title"`
	Port     Port     `toml:"port" json:"port"`
	Mode     Mode     `toml:"mode" json:"mode"`
	Log      Log      `toml:"log" json:"log"`
	Appchain Appchain `toml:"appchain" json:"appchain"`
	Security Security `toml:"security" json:"security"`
	HA       HA       `toml:"ha" json:"ha"`
}

Config represents the necessary config data for starting pier

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns config with default value

func UnmarshalConfig

func UnmarshalConfig(repoRoot string) (*Config, error)

UnmarshalConfig read from config files under config path

type Direct

type Direct struct {
	Peers []string `toml:"peers" json:"peers"`
}

type HA added in v1.5.0

type HA struct {
	Mode string `toml:"mode" json:"mode"`
}

type Log

type Log struct {
	Dir          string    `toml:"dir" json:"dir"`
	Filename     string    `toml:"filename" json:"filename"`
	ReportCaller bool      `mapstructure:"report_caller"`
	Level        string    `toml:"level" json:"level"`
	Module       LogModule `toml:"module" json:"module"`
}

Log are config about log

type LogModule added in v1.5.0

type LogModule struct {
	ApiServer   string `mapstructure:"api_server" toml:"api_server" json:"api_server"`
	AppchainMgr string `mapstructure:"appchain_mgr" toml:"appchain_mgr" json:"appchain_mgr"`
	BxhLite     string `mapstructure:"bxh_lite" toml:"bxh_lite" json:"bxh_lite"`
	Exchanger   string `toml:"exchanger" json:"exchanger"`
	Executor    string `toml:"executor" json:"executor"`
	Monitor     string `toml:"monitor" json:"monitor"`
	PeerMgr     string `mapstructure:"peer_mgr" toml:"peer_mgr" json:"peer_mgr"`
	Router      string `toml:"router" json:"router"`
	RuleMgr     string `mapstructure:"rule_mgr" toml:"rule_mgr" json:"rule_mgr"`
	Swarm       string `toml:"swarm" json:"swarm"`
	Syncer      string `toml:"syncer" json:"syncer"`
}

type Mode

type Mode struct {
	Type   string `toml:"type" json:"type"`
	Relay  Relay  `toml:"relay" json:"relay"`
	Direct Direct `toml:"direct" json:"direct"`
	Union  Union  `toml:"union" json:"union"`
}

type Port

type Port struct {
	Http  int64 `toml:"http" json:"http"`
	PProf int64 `toml:"pprof" json:"pprof"`
}

Port are ports providing http and pprof service

type Relay

type Relay struct {
	Addrs        []string      `toml:"addrs" json:"addrs"`
	TimeoutLimit time.Duration `mapstructure:"timeout_limit" json:"timeout_limit"`
	Quorum       uint64        `toml:"quorum" json:"quorum"`
	Validators   []string      `toml:"validators" json:"validators"`
}

Relay are configs about bitxhub

func (*Relay) GetValidators

func (relay *Relay) GetValidators() []*types.Address

GetValidators gets validator address of bitxhub

type Security added in v1.4.0

type Security struct {
	EnableTLS  bool   `mapstructure:"enable_tls"`
	Tlsca      string `toml:"tlsca" json:"tlsca"`
	CommonName string `mapstructure:"common_name" json:"common_name"`
}

Security are certs used to setup connection with tls

type Union added in v1.4.0

type Union struct {
	Connectors []string `toml:"connectors" json:"connectors"`
	Providers  uint64   `toml:"providers" json:"providers"`
}

Jump to

Keyboard shortcuts

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