repo

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectMode = "direct"
	RelayMode  = "relay"
)
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"

	// KeyPassword
	KeyPassword = "bitxhub"

	// API name
	APIName = "api"
)
View Source
const (
	// Items
	LogLevel = "log.level"
)

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 LoadPrivateKey

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

LoadPrivateKey loads private key from config path

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 {
	Plugin string `toml:"plugin" json:"plugin"`
	Config string `toml:"config" json:"config"`
}

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"`
}

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 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"`
}

Log are config about log

type Mode

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

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 {
	Addr       string   `toml:"addr" json:"addr"`
	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

Jump to

Keyboard shortcuts

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