nodeconfig

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package nodeconfig includes all the configuration variables for a node. It is a global configuration for node and other services. It will be included in node module, and other modules.

Index

Constants

View Source
const (
	Mainnet   = "mainnet"
	Testnet   = "testnet"
	Devnet    = "devnet"
	Stressnet = "stressnet"
	Localnet  = "localnet"
)

Constants for NetworkType TODO: replace this with iota. Leave the string parsing in command line

View Source
const (
	Global    = 0
	MaxShards = 32 // maximum number of shards. It is also the maxium number of configs.
)

Global is the index of the global node configuration

View Source
const (
	// DefaultLocalListenIP is the IP used for local hosting
	DefaultLocalListenIP = "127.0.0.1"
	// DefaultPublicListenIP is the IP used for public hosting
	DefaultPublicListenIP = "0.0.0.0"
	// DefaultP2PPort is the key to be used for p2p communication
	DefaultP2PPort = 9000
	// DefaultLegacyDNSPort is the default legacy DNS port. The actual port used is DNSPort - 3000. This is a
	// very bad design. Refactored to DefaultDNSPort
	DefaultLegacyDNSPort = 9000
	// DefaultDNSPort is the default DNS port for both remote node and local server.
	DefaultDNSPort = 6000
	// DefaultRPCPort is the default rpc port. The actual port used is 9000+500
	DefaultRPCPort = 9500
	// DefaultAuthRPCPort is the default rpc auth port. The actual port used is 9000+501
	DefaultAuthRPCPort = 9501
	// DefaultRosettaPort is the default rosetta port. The actual port used is 9000+700
	DefaultRosettaPort = 9700
	// DefaultWSPort is the default port for web socket endpoint. The actual port used is
	DefaultWSPort = 9800
	// DefaultAuthWSPort is the default port for web socket auth endpoint. The actual port used is
	DefaultAuthWSPort = 9801
	// DefaultPrometheusPort is the default prometheus port. The actual port used is 9000+900
	DefaultPrometheusPort = 9900
	// DefaultP2PConcurrency is the default P2P concurrency, 0 means is set the default value of P2P Discovery, the actual value is 10
	DefaultP2PConcurrency = 0
	DefaultMaxConnPerIP   = 10
)
View Source
const (
	// DefaultRateLimit for RPC, the number of requests per second
	DefaultRPCRateLimit = 1000
)

Variables

This section is empty.

Functions

func GetDefaultBootNodes

func GetDefaultBootNodes(networkType NetworkType) []string

GetDefaultBootNodes get the default bootnode with the given network type

func GetDefaultDNSPort

func GetDefaultDNSPort(NetworkType) int

GetDefaultDNSPort get the default DNS port for the given network type

func GetDefaultDNSZone

func GetDefaultDNSZone(networkType NetworkType) string

GetDefaultDNSZone get the default DNS zone with the given network type

func GetPeerID

func GetPeerID() peer.ID

GetPeerID returns the peer ID of the node

func GetPrometheusHTTPPortFromBase

func GetPrometheusHTTPPortFromBase(basePort int) int

GetPrometheusHTTPPortFromBase return the prometheus HTTP port from base port

func GetRPCAuthHTTPPortFromBase

func GetRPCAuthHTTPPortFromBase(basePort int) int

GetRPCAuthHTTPPortFromBase return the rpc HTTP port from base port

func GetRPCHTTPPortFromBase

func GetRPCHTTPPortFromBase(basePort int) int

GetRPCHTTPPortFromBase return the rpc HTTP port from base port

func GetRosettaHTTPPortFromBase

func GetRosettaHTTPPortFromBase(basePort int) int

GetRosettaHTTPPortFromBase return the rosetta HTTP port from base port

func GetVersion

func GetVersion() string

GetVersion return the version of the node binary

func GetWSAuthPortFromBase

func GetWSAuthPortFromBase(basePort int) int

GetWSAuthPortFromBase return the Websocket port from the base auth port

func GetWSPortFromBase

func GetWSPortFromBase(basePort int) int

GetWSPortFromBase return the Websocket port from the base port

func SetDefaultRole

func SetDefaultRole(r Role)

SetDefaultRole ..

func SetNetworkType

func SetNetworkType(networkType NetworkType)

SetNetworkType set the networkType

func SetPeerID

func SetPeerID(pid peer.ID)

SetPeerID set the peer ID of the node

func SetShardingSchedule

func SetShardingSchedule(schedule shardingconfig.Schedule)

SetShardingSchedule sets the sharding schedule for all config instances.

func SetVersion

func SetVersion(ver string)

SetVersion set the version of the node binary

Types

type ActionType

type ActionType uint

ActionType lists action on group

const (
	ActionStart ActionType = iota
	ActionPause
	ActionResume
	ActionStop
	ActionUnknown
)

Const of different Action type

func (ActionType) String

func (a ActionType) String() string

type ConfigType

type ConfigType struct {
	ShardID uint32 // ShardID of this node; TODO ek – revisit when resharding

	Port            string              // Port of the node.
	IP              string              // IP of the node.
	RPCServer       RPCServerConfig     // RPC server port and ip
	RosettaServer   RosettaServerConfig // rosetta server port and ip
	IsOffline       bool
	Downloader      bool // Whether stream downloader is running; TODO: remove this after sync up
	NtpServer       string
	StringRole      string
	P2PPriKey       p2p_crypto.PrivKey   `json:"-"`
	ConsensusPriKey multibls.PrivateKeys `json:"-"`
	// Database directory
	DBDir string

	DNSZone string

	WebHooks struct {
		Hooks *webhooks.Hooks
	}
	TraceEnable bool
	// contains filtered or unexported fields
}

ConfigType is the structure of all node related configuration variables

func GetDefaultConfig

func GetDefaultConfig() *ConfigType

GetDefaultConfig returns default config.

func GetShardConfig

func GetShardConfig(shardID uint32) *ConfigType

GetShardConfig return the shard's ConfigType variable

func (*ConfigType) ArchiveModes

func (conf *ConfigType) ArchiveModes() map[uint32]bool

ArchiveModes return the map of the archive setting

func (*ConfigType) GetArchival

func (conf *ConfigType) GetArchival() bool

GetArchival returns archival mode

func (*ConfigType) GetBeaconGroupID

func (conf *ConfigType) GetBeaconGroupID() GroupID

GetBeaconGroupID returns the groupID for beacon group

func (*ConfigType) GetClientGroupID

func (conf *ConfigType) GetClientGroupID() GroupID

GetClientGroupID returns the groupID for client group

func (*ConfigType) GetNetworkType

func (conf *ConfigType) GetNetworkType() NetworkType

GetNetworkType gets the networkType

func (*ConfigType) GetShardGroupID

func (conf *ConfigType) GetShardGroupID() GroupID

GetShardGroupID returns the groupID for shard group

func (*ConfigType) GetShardID

func (conf *ConfigType) GetShardID() uint32

GetShardID returns the shardID.

func (*ConfigType) Role

func (conf *ConfigType) Role() Role

Role returns the role

func (*ConfigType) SetArchival

func (conf *ConfigType) SetArchival(bcArchival, archival bool)

SetArchival set archival mode for beacon chain node, the archival variable will overrdie bcArchival as the shardID is the same

func (*ConfigType) SetBeaconGroupID

func (conf *ConfigType) SetBeaconGroupID(g GroupID)

SetBeaconGroupID set the groupID for beacon group

func (*ConfigType) SetClientGroupID

func (conf *ConfigType) SetClientGroupID(g GroupID)

SetClientGroupID set the groupID for client group

func (*ConfigType) SetRole

func (conf *ConfigType) SetRole(r Role)

SetRole set the role

func (*ConfigType) SetShardGroupID

func (conf *ConfigType) SetShardGroupID(g GroupID)

SetShardGroupID set the groupID for shard group

func (*ConfigType) SetShardID

func (conf *ConfigType) SetShardID(s uint32)

SetShardID set the ShardID

func (*ConfigType) SetShardingSchedule

func (conf *ConfigType) SetShardingSchedule(schedule shardingconfig.Schedule)

SetShardingSchedule sets the sharding schedule for this node config.

func (*ConfigType) ShardIDFromConsensusKey

func (conf *ConfigType) ShardIDFromConsensusKey() (uint32, error)

ShardIDFromConsensusKey returns the shard ID statically determined from the consensus key.

func (*ConfigType) ShardIDFromKey

func (conf *ConfigType) ShardIDFromKey(key *bls_core.PublicKey) (uint32, error)

ShardIDFromKey returns the shard ID statically determined from the input key

func (*ConfigType) ShardingSchedule

func (conf *ConfigType) ShardingSchedule() shardingconfig.Schedule

ShardingSchedule returns the sharding schedule for this node config.

func (*ConfigType) String

func (conf *ConfigType) String() string

func (*ConfigType) ValidateConsensusKeysForSameShard

func (conf *ConfigType) ValidateConsensusKeysForSameShard(pubkeys multibls.PublicKeys, sID uint32) error

ValidateConsensusKeysForSameShard checks if all consensus public keys belong to the same shard

type GroupAction

type GroupAction struct {
	Name   GroupID
	Action ActionType
}

GroupAction specify action on corresponding group

func (GroupAction) String

func (g GroupAction) String() string

type GroupID

type GroupID string

GroupID is a multicast group ID.

It is a binary string, conducive to layering and scoped generation using cryptographic hash.

Applications define their own group ID, without central allocation. A cryptographically secure random string of enough length – 32 bytes for example – may be used.

const (
	GroupIDBeacon            GroupID = "%s/0.0.1/node/beacon"
	GroupIDBeaconClient      GroupID = "%s/0.0.1/client/beacon"
	GroupIDShardPrefix       GroupID = "%s/0.0.1/node/shard/%s"
	GroupIDShardClientPrefix GroupID = "%s/0.0.1/client/shard/%s"
	GroupIDGlobal            GroupID = "%s/0.0.1/node/global"
	GroupIDGlobalClient      GroupID = "%s/0.0.1/node/global"
	GroupIDUnknown           GroupID = "%s/B1acKh0lE"
)

Const of group ID

func NewClientGroupIDByShardID

func NewClientGroupIDByShardID(shardID ShardID) GroupID

NewClientGroupIDByShardID returns a new groupID for a shard's client

func NewGroupIDByShardID

func NewGroupIDByShardID(shardID ShardID) GroupID

NewGroupIDByShardID returns a new groupID for a shard

func (GroupID) String

func (id GroupID) String() string

type NetworkType

type NetworkType string

NetworkType describes the type of Harmony network

func (NetworkType) ChainConfig

func (t NetworkType) ChainConfig() params.ChainConfig

ChainConfig returns the chain configuration for the network type.

type RPCServerConfig

type RPCServerConfig struct {
	HTTPEnabled  bool
	HTTPIp       string
	HTTPPort     int
	HTTPAuthPort int

	WSEnabled  bool
	WSIp       string
	WSPort     int
	WSAuthPort int

	DebugEnabled bool

	EthRPCsEnabled     bool
	StakingRPCsEnabled bool
	LegacyRPCsEnabled  bool

	RpcFilterFile string

	RateLimiterEnabled bool
	RequestsPerSecond  int
}

RPCServerConfig is the config for rpc listen addresses

type Role

type Role byte

Role defines a role of a node.

const (
	Unknown Role = iota
	Validator
	ExplorerNode
)

All constants for different node roles.

func (Role) String

func (role Role) String() string

type RosettaServerConfig

type RosettaServerConfig struct {
	HTTPEnabled bool
	HTTPIp      string
	HTTPPort    int
}

RosettaServerConfig is the config for the rosetta server

type ShardID

type ShardID uint32

ShardID defines the ID of a shard

Jump to

Keyboard shortcuts

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