repo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// key name
	KeyName = "key.json"
	// API name
	APIName = "api"
)

Variables

This section is empty.

Functions

func AddrToPeerInfo

func AddrToPeerInfo(multiAddr string) (*peer.AddrInfo, error)

AddrToPeerInfo transfer addr to PeerInfo addr example: "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64"

func AddrsToPeerInfo added in v1.0.1

func AddrsToPeerInfo(multiAddrs []string) ([]peer.AddrInfo, error)

AddrsToPeerInfo transfer addrs to PeerInfo

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 MultiaddrToPeerID added in v1.0.1

func MultiaddrToPeerID(multiAddr string) (string, error)

MultiaddrToPeerID .

func PathRoot

func PathRoot() (string, error)

func PathRootWithDefault

func PathRootWithDefault(path string) (string, error)

func ReadConfig

func ReadConfig(path, configType string, config interface{}) error

Types

type Cert

type Cert struct {
	Verify bool `toml:"verify" json:"verify"`
}

type Certs

type Certs struct {
	NodeCertData   []byte
	AgencyCertData []byte
	CACertData     []byte
	NodeCert       *x509.Certificate
	AgencyCert     *x509.Certificate
	CACert         *x509.Certificate
}

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"`
	Gateway  `json:"gateway"`
	Log      `json:"log"`
	Cert     `json:"cert"`
	Txpool   `json:"txpool"`
	Order    `json:"order"`
	Executor `json:"executor"`
	Security Security `toml:"security" json:"security"`
}

func DefaultConfig

func DefaultConfig() (*Config, error)

func UnmarshalConfig

func UnmarshalConfig(repoRoot string) (*Config, error)

func (*Config) Bytes

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

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 {
	Addresses []string `json:"addresses" toml:"addresses"`
}

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

type Monitor

type Monitor struct {
	Enable bool
}

type NetworkConfig

type NetworkConfig struct {
	ID         uint64
	N          uint64
	LocalAddr  string
	Nodes      []*NetworkNode
	OtherNodes map[uint64]*peer.AddrInfo
}

NetworkConfig . @param OtherNodes to fit original code @param OthersNodes for new network config

func (NetworkConfig) Len added in v1.0.1

func (p NetworkConfig) Len() int

Len returns length of the struct to be sorted

func (NetworkConfig) Less added in v1.0.1

func (p NetworkConfig) Less(i, j int) bool

Less compares two iterms ascending(ASC)

func (NetworkConfig) Swap added in v1.0.1

func (p NetworkConfig) Swap(i, j int)

Swap swaps iterms

type NetworkNode added in v1.0.1

type NetworkNode struct {
	ID    uint64
	Addr  string // the optimal address of a node
	Addrs []string
}

NetworkNode is the struct to describe network conf of a node @param ID is the id of the node, it is origined by sorting. @param Addrs is the address array of the node. @param Addr is the default used address the node.

type Order

type Order struct {
	Plugin string `toml:"plugin" json:"plugin"`
}

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 Port

type Port struct {
	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 ReadinNetworkConfig added in v1.0.1

type ReadinNetworkConfig struct {
	Addrs [][]string
}

ReadinNetworkConfig is used for read in toml file

type Repo

type Repo struct {
	Config        *Config
	NetworkConfig *NetworkConfig
	Genesis       *Genesis
	Key           *Key
	Certs         *Certs
}

func Load

func Load(repoRoot string) (*Repo, error)

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

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