config

package
v0.0.0-...-782863c Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB
)

Constants representing various SI multiples for bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Announce

type Announce struct {
	MDNS     bool `yaml:"mdns,omitempty"`
	Registry bool `yaml:"registry,omitempty"`
}

Announce represents the configuration for announcing address to peers.

type Bootstrap

type Bootstrap struct {
	File     string            `yaml:",omitempty"`
	MDNS     bool              `yaml:",omitempty"`
	Registry bool              `yaml:",omitempty"`
	Static   map[uint64]string `yaml:",omitempty"`
}

Bootstrap represents the configuration for bootstrapping peer addresses.

type Broadcast

type Broadcast struct {
	InitialBackoff time.Duration `yaml:"initial.backoff"`
	MaxBackoff     time.Duration `yaml:"max.backoff"`
}

Broadcast represents the configuration for maintaining the shard broadcast by a node.

type ByteSize

type ByteSize uint64

ByteSize provides a YAML-serializable format for byte size definitions.

func (ByteSize) Int

func (b ByteSize) Int() (int, error)

Int returns the ByteSize value as an int as long as it'd fit within the system's int limits.

func (ByteSize) MarshalYAML

func (b ByteSize) MarshalYAML() (interface{}, error)

MarshalYAML implements the YAML encoding interface.

func (*ByteSize) UnmarshalYAML

func (b *ByteSize) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the YAML decoding interface.

type Connections

type Connections struct {
	ReadTimeout  time.Duration `yaml:"read.timeout"`
	WriteTimeout time.Duration `yaml:"write.timeout"`
}

Connections represents the configuration for network connections. MaxPayload when used as part of the Network.NodeConnections configuration, also implicitly defines the maximum size of blocks.

type Key

type Key struct {
	Type    string
	Public  string
	Private string `yaml:",omitempty"`
}

Key represents a cryptographic key of some kind.

type Keys

type Keys struct {
	SigningKey    *Key `yaml:"signing.key"`
	TransportCert *Key `yaml:"transport.cert"`
}

Keys represents the configuration that individual nodes use for their various cryptographic keys.

func LoadKeys

func LoadKeys(path string) (*Keys, error)

LoadKeys will read the YAML file at the given path and return the corresponding Keys config.

type Logging

type Logging struct {
	ConsoleLevel log.Level `yaml:"console.level,omitempty"`
	FileLevel    log.Level `yaml:"file.level,omitempty"`
	FilePath     string    `yaml:"file.path,omitempty"`
	ServerHost   string    `yaml:"server.host,omitempty"`
	ServerLevel  log.Level `yaml:"server.level,omitempty"`
	ServerToken  string    `yaml:"server.token,omitempty"`
}

Logging represents the logging configuration for individual nodes.

type NetConsensus

type NetConsensus struct {
	BlockReferencesSizeLimit   ByteSize      `yaml:"block.references.size.limit"`
	BlockTransactionsSizeLimit ByteSize      `yaml:"block.transactions.size.limit"`
	NonceExpiration            time.Duration `yaml:"nonce.expiration"`
	RoundInterval              time.Duration `yaml:"round.interval"`
	ViewTimeout                int           `yaml:"view.timeout"`
}

NetConsensus represents the network-wide configuration for the consensus protocol.

type Network

type Network struct {
	ID         string           `yaml:",omitempty"`
	Consensus  *NetConsensus    `yaml:"consensus"`
	MaxPayload ByteSize         `yaml:"max.payload"`
	SeedNodes  map[uint64]*Peer `yaml:"seed.nodes"`
}

Network represents the configuration of a Chainspace network as a whole.

func LoadNetwork

func LoadNetwork(path string) (*Network, error)

LoadNetwork will read the YAML file at the given path and return the corresponding Network config.

func (*Network) Hash

func (n *Network) Hash() ([]byte, error)

Hash returns the SHA-512/256 hash of the network's seed configuration by first encoding it into YAML. The returned hash should then be used as the ID for the network.

type Node

type Node struct {
	Announce    *Announce      `yaml:"announce,omitempty"`
	Bootstrap   *Bootstrap     `yaml:"bootstrap"`
	Broadcast   *Broadcast     `yaml:"broadcast"`
	Connections *Connections   `yaml:"connections"`
	Consensus   *NodeConsensus `yaml:"consensus"`
	HTTP        ServiceEnable  `yaml:"http,omitempty"`
	Logging     *Logging       `yaml:"logging"`
	Pubsub      ServiceEnable  `yaml:"pubsub"`
	Registries  []Registry     `yaml:"registries,omitempty"`
	Storage     *Storage       `yaml:"storage"`
}

Node represents the configuration of an individual node in a Chainspace network.

func LoadNode

func LoadNode(path string) (*Node, error)

LoadNode will read the YAML file at the given path and return the corresponding Node config.

type NodeConsensus

type NodeConsensus struct {
	DriftTolerance      time.Duration `yaml:"drift.tolerance"`
	InitialWorkDuration time.Duration `yaml:"initial.work.duration"`
	RateLimit           *RateLimit    `yaml:"rate.limit"`
}

NodeConsensus represents the node-specific configuration for the consensus protocol.

type Peer

type Peer struct {
	SigningKey    *PeerKey `yaml:"signing.key"`
	TransportCert *PeerKey `yaml:"transport.cert"`
}

Peer represents the cryptographic public keys of a node in a Chainspace network.

type PeerKey

type PeerKey struct {
	Type  string
	Value string
}

PeerKey represents a cryptographic public key of some kind.

type RateLimit

type RateLimit struct {
	InitialRate  int     `yaml:"initial.rate"`
	RateDecrease float64 `yaml:"rate.decrease"`
	RateIncrease int     `yaml:"rate.increase"`
}

RateLimit represents the configuration for rate-limiting within the system.

type Registry

type Registry struct {
	Host  string
	Token string
}

Registry represents the configuration of an individual network registry server.

func (Registry) URL

func (r Registry) URL() string

URL returns the registry's root URL including the scheme.

type ServiceEnable

type ServiceEnable struct {
	Enabled bool
	Port    uint `yaml:"port,omitempty"`
}

type Storage

type Storage struct {
	Type string
}

Storage represents the configuration for a node's underlying storage mechanism.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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