repo

package
v1.13.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// key name
	KeyName = "key.json"
	// API name
	APIName = "api"
	// admin weight
	SuperAdminWeight  = 2
	NormalAdminWeight = 1
	// governance strategy default participate threshold
	DefaultParticipateThreshold = 0.75
	//Passwd
	DefaultPasswd = "bitxhub"
)

Variables

This section is empty.

Functions

func GetAPI

func GetAPI(repoRoot string) (string, error)

func GetKeyPath

func GetKeyPath(repoRoot string) string

func GetPidFromPrivFile added in v1.0.1

func GetPidFromPrivFile(privPath string) (string, error)

GetPidFromPrivFile gets pid from libp2p node priv file

func GetStoragePath

func GetStoragePath(repoRoot string, subPath ...string) string

func Initialize

func Initialize(repoRoot string) error

func Initialized

func Initialized(repoRoot string) bool

func PathRoot

func PathRoot() (string, error)

func PathRootWithDefault

func PathRootWithDefault(path string) (string, error)

func ReadConfig

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

func RewriteNetworkConfig added in v1.4.0

func RewriteNetworkConfig(repoRoot string, infos map[uint64]*pb.VpInfo, isNew bool) error

func WatchBitxhubConfig added in v1.6.3

func WatchBitxhubConfig(viper *viper.Viper, feed *event.Feed)

func WatchNetworkConfig added in v1.6.3

func WatchNetworkConfig(viper *viper.Viper, feed *event.Feed, config *NetworkConfig)

Types

type Admin added in v1.6.0

type Admin struct {
	Address string `json:"address" toml:"address"`
	Weight  uint64 `json:"weight" toml:"weight"`
}

type Appchain added in v1.10.0

type Appchain struct {
	Enable        bool   `toml:"enable" json:"enable"`
	EthHeaderPath string `mapstructure:"eth_header_path"`
}

type Cert

type Cert struct {
	Verify         bool   `toml:"verify" json:"verify"`
	NodeCertPath   string `mapstructure:"node_cert_path" json:"node_cert_path"`
	AgencyCertPath string `mapstructure:"agency_cert_path" json:"agency_cert_path"`
	CACertPath     string `mapstructure:"ca_cert_path" json:"ca_cert_path"`
}

type Config

type Config struct {
	RepoRoot string `json:"repo_root"`
	Title    string `json:"title"`
	Solo     bool   `json:"solo"`
	Port     `json:"port"`
	PProf    `json:"pprof"`
	Monitor  `json:"monitor"`
	Limiter  `json:"limiter"`
	Appchain `json:"appchain"`
	Gateway  `json:"gateway"`
	Ping     `json:"ping"`
	Log      `json:"log"`
	Cert     `json:"cert"`
	Txpool   `json:"txpool"`
	Order    `json:"order"`
	Executor `json:"executor"`
	Ledger   `json:"ledger"`
	Genesis  `json:"genesis"`
	Security Security `toml:"security" json:"security"`
	License  License  `toml:"license" json:"license"`
	Crypto   Crypto   `toml:"crypto" json:"crypto"`
}

func DefaultConfig

func DefaultConfig() (*Config, error)

func UnmarshalConfig

func UnmarshalConfig(viper *viper.Viper, repoRoot string, configPath string) (*Config, error)

func (*Config) Bytes

func (c *Config) Bytes() ([]byte, error)

type Crypto added in v1.13.0

type Crypto struct {
	Algorithms []string `json:"algorithms" toml:"algorithms"`
}

type Executor added in v1.0.1

type Executor struct {
	Type string `toml:"type" json:"type"`
}

type Gateway

type Gateway struct {
	AllowedOrigins []string `mapstructure:"allowed_origins"`
}

type Genesis

type Genesis struct {
	ChainID     uint64            `json:"chainid" toml:"chainid"`
	GasLimit    uint64            `mapstructure:"gas_limit" json:"gas_limit" toml:"gas_limit"`
	BvmGasPrice uint64            `mapstructure:"bvm_gas_price" json:"bvm_gas_price" toml:"bvm_gas_price"`
	Balance     string            `json:"balance" toml:"balance"`
	Admins      []*Admin          `json:"admins" toml:"admins"`
	Strategy    map[string]string `json:"strategy" toml:"strategy"`
	Dider       string            `json:"dider" toml:"dider"`
}

type Key

type Key struct {
	Address       string             `json:"address"`
	PrivKey       crypto2.PrivateKey `json:"priv_key"`
	Libp2pPrivKey crypto.PrivKey
}

func LoadKey

func LoadKey(path string) (*Key, error)

type Ledger added in v1.9.0

type Ledger struct {
	Type string `toml:"type" json:"type"`
}

type License added in v1.6.2

type License struct {
	Key      string `toml:"key" json:"key"`
	Verifier string `toml:"verifier" json:"verifier"`
}

type Limiter added in v1.6.0

type Limiter struct {
	Interval time.Duration `toml:"interval" json:"interval"`
	Quantum  int64         `toml:"quantum" json:"quantum"`
	Capacity int64         `toml:"capacity" json:"capacity"`
}

type Log

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

type LogModule

type LogModule struct {
	P2P       string `toml:"p2p" json:"p2p"`
	Consensus string `toml:"consensus" json:"consensus"`
	Executor  string `toml:"executor" json:"executor"`
	Router    string `toml:"router" json:"router"`
	API       string `toml:"api" json:"api"`
	CoreAPI   string `mapstructure:"coreapi" toml:"coreapi" json:"coreapi"`
	Storage   string `toml:"storage" json:"storage"`
	Profile   string `toml:"profile" json:"profile"`
}

type Monitor

type Monitor struct {
	Enable bool
}

type NetworkConfig

type NetworkConfig struct {
	ID        uint64          `toml:"id" json:"id"`
	N         uint64          `toml:"n" json:"n"`
	New       bool            `toml:"new" json:"new"`
	LocalAddr string          `toml:"local_addr, omitempty" json:"local_addr"`
	Nodes     []*NetworkNodes `toml:"nodes" json:"nodes"`
	Genesis   Genesis         `toml:"genesis, omitempty" json:"genesis"`
}

func (*NetworkConfig) GetNetworkPeers added in v1.4.0

func (config *NetworkConfig) GetNetworkPeers() (map[uint64]*peer.AddrInfo, error)

GetNetworkPeers gets all peers from network config

func (*NetworkConfig) GetVpAccount added in v1.4.0

func (config *NetworkConfig) GetVpAccount() map[uint64]types.Address

GetVpAccount gets genesis address from network config

func (*NetworkConfig) GetVpGenesisAccount added in v1.4.0

func (config *NetworkConfig) GetVpGenesisAccount() map[uint64]types.Address

GetVpGenesisAccount gets genesis address from network config

func (*NetworkConfig) GetVpInfos added in v1.4.0

func (config *NetworkConfig) GetVpInfos() map[uint64]*pb.VpInfo

GetVpInfos gets vp info from network config

type NetworkNodes

type NetworkNodes struct {
	ID      uint64   `toml:"id" json:"id"`
	Pid     string   `toml:"pid" json:"pid"`
	Hosts   []string `toml:"hosts" json:"hosts"`
	Account string   `toml:"account" json:"account"`
}

type Order

type Order struct {
	Type string `toml:"type" json:"type"`
}

type PProf

type PProf struct {
	Enable   bool          `toml:"enbale" json:"enable"`
	PType    string        `toml:"ptype" json:"ptype"`
	Mode     string        `toml:"mode" json:"mode"`
	Duration time.Duration `toml:"duration" json:"duration"`
}

type Ping added in v1.4.0

type Ping struct {
	Enable   bool          `toml:"enable" json:"enable"`
	Duration time.Duration `toml:"duration" json:"duration"`
}

type Port

type Port struct {
	JsonRpc int64 `toml:"jsonrpc" json:"jsonrpc"`
	Grpc    int64 `toml:"grpc" json:"grpc"`
	Gateway int64 `toml:"gateway" json:"gateway"`
	PProf   int64 `toml:"pprof" json:"pprof"`
	Monitor int64 `toml:"monitor" json:"monitor"`
}

type Repo

type Repo struct {
	Config           *Config
	NetworkConfig    *NetworkConfig
	Key              *Key
	Certs            *libp2pcert.Certs
	ConfigChangeFeed event.Feed
}

func Load

func Load(repoRoot string, passwd string, configPath string, networkPath string) (*Repo, error)

func (*Repo) SubscribeConfigChange added in v1.6.3

func (r *Repo) SubscribeConfigChange(ch chan *Repo) event.Subscription

type Security added in v1.0.1

type Security struct {
	EnableTLS       bool   `mapstructure:"enable_tls"`
	PemFilePath     string `mapstructure:"pem_file_path" json:"pem_file_path"`
	ServerKeyPath   string `mapstructure:"server_key_path" json:"server_key_path"`
	GatewayCertPath string `mapstructure:"gateway_cert_path" json:"gateway_cert_path"`
	GatewayKeyPath  string `mapstructure:"gateway_key_path" json:"gateway_key_path"`
}

Security are files used to setup connection with tls

type Txpool

type Txpool struct {
	BatchSize    int           `mapstructure:"batch_size" json:"batch_size"`
	BatchTimeout time.Duration `mapstructure:"batch_timeout" json:"batch_timeout"`
}

Jump to

Keyboard shortcuts

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