repo

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: GPL-3.0 Imports: 24 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"

	NetworkName = "network.toml"

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

	// KeyName
	KeyName = "key.json"

	// NodeKeyName
	NodeKeyName = "node.priv"

	// NodeCsrName
	NodeCsrName = "node.csr"

	// 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 GetNetworkPeers added in v1.14.0

func GetNetworkPeers(networkConfig *NetworkConfig) (map[string]*peer2.AddrInfo, error)

GetNetworkPeers gets all peers from network config

func InitConfig

func InitConfig(path string) error

InitConfig initialize configuration

func Initialize

func Initialize(repoRoot, algo 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 ReadConfig added in v1.14.0

func ReadConfig(v *viper.Viper, path, configType string, config interface{}) error

func SetPath

func SetPath(root string)

SetPath sets global config path

func WriteNetworkConfig added in v1.14.0

func WriteNetworkConfig(originRoot string, repoRoot string, changeConfig *NetworkConfig) error

Types

type Appchain

type Appchain struct {
	ID     string `toml:"id" json:"id"`
	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"`
	TSS      *TSS     `toml:"tss" json:"tss"`
}

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 {
	GasLimit uint64 `toml:"gas_limit" json:"gas_limit"`
}

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"`
	Appchain    string `mapstructure:"appchain_adapter" toml:"appchain_adapter" json:"appchain_adapter"`
	Syncer      string `mapstructure:"bxh_adapter" toml:"bxh_adapter" json:"bxh_adapter"`
	Direct      string `mapstructure:"direct_adapter" toml:"direct_adapter" json:"direct_adapter"`
	Union       string `toml:"union_adapter" json:"union_adapter"`
	Cryptor     string `toml:"cryptor" json:"cryptor"`
}

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 NetworkConfig added in v1.14.0

type NetworkConfig struct {
	LocalAddr string          `toml:"local_addr, omitempty" json:"local_addr"`
	Piers     []*NetworkPiers `toml:"piers" json:"piers"`
}

func LoadNetworkConfig added in v1.14.0

func LoadNetworkConfig(repoRoot string, privateKey crypto2.PrivKey) (*NetworkConfig, error)

type NetworkPiers added in v1.14.0

type NetworkPiers struct {
	Pid   string   `toml:"pid" json:"pid"`
	Hosts []string `toml:"hosts" json:"hosts"`
}

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"`
	BitXHubID                  string        `mapstructure:"bitxhub_id" json:"bitxhub_id"`
	EnableOffChainTransmission bool          `mapstructure:"enable_offchain_transmission"`
}

Relay are configs about bitxhub

type Repo added in v1.14.0

type Repo struct {
	Config        *Config
	NetworkConfig *NetworkConfig
}

type Security added in v1.4.0

type Security struct {
	EnableTLS  bool     `mapstructure:"enable_tls"`
	AccessCert []string `mapstructure:"access_cert"`
	AccessKey  string   `mapstructure:"access_key"`
	Tlsca      string   `toml:"tlsca" json:"tlsca"`
	CommonName string   `mapstructure:"common_name" json:"common_name"`
}

Security are certs used to setup connection with tls

type TSS added in v1.22.0

type TSS struct {
	EnableTSS bool `mapstructure:"enable_tss" json:"enable_tss"`
}

type Union added in v1.4.0

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

Jump to

Keyboard shortcuts

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