config

package
v0.0.0-...-a968a3f Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoticeDefaultAddr  = "127.0.0.1:6379"
	NoticeDefaultPwd   = ""
	NoticeDefaultDB    = 0
	NoticeDefaultQueue = "QueueOfBlocks"
)
View Source
const (
	// all letters must be captitalized
	ORIGIN  Release = "ORIGIN"
	V2_10_3 Release = "V2_10_3"

	ORIGINFORKAT  common.Height = 0
	V2_10_3FORKAT common.Height = 30000000
)
View Source
const DefaultLoadLimit = 1

Variables

View Source
var (
	SystemStarterPrivate cipher.ECCPrivateKey
	SystemStarterPublic  cipher.ECCPublicKey
	SystemStarterPK      []byte
)
View Source
var (
	DefaultEthRpcEndpoint = common.Endpoint{NetType: "tcp", Address: common.DefaultEthRpcAddress}
)

Functions

func IsLogOn

func IsLogOn(logType LogType) bool

Types

type ChainConf

type ChainConf struct {
	ID                   common.ChainID      `yaml:"id" json:"id"`                     // ID of the chain
	ParentID             common.ChainID      `yaml:"parentid" json:"parentid"`         // ID of the parent chain,if there's no parent chain (main chain no parent),should be '1048576',IsNil()==true
	GenesisDataservers   []string            `yaml:"gdataservers" json:"gdataservers"` // string array of nodeid of the genesis data node
	GenesisDataserverIds []common.NodeID     `yaml:"-" json:"-"`                       // the nodeid array of genesis data node, convert from GenesisDataservers in validate()
	Dataservers          []string            `yaml:"dataservers" json:"dataservers"`   // String array of nodeid of non genesis data node
	DataserverIds        []common.NodeID     `yaml:"-" json:"-"`                       // nodeid array of genesis and non-genesis data nodes, created in validate()
	ElectType            common.ElectionType `yaml:"election" json:"election"`         // election type:VRF,Managed
	CommitteeIdStrings   []string            `yaml:"committee" json:"committee"`       // Array of nodeid strings for the initial committee
	CommitteeIds         []common.NodeID     `yaml:"-" json:"-"`                       // Array of NodeID for the initial committee
	Admins               []string            `yaml:"admins" json:"-"`                  // string array of account address of chain administrators
	AdminAddrs           []common.Address    `yaml:"-" json:"-"`                       // Address array of chain administrators
	SecondCoinId         uint32              `yaml:"coinId" json:"coinId"`             // local currency id
	SecondCoinName       string              `yaml:"coinName" json:"coinName"`         // local currency name
	Attributes           []string            `yaml:"attributes"`                       // attribute strings of the chain
}

func (*ChainConf) String

func (c *ChainConf) String() string

func (*ChainConf) Validate

func (c *ChainConf) Validate() error

type ChainConfs

type ChainConfs []*ChainConf

func (ChainConfs) GetChainElectType

func (cc ChainConfs) GetChainElectType(chainid common.ChainID) (common.ElectionType, error)

func (ChainConfs) GetGenesisDataNodeIds

func (cc ChainConfs) GetGenesisDataNodeIds(chainid common.ChainID) []common.NodeID

func (ChainConfs) GetInitCommittee

func (cc ChainConfs) GetInitCommittee(chainid common.ChainID) []common.NodeID

func (ChainConfs) Len

func (cc ChainConfs) Len() int

func (ChainConfs) Less

func (cc ChainConfs) Less(i, j int) bool

func (ChainConfs) Swap

func (cc ChainConfs) Swap(i, j int)

func (ChainConfs) Validate

func (cc ChainConfs) Validate() error

type ConfValidator

type ConfValidator interface {
	Validate() error
}

type Config

type Config struct {
	PriKeyString string               `yaml:"priKey"`      // hex string of private key of the node
	LoadLimit    int                  `yaml:"loadlimit"`   // Load upper limit. Configure the current node to make consensus on several chains at the same time. Default loadlimit = 2
	NetworkConf  NConfig              `yaml:"network"`     // network config
	DataConf     DConfig              `yaml:"data"`        // data node config
	LogTypes     []LogType            `yaml:"logs"`        // log types should print
	LogPath      string               `yaml:"logpath"`     // log file path
	Chains       ChainConfs           `yaml:"chains"`      // configs for genesis chains
	TxCount      uint64               `yaml:"txCount"`     //
	NetDelay     []int                `yaml:"netDelay"`    // range of network delay (for debugging)
	WaitingTime  *time.Duration       `yaml:"waitingTime"` // delay for consensus
	NodeType     *common.NodeType     `yaml:"nodetype"`    // type of node: Consensus:0, Data:1, Memo:2
	ForChain     *common.ChainID      `yaml:"forchain"`    // specifies the chain of node services
	FullData     bool                 `yaml:"fulldata"`    // whether a full data node
	CheckData    bool                 `yaml:"checkdata"`   // whether need to check old data
	Compatible   *bool                `yaml:"compatible"`  //
	Nid          *common.NodeID       `yaml:"-"`           // The nodeid object obtained by parsing Nodeidstring
	PrivKey      cipher.ECCPrivateKey `yaml:"-"`           // The private key object obtained by parsing PriKeyString
	StandAlone   bool                 `yaml:"standAlone"`  // whether start in single chain mode
	Noticer      *NoticeConf          `yaml:"notice"`
	Starter      *Starter             `yaml:"starter"`  // starter private key
	Releases     ReleaseDefs          `yaml:"releases"` // release definations
}
var (
	SystemConf *Config

	FullHashBigInt *big.Int = new(big.Int).SetBytes([]byte{
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	})
)

func LoadConfig

func LoadConfig(path string) (*Config, error)

func (*Config) IsCompatible

func (c *Config) IsCompatible() bool

func (*Config) MakeLogTypeMap

func (c *Config) MakeLogTypeMap()

type DConfig

type DConfig struct {
	Path string `yaml:"datapath"` // db path
}

type ETHRPCConfig

type ETHRPCConfig struct {
	MessageBufferSize uint16           `yaml:"buffersize" json:"-"`
	KeepaliveInterval int64            `yaml:"keepaliveinterval" json:"-"`
	EthRPCServerAddr  *common.Endpoint `yaml:"ethrpcserver" json:"ethrpcserver"`
}

func (*ETHRPCConfig) GetRpcEndpoint

func (rpc *ETHRPCConfig) GetRpcEndpoint() common.Endpoint

type ElectConf

type ElectConf struct {
	ChainID   common.ChainID      `yaml:"chainid"`   // ID of the chain
	Election  common.ElectionType `yaml:"election"`  // Election type, default NONE
	SyncBlock bool                `yaml:"syncblock"` // no use
}

func (ElectConf) String

func (cc ElectConf) String() string

type LogType

type LogType uint8
const (
	BasicLog LogType = iota
	NetLog
	NetDebugLog
	ConsensusLog
	ConsensusDebugLog
	DataLog
	DataDebugLog
	QueueLog
	QueueDebugLog
	VmLog
	VmDebugLog
	BalanceLog
	LengthOfLogType
)

func (LogType) String

func (l LogType) String() string

type NConfig

type NConfig struct {
	DataServers []common.Dataserver `yaml:"bootservers" json:"bootservers"`
	P2Ps        *P2PConfig          `yaml:"p2p",omitempty json:"p2p"`
	RPCs        *RPCConfig          `yaml:"rpc",omitempty json:"rpc"`
	ETHRPC      *ETHRPCConfig       `yaml:"ethrpc",omitempty json:"ethrpc"`
	Pprof       *string             `yaml:"pprof",omitempty json:"pprof"`

	DataServerMap map[common.NodeID][]common.Dataserver `yaml:"-" json:"-"` // nodeid -> []Dataserver
}

type NoticeConf

type NoticeConf struct {
	ChainID    *common.ChainID `yaml:"chainid" json:"chainid"`
	QueueSize  int             `yaml:"queueSize" json:"queueSize"`
	RedisAddr  string          `yaml:"addr" json:"addr"`
	RedisPwd   string          `yaml:"pwd" json:"pwd"`
	RedisDB    int             `yaml:"db" json:"db"`
	RedisQueue string          `yaml:"queue" json:"queue"`
}

func (*NoticeConf) String

func (n *NoticeConf) String() string

func (*NoticeConf) Validate

func (n *NoticeConf) Validate() error

type P2PConfig

type P2PConfig struct {
	PortRange *[2]uint16 `yaml:"portRange",omitempty json:"portRange"`
}

func (*P2PConfig) GetPortRange

func (p *P2PConfig) GetPortRange() *[2]uint16

type RPCConfig

type RPCConfig struct {
	MessageBufferSize uint16           `yaml:"buffersize" json:"-"`
	KeepaliveInterval int64            `yaml:"keepaliveinterval" json:"-"`
	RPCServerAddr     *common.Endpoint `yaml:"rpcserver" json:"rpcserver"`
}

func (*RPCConfig) GetRpcAddress

func (rpc *RPCConfig) GetRpcAddress() string

func (*RPCConfig) GetRpcEndpoint

func (rpc *RPCConfig) GetRpcEndpoint() common.Endpoint

type Release

type Release string

func (Release) IsValid

func (r Release) IsValid() bool

type ReleaseDef

type ReleaseDef struct {
	Name   Release       `yaml:"name"`
	ForkAt common.Height `yaml:"fork"`
}

func (ReleaseDef) String

func (d ReleaseDef) String() string

type ReleaseDefs

type ReleaseDefs []ReleaseDef

func (ReleaseDefs) Validate

func (defs ReleaseDefs) Validate() error

type Releases

type Releases struct {
	// contains filtered or unexported fields
}
var (
	SysReleases *Releases
)

func NewReleases

func NewReleases(defs ReleaseDefs) (*Releases, error)

func (Releases) IsForked

func (rl Releases) IsForked(release Release, current common.Height) bool

func (Releases) String

func (rl Releases) String() string

func (Releases) Which

func (rl Releases) Which(height common.Height) (at Release, exist bool)

type Starter

type Starter struct {
	SKString string `yaml:"sk" json:"sk"`
	PKString string `yaml:"pk" json:"pk"`
}

func (*Starter) Validate

func (s *Starter) Validate() error

Jump to

Keyboard shortcuts

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