config

package
v0.0.0-...-8220f0d Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 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 Contract

type Contract struct {
	Name           string
	Procedures     []string
	Addr           string
	HealthCheckURL string
}

type Contracts

type Contracts struct {
	DockerContracts      []DockerContract `yaml:"contracts.docker"`
	Contracts            []Contract       `yaml:"contracts"`
	DockerMinimalVersion string           `yaml:"docker.minimalversion"`
}

Contracts represent the global configuration for the contracts

func LoadContracts

func LoadContracts(path string) (*Contracts, error)

LoadContracts will read the YAML file at the given path and return the corresponding Contracts config.

type DockerContract

type DockerContract struct {
	Name           string
	Procedures     []string
	Image          string
	Addr           string
	Port           string
	HostPort       string
	HealthCheckURL string
}

DockerContract represent the configuration for a contract running inside a docker container

type HTTP

type HTTP struct {
	Enabled bool
	Port    int `yaml:"port,omitempty"`
}

HTTP represents the configuration for the REST HTTP API exposed by a node.

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"`
	Shard      *Shard
}

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"`
	Contracts   *NodeContracts `yaml:"contracts"`
	DisableSBAC bool           `yaml:"disable.sbac,omitempty"`
	HTTP        HTTP           `yaml:"http,omitempty"`
	Logging     *Logging       `yaml:"logging"`
	Pubsub      *Pubsub        `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 NodeContracts

type NodeContracts struct {
	Docker bool `yaml:"docker"`
	Manage bool `yaml:"manage"`
}

Contracts represents the configuration for the contracts.

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 Pubsub

type Pubsub struct {
	Enabled bool `yaml:"enabled"`
	// if not specified choose random port and announce with mdns
	Port *int `yaml:"port,omitempty"`
}

Pubsub represent the configuration for the pub sub system

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 Shard

type Shard struct {
	Count int
	Size  int
}

Shard represents the configuration of the sharding system within a given Chainspace network.

type Storage

type Storage struct {
	Type string
}

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

Jump to

Keyboard shortcuts

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