repo

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: GPL-3.0 Imports: 28 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
	DefaultSimpleMajorityExpression = "a > 0.5 * t"
	DefaultZeroStrategyExpression   = "a >= 0"
	//Passwd
	DefaultPasswd = "bitxhub"

	SuperMajorityApprove = "SuperMajorityApprove"
	SuperMajorityAgainst = "SuperMajorityAgainst"
	SimpleMajority       = "SimpleMajority"
	ZeroPermission       = "ZeroPermission"

	AppchainMgr         = "appchain_mgr"
	RuleMgr             = "rule_mgr"
	NodeMgr             = "node_mgr"
	ServiceMgr          = "service_mgr"
	RoleMgr             = "role_mgr"
	ProposalStrategyMgr = "proposal_strategy_mgr"
	DappMgr             = "dapp_mgr"
	AllMgr              = "all_mgr"
)

Variables

This section is empty.

Functions

func CheckManageModule added in v1.11.3

func CheckManageModule(moduleTyp string) error

func CheckStrategyExpression added in v1.11.3

func CheckStrategyExpression(expressionStr string, adminsNum int) error

func CheckStrategyInfo added in v1.11.3

func CheckStrategyInfo(typ, module string, extra string, adminsNum int) error

func CheckStrategyType added in v1.11.3

func CheckStrategyType(typ string, extra string, adminsNum int) error

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 MakeStrategyDecision added in v1.11.3

func MakeStrategyDecision(expressionStr string, approve, reject, total, avaliableNum uint64) (bool, bool, error)

return: - whether the proposal is over, if not, you need to wait for the vote - whether the proposal is pass, that is, it has ended, may be passed or rejected - error

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)

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"`
	Tss      tss.TssConfig `toml:"tss" json:"tss"`
}

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    []*Strategy `json:"strategy" toml:"strategy"`
}

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"`
	TSS       string `toml:"tss" json:"tss"`
}

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 Strategy added in v1.11.3

type Strategy struct {
	Module string `json:"module" toml:"module"`
	Typ    string `json:"typ" toml:"typ"`
	Extra  string `json:"extra" toml:"extra"`
}

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