nodeconfig

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 8 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"
	Pangaea  = "pangaea"
	Devnet   = "devnet"
	Localnet = "localnet"
)

Constants for NetworkType

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

Variables

This section is empty.

Functions

func AppendPriKey added in v1.2.4

func AppendPriKey(multiKey *MultiBlsPrivateKey, key *bls.SecretKey)

AppendPriKey appends a SecretKey to MultiBlsPrivateKey

func AppendPubKey added in v1.2.4

func AppendPubKey(multiKey *MultiBlsPublicKey, key *bls.PublicKey)

AppendPubKey appends a PublicKey to MultiBlsPublicKey

func GetPublicRPC

func GetPublicRPC() bool

GetPublicRPC get the boolean value of public RPC access

func GetVersion

func GetVersion() string

GetVersion return the version of the node binary

func SetConfigs

func SetConfigs(config ConfigType, shardID uint32) error

SetConfigs set ConfigType in the right index.

func SetNetworkType

func SetNetworkType(networkType NetworkType)

SetNetworkType set the networkType

func SetPublicRPC

func SetPublicRPC(v bool)

SetPublicRPC set the boolean value of public RPC access

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 – reviisit when resharding

	Port string // Port of the node.
	IP   string // IP of the node.

	MetricsFlag     bool   // collect and upload metrics flag
	PushgatewayIP   string // metrics pushgateway prometheus ip
	PushgatewayPort string // metrics pushgateway prometheus port
	StringRole      string
	StakingPriKey   *ecdsa.PrivateKey
	P2pPriKey       p2p_crypto.PrivKey
	ConsensusPriKey *MultiBlsPrivateKey
	ConsensusPubKey *MultiBlsPublicKey

	// Database directory
	DBDir string
	// 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) GetArchival added in v1.2.5

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) GetMetricsFlag

func (conf *ConfigType) GetMetricsFlag() bool

GetMetricsFlag get the metrics flag

func (*ConfigType) GetNetworkType

func (conf *ConfigType) GetNetworkType() NetworkType

GetNetworkType gets the networkType

func (*ConfigType) GetPushgatewayIP

func (conf *ConfigType) GetPushgatewayIP() string

GetPushgatewayIP get the pushgateway ip

func (*ConfigType) GetPushgatewayPort

func (conf *ConfigType) GetPushgatewayPort() string

GetPushgatewayPort get the pushgateway port

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) IsClient

func (conf *ConfigType) IsClient() bool

IsClient returns the isClient configuration

func (*ConfigType) Role

func (conf *ConfigType) Role() Role

Role returns the role

func (*ConfigType) SetArchival added in v1.2.5

func (conf *ConfigType) SetArchival(archival bool)

SetArchival set archival mode

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) SetIsClient

func (conf *ConfigType) SetIsClient(b bool)

SetIsClient set the isClient configuration

func (*ConfigType) SetMetricsFlag

func (conf *ConfigType) SetMetricsFlag(flag bool)

SetMetricsFlag set the metrics flag

func (*ConfigType) SetPushgatewayIP

func (conf *ConfigType) SetPushgatewayIP(ip string)

SetPushgatewayIP set the pushgateway ip

func (*ConfigType) SetPushgatewayPort

func (conf *ConfigType) SetPushgatewayPort(port string)

SetPushgatewayPort set the pushgateway port

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) String

func (conf *ConfigType) String() string

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 MultiBlsPrivateKey added in v1.2.4

type MultiBlsPrivateKey struct {
	PrivateKey []*bls.SecretKey
}

MultiBlsPrivateKey stores the bls secret keys that belongs to the node

func GetMultiBlsPrivateKey added in v1.2.4

func GetMultiBlsPrivateKey(key *bls.SecretKey) *MultiBlsPrivateKey

GetMultiBlsPrivateKey creates a MultiBlsPrivateKey using bls.SecretKey

func (MultiBlsPrivateKey) GetPublicKey added in v1.2.4

func (multiKey MultiBlsPrivateKey) GetPublicKey() *MultiBlsPublicKey

GetPublicKey wrapper

type MultiBlsPublicKey added in v1.2.4

type MultiBlsPublicKey struct {
	PublicKey []*bls.PublicKey
}

MultiBlsPublicKey stores the bls public keys that belongs to the node

func GetMultiBlsPublicKey added in v1.2.4

func GetMultiBlsPublicKey(key *bls.PublicKey) *MultiBlsPublicKey

GetMultiBlsPublicKey creates a MultiBlsPublicKey using bls.PublicKey

func (MultiBlsPublicKey) Contains added in v1.2.4

func (multiKey MultiBlsPublicKey) Contains(pubKey *bls.PublicKey) bool

Contains wrapper

func (*MultiBlsPublicKey) SerializeToHexStr added in v1.2.4

func (multiKey *MultiBlsPublicKey) SerializeToHexStr() string

SerializeToHexStr wrapper

type NetworkType

type NetworkType string

NetworkType describes the type of Harmony network

type Role

type Role byte

Role defines a role of a node.

const (
	Unknown Role = iota
	Validator
	ClientNode
	WalletNode
	ExplorerNode
)

All constants for different node roles.

func (Role) String

func (role Role) String() string

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