repo

package
v0.0.0-...-f069fcf Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 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 = "sidecar"

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

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

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

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

	// KeyName
	KeyName = "key.json"

	// NodeKeyName
	NodeKeyName = "node.priv"

	// KeyPassword
	KeyPassword = "link33"

	// API name
	APIName = "api"

	// link33 type
	Link33Type = "link33"
)

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 sidecar path and necessary configuration, account file and so on.

func KeyPath

func KeyPath(repoRoot string) string

func LoadNodePrivateKey

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

func NodeKeyPath(repoRoot string) string

func PathRoot

func PathRoot() (string, error)

PathRoot returns root path (default sidecar)

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 {
	Enable   bool   `toml:"enable" json:"enable"`
	Type     string `toml:"type" json:"type"`
	DID      string `toml:"did" json:"did"`
	Config   string `toml:"config" json:"config"`
	Plugin   string `toml:"plugin" json:"plugin"`
	PluginID string `toml:"plugin_id" json:"plugin_id"`
}

Appchain are configs about appchain

type Config

type Config struct {
	RepoRoot  string
	Debug     bool       `toml:"debug"  json:"debug"`
	Title     string     `toml:"title" json:"title"`
	Port      Port       `toml:"port" json:"port"`
	Log       Log        `toml:"log" json:"log"`
	Appchains []Appchain `toml:"appchains" json:"appchains"`
	Router    Router     `toml:"router" json:"router"`
	Security  Security   `toml:"security" json:"security"`
	Peer      Peer       `toml:"peer" json:"peer"`
}

Config represents the necessary config data for starting sidecar

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"`
	Module       LogModule `toml:"module" json:"module"`
}

Log are config about log

type LogModule

type LogModule struct {
	ApiServer   string `mapstructure:"api_server" toml:"api_server" json:"api_server" json:"api_server,omitempty"`
	AppchainMgr string `mapstructure:"appchain_mgr" toml:"appchain_mgr" json:"appchain_mgr" json:"appchain_mgr,omitempty"`
	App         string `mapstructure:"app" toml:"app" json:"app" json:"app,omitempty"`
	Monitor     string `toml:"monitor" json:"monitor" json:"monitor,omitempty"`
	PeerMgr     string `mapstructure:"peer_mgr" toml:"peer_mgr" json:"peer_mgr" json:"peer_mgr,omitempty"`
	Router      string `toml:"router" json:"router" json:"router,omitempty"`
	Swarm       string `toml:"swarm" json:"swarm" json:"swarm,omitempty"`
	Syncer      string `toml:"syncer" json:"syncer" json:"syncer,omitempty"`
	Manager     string `toml:"manager" json:"manager" json:"manager,omitempty"`
	Rule        string `toml:"rule" json:"rule" json:"rule,omitempty"`
}

type Mode

type Mode struct {
	Type  string `toml:"type" json:"type"`
	Relay Relay  `toml:"relay" json:"relay"`
	// TODO 连接节点
	Peers      []string `toml:"peers" json:"peers"`
	Connectors []string `toml:"connectors" json:"connectors"`
	Providers  uint64   `toml:"providers" json:"providers"`
}

type Peer

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

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 Router

type Router struct {
	Enable         bool     `toml:"enable" json:"enable,omitempty"`
	RouteMethod    string   `toml:"route_method" json:"route_method,omitempty"`
	RouteMethodArg []string `toml:"route_method_arg" json:"route_method_arg,omitempty"`
}

type Security

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

type Union struct {
	Addrs      []string `toml:"addrs" json:"addrs"`
	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