config

package
v0.0.0-...-86e039a Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_CONFIG_FILE_NAME = "./config.json"
	DEFAULT_WALLET_FILE_NAME = "./wallet.dat"
	MIN_GEN_BLOCK_TIME       = 2
	DEFAULT_GEN_BLOCK_TIME   = 6
	DBFT_MIN_NODE_NUM        = 4 //min node number of dbft consensus
	SOLO_MIN_NODE_NUM        = 1 //min node number of solo consensus
	VBFT_MIN_NODE_NUM        = 4 //min node number of vbft consensus

	CONSENSUS_TYPE_DBFT = "dbft"
	CONSENSUS_TYPE_SOLO = "solo"
	CONSENSUS_TYPE_VBFT = "vbft"

	DEFAULT_LOG_LEVEL                       = log.InfoLog
	DEFAULT_MAX_LOG_SIZE                    = 100 //MByte
	DEFAULT_NODE_PORT                       = uint(20338)
	DEFAULT_CONSENSUS_PORT                  = uint(20339)
	DEFAULT_RPC_PORT                        = uint(20336)
	DEFAULT_RPC_LOCAL_PORT                  = uint(20337)
	DEFAULT_REST_PORT                       = uint(20334)
	DEFAULT_WS_PORT                         = uint(20335)
	DEFAULT_REST_MAX_CONN                   = uint(1024)
	DEFAULT_MAX_CONN_IN_BOUND               = uint(1024)
	DEFAULT_MAX_CONN_OUT_BOUND              = uint(1024)
	DEFAULT_MAX_CONN_IN_BOUND_FOR_SINGLE_IP = uint(16)
	DEFAULT_HTTP_INFO_PORT                  = uint(0)
	DEFAULT_MAX_TX_IN_BLOCK                 = 60000
	DEFAULT_MAX_SYNC_HEADER                 = 500
	DEFAULT_ENABLE_CONSENSUS                = true
	DEFAULT_ENABLE_EVENT_LOG                = true
	DEFAULT_CLI_RPC_PORT                    = uint(20000)
	DEFUALT_CLI_RPC_ADDRESS                 = "127.0.0.1"
	DEFAULT_GAS_LIMIT                       = 20000
	DEFAULT_GAS_PRICE                       = 500

	DEFAULT_DATA_DIR      = "./Chain"
	DEFAULT_RESERVED_FILE = "./peers.rsv"
)
View Source
const (
	NETWORK_ID_MAIN_NET      = 1
	NETWORK_ID_POLARIS_NET   = 2
	NETWORK_ID_SOLO_NET      = 3
	NETWORK_NAME_MAIN_NET    = "onyxchain"
	NETWORK_NAME_POLARIS_NET = "polaris"
	NETWORK_NAME_SOLO_NET    = "testmode"
)

Variables

View Source
var DefConfig = NewOnyxChainConfig()
View Source
var MainNetConfig = &GenesisConfig{
	SeedList: []string{
		"andromeda1.onyxpay.co:20338",
		"andromeda2.onyxpay.co:20338",
		"andromeda3.onyxpay.co:20338",
		"andromeda4.onyxpay.co:20338",
		"andromeda5.onyxpay.co:20338",
		"andromeda6.onyxpay.co:20338",
		"andromeda7.onyxpay.co:20338",
		"andromeda8.onyxpay.co:20338",
		"andromeda9.onyxpay.co:20338"},
	ConsensusType: CONSENSUS_TYPE_VBFT,
	VBFT: &VBFTConfig{
		N:                    7,
		C:                    2,
		K:                    7,
		L:                    112,
		BlockMsgDelay:        10000,
		HashMsgDelay:         10000,
		PeerHandshakeTimeout: 10,
		MaxBlockChangeView:   120000,
		AdminOnxID:           "did:onx:AXZwMA2ETixSSC65tGsoguAnjNhzQWnADm",
		MinInitStake:         10000000000000,
		VrfValue:             "1c9810aa9822e511d5804a9c4db9dd08497c31087b0daafa34d768a3253441fa20515e2f30f81741102af0ca3cefc4818fef16adb825fbaa8cad78647f3afb590e",
		VrfProof:             "c57741f934042cb8d8b087b44b161db56fc3ffd4ffb675d36cd09f83935be853d8729f3f5298d12d6fd28d45dde515a4b9d7f67682d182ba5118abf451ff1988",
		Peers: []*VBFTPeerStakeInfo{
			{
				Index:      1,
				PeerPubkey: "03cf02729835f9fc45cf6e5864b7a1b5dd3fea3f0c4a8f850ee6b76d53caaf08b3",
				Address:    "ANA2KoVAmddnzP8QQKi85DFGHT2dTKHpMR",
			},
			{
				Index:      2,
				PeerPubkey: "02bfe1ddec354c3e5175576892fa9aa3808d846bb6a3ef1b8bbfef2ed1da611b3f",
				Address:    "ATHjUvQ55ynXr9nmNv4BFPsAEyMK7YqgpK",
			},
			{
				Index:      3,
				PeerPubkey: "03599eb6184e59414acc83b4e337b20d261d84e57f3d2c303d8833253be12fbda4",
				Address:    "AZUH86XLbvBd8pJwbWo6mU5ToXcCtDUmwM",
			},
			{
				Index:      4,
				PeerPubkey: "035fcb17d4ec8d0a9f209df17fe68d377bbe40df0d98a0c2dbf017ea8ecdc27c3d",
				Address:    "ANg7s32wT8RUqFYz9cZf1cwCdGH8hcjnTR",
			},
			{
				Index:      5,
				PeerPubkey: "024c799d2053c7b9a2fe44ab136fed146e553ccab25f665d5759711dc79e907acb",
				Address:    "ARec8JxYQyr6fnCD4Ghpg1Tz2GNCumJtSa",
			},
			{
				Index:      6,
				PeerPubkey: "0257a94b74591f720ad7cc05e706c262f915c6e889ef98588a3adb0d702cf96f50",
				Address:    "AVVSLeqcTWacLN2LSnFms6GvrYVzdqrCB8",
			},
			{
				Index:      7,
				PeerPubkey: "03d50f031adc124a657e22b5d54f34bafc25387e8c589bae117bdd158dcfa79103",
				Address:    "AKgBjiwqT74UbV2XW6FL14WhKRki2Mz2X6",
			},
		},
	},
	DBFT: &DBFTConfig{},
	SOLO: &SOLOConfig{},
}
View Source
var TestNetConfig = &GenesisConfig{
	SeedList: []string{
		"cepheus1.onyxpay.co:20338",
		"cepheus2.onyxpay.co:20338",
		"cepheus3.onyxpay.co:20338",
		"cepheus4.onyxpay.co:20338",
		"cepheus5.onyxpay.co:20338"},
	ConsensusType: CONSENSUS_TYPE_VBFT,
	VBFT: &VBFTConfig{
		N:                    7,
		C:                    2,
		K:                    7,
		L:                    112,
		BlockMsgDelay:        10000,
		HashMsgDelay:         10000,
		PeerHandshakeTimeout: 10,
		MaxBlockChangeView:   3000,
		AdminOnxID:           "did:onx:AaqCTX9JBCcaFzSSY3wBTFHgjnD39kjKdE",
		MinInitStake:         10000000000000,
		VrfValue:             "1c9810aa9822e511d5804a9c4db9dd08497c31087b0daafa34d768a3253441fa20515e2f30f81741102af0ca3cefc4818fef16adb825fbaa8cad78647f3afb590e",
		VrfProof:             "c57741f934042cb8d8b087b44b161db56fc3ffd4ffb675d36cd09f83935be853d8729f3f5298d12d6fd28d45dde515a4b9d7f67682d182ba5118abf451ff1988",
		Peers: []*VBFTPeerStakeInfo{
			{
				Index:      1,
				PeerPubkey: "02e17137be61d0497ca9c7f6dfc63023d36a82c45f2e01990b853801f56b859a89",
				Address:    "ANdgnhAsrdfkHJGCBbR7Fsfv2VH4qrQAqr",
				InitPos:    10000,
			},
			{
				Index:      2,
				PeerPubkey: "03306a51e3038f47cd8ae3de6dd05e015abd52a5b3731f461f4e6f08e84580d5bc",
				Address:    "Af35ofPFXopLHEkkeSqsKtKk6h8u6usjaX",
				InitPos:    20000,
			},
			{
				Index:      3,
				PeerPubkey: "03c27db2cddb2868aa9cc1357e360082e8a806b0b714322a7e73935305566938ca",
				Address:    "AX3gRr6zRpsvutiphZNo5WMv8BTWCZ72RM",
				InitPos:    30000,
			},
			{
				Index:      4,
				PeerPubkey: "03a25aaecaea8d8a75b2d9f15ebcf5fc34c1ad8f6a6de96e59a4fe04d9a73e0088",
				Address:    "AY64Ni7zWLaND6whYNv2EvFkAjdWsQZM5h",
				InitPos:    40000,
			},
			{
				Index:      5,
				PeerPubkey: "0213825fb06c8eab999934c989e5411aad376608e1f020ffbe2c88befec2d77b95",
				Address:    "AYEbLFtPkPstRTogTtAuM3oFYXEZ7uSDSt",
				InitPos:    30000,
			},
			{
				Index:      6,
				PeerPubkey: "02f1ff6a31f0be1dc41c602d3b39a86735d8fcb287a20f86b50c04f34a013d4317",
				Address:    "AQhYB8wQ8oWmKNjycEhdm3xoC9wVAX2V6u",
				InitPos:    20000,
			},
			{
				Index:      7,
				PeerPubkey: "027730e7d488923d7802cfdb8abedeb650a6c9b981dfd7a9f2d41d05c61bdbe267",
				Address:    "AXmPNMMKd4Tk9sFwHfSzpBbFkf4VtqdGur",
				InitPos:    10000,
			},
		},
	},
	DBFT: &DBFTConfig{},
	SOLO: &SOLOConfig{},
}
View Source
var Version = "1.6.0" //Set value when build project

Functions

func GetNetworkMagic

func GetNetworkMagic(id uint32) uint32

func GetNetworkName

func GetNetworkName(id uint32) string

func GetStateHashCheckHeight

func GetStateHashCheckHeight(id uint32) uint32

Types

type CommonConfig

type CommonConfig struct {
	LogLevel       uint
	NodeType       string
	EnableEventLog bool
	SystemFee      map[string]int64
	GasLimit       uint64
	GasPrice       uint64
	DataDir        string
}

type ConsensusConfig

type ConsensusConfig struct {
	EnableConsensus bool
	MaxTxInBlock    uint
}

type DBFTConfig

type DBFTConfig struct {
	GenBlockTime uint
	Bookkeepers  []string
}

type GenesisConfig

type GenesisConfig struct {
	SeedList      []string
	ConsensusType string
	VBFT          *VBFTConfig
	DBFT          *DBFTConfig
	SOLO          *SOLOConfig
}

func NewGenesisConfig

func NewGenesisConfig() *GenesisConfig

type OnyxChainConfig

type OnyxChainConfig struct {
	Genesis   *GenesisConfig
	Common    *CommonConfig
	Consensus *ConsensusConfig
	P2PNode   *P2PNodeConfig
	Rpc       *RpcConfig
	Restful   *RestfulConfig
	Ws        *WebSocketConfig
}

func NewOnyxChainConfig

func NewOnyxChainConfig() *OnyxChainConfig

func (*OnyxChainConfig) GetBookkeepers

func (this *OnyxChainConfig) GetBookkeepers() ([]keypair.PublicKey, error)

func (*OnyxChainConfig) GetDefaultNetworkId

func (this *OnyxChainConfig) GetDefaultNetworkId() (uint32, error)

type P2PNodeConfig

type P2PNodeConfig struct {
	ReservedPeersOnly         bool
	ReservedCfg               *P2PRsvConfig
	NetworkMagic              uint32
	NetworkId                 uint32
	NetworkName               string
	NodePort                  uint
	NodeConsensusPort         uint
	DualPortSupport           bool
	IsTLS                     bool
	CertPath                  string
	KeyPath                   string
	CAPath                    string
	HttpInfoPort              uint
	MaxHdrSyncReqs            uint
	MaxConnInBound            uint
	MaxConnOutBound           uint
	MaxConnInBoundForSingleIP uint
}

type P2PRsvConfig

type P2PRsvConfig struct {
	ReservedPeers []string `json:"reserved"`
	MaskPeers     []string `json:"mask"`
}

type RestfulConfig

type RestfulConfig struct {
	EnableHttpRestful  bool
	HttpRestPort       uint
	HttpMaxConnections uint
	HttpCertPath       string
	HttpKeyPath        string
}

type RpcConfig

type RpcConfig struct {
	EnableHttpJsonRpc bool
	HttpJsonPort      uint
	HttpLocalPort     uint
	HttpCertPath      string
	HttpKeyPath       string
}

type SOLOConfig

type SOLOConfig struct {
	GenBlockTime uint
	Bookkeepers  []string
}

type VBFTConfig

type VBFTConfig struct {
	N                    uint32               `json:"n"` // network size
	C                    uint32               `json:"c"` // consensus quorum
	K                    uint32               `json:"k"`
	L                    uint32               `json:"l"`
	BlockMsgDelay        uint32               `json:"block_msg_delay"`
	HashMsgDelay         uint32               `json:"hash_msg_delay"`
	PeerHandshakeTimeout uint32               `json:"peer_handshake_timeout"`
	MaxBlockChangeView   uint32               `json:"max_block_change_view"`
	MinInitStake         uint64               `json:"min_init_stake"`
	AdminOnxID           string               `json:"admin_onx_id"`
	VrfValue             string               `json:"vrf_value"`
	VrfProof             string               `json:"vrf_proof"`
	Peers                []*VBFTPeerStakeInfo `json:"peers"`
}

VBFT genesis config, from local config file

func (*VBFTConfig) Deserialize

func (this *VBFTConfig) Deserialize(r io.Reader) error

func (*VBFTConfig) Serialize

func (this *VBFTConfig) Serialize(w io.Writer) error

type VBFTPeerStakeInfo

type VBFTPeerStakeInfo struct {
	Index      uint32 `json:"index"`
	PeerPubkey string `json:"peerPubkey"`
	Address    string `json:"address"`
	InitPos    uint64 `json:"initPos"`
}

func (*VBFTPeerStakeInfo) Deserialize

func (this *VBFTPeerStakeInfo) Deserialize(r io.Reader) error

func (*VBFTPeerStakeInfo) Serialize

func (this *VBFTPeerStakeInfo) Serialize(w io.Writer) error

type WebSocketConfig

type WebSocketConfig struct {
	EnableHttpWs bool
	HttpWsPort   uint
	HttpCertPath string
	HttpKeyPath  string
}

Jump to

Keyboard shortcuts

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