config

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigGuideUrl          = ""
	NodeKeyFileName         = "nodekey"
	JsonFileName            = "distribution-config.json"
	DefaultHttpPort         = 8001
	DefaultHttpVirtualHosts = "localhost"
	DefaultWSPort           = 8002
)

Variables

View Source
var (
	ErrConfigFormat          = fmt.Errorf(`file "%s" format error. %s`, JsonFileName, ConfigGuideUrl)
	ErrChainIDInConfig       = fmt.Errorf(`file "%s" error: chainID must be in [1, 65535]`, JsonFileName)
	ErrLogLevelInConfig      = fmt.Errorf(`file "%s" error: logLevel must be in [1, 5]`, JsonFileName)
	ErrHttpPortInConfig      = fmt.Errorf(`file "%s" error: http port must be less than 65535`, JsonFileName)
	ErrWebSocketPortInConfig = fmt.Errorf(`file "%s" error: websocket port must be less than 65535`, JsonFileName)
	ErrCoreNodeInConfig      = fmt.Errorf(`file "%s" error: coreNode must be like: 5e3600755f9b512a65603b38e30885c98cbac70259c3235c9b3f42ee563b480edea351ba0ff5748a638fe0aeff5d845bf37a3b437831871b48fd32f33cd9a3c0@127.0.0.1:60001`, JsonFileName)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ChainID         uint32  `json:"chainID"        gencodec:"required"`
	DeputyCount     uint32  `json:"deputyCount"    gencodec:"required"`
	TermDuration    uint64  `json:"termDuration"`
	InterimDuration uint64  `json:"interimDuration"`
	DbUri           string  `json:"dbUri"          gencodec:"required"` // sample: root:123123@tcp(localhost:3306)/lemochain?charset=utf8mb4
	DbDriver        string  `json:"dbDriver"       gencodec:"required"`
	LogLevel        uint32  `json:"logLevel"`
	CoreNode        string  `json:"coreNode"       gencodec:"required"`
	Http            RpcHttp `json:"http"`
	WebSocket       RpcWS   `json:"webSocket"`

	DataDir string
	// contains filtered or unexported fields
}

func ReadConfigFile

func ReadConfigFile() (*Config, error)

func (*Config) Check added in v1.2.0

func (c *Config) Check()

func (*Config) CoreEndpoint

func (c *Config) CoreEndpoint() string

func (*Config) CoreNodeID

func (c *Config) CoreNodeID() *p2p.NodeID

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Config) NodeKey

func (c *Config) NodeKey() *ecdsa.PrivateKey

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type ConfigMarshaling

type ConfigMarshaling struct {
	ChainID         hexutil.Uint32
	DeputyCount     hexutil.Uint32
	TermDuration    hexutil.Uint64
	InterimDuration hexutil.Uint64
	LogLevel        hexutil.Uint32
}

type RpcHttp

type RpcHttp struct {
	Disable      bool   `json:"disable"`
	Port         uint32 `json:"port"  gencodec:"required"`
	CorsDomain   string `json:"corsDomain"`
	VirtualHosts string `json:"virtualHosts"`
}

func (RpcHttp) MarshalJSON

func (r RpcHttp) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RpcHttp) UnmarshalJSON

func (r *RpcHttp) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type RpcMarshaling

type RpcMarshaling struct {
	Port hexutil.Uint32
}

type RpcWS

type RpcWS struct {
	Disable    bool   `json:"disable"`
	Port       uint32 `json:"port"  gencodec:"required"`
	CorsDomain string `json:"corsDomain"`
}

func (RpcWS) MarshalJSON

func (r RpcWS) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RpcWS) UnmarshalJSON

func (r *RpcWS) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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