config

package
v0.0.0-...-0b9d80d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2016 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package config manages persistent configuration data for Chain Core.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadGenerator    = errors.New("generator returned an unsuccessful response")
	ErrBadSignerURL    = errors.New("block signer URL is invalid")
	ErrBadSignerPubkey = errors.New("block signer pubkey is invalid")
	ErrBadQuorum       = errors.New("quorum must be greater than 0 if there are signers")
)

Functions

func Configure

func Configure(ctx context.Context, db pg.DB, c *Config) error

Configure configures the core by writing to the database. If running in a cored process, the caller must ensure that the new configuration is properly reloaded, for example by restarting the process.

If c.IsSigner is true, Configure generates a new mockhsm keypair for signing blocks, and assigns it to c.BlockPub.

If c.IsGenerator is true, Configure creates an initial block, saves it, and assigns its hash to c.BlockchainID. Otherwise, c.IsGenerator is false, and Configure makes a test request to GeneratorURL to detect simple configuration mistakes.

Types

type BlockSigner

type BlockSigner struct {
	AccessToken string             `json:"access_token"`
	Pubkey      chainjson.HexBytes `json:"pubkey"`
	URL         string             `json:"url"`
}

type Config

type Config struct {
	ID                   string  `json:"id"`
	IsSigner             bool    `json:"is_signer"`
	IsGenerator          bool    `json:"is_generator"`
	BlockchainID         bc.Hash `json:"blockchain_id"`
	GeneratorURL         string  `json:"generator_url"`
	GeneratorAccessToken string  `json:"generator_access_token"`
	ConfiguredAt         time.Time
	BlockPub             string        `json:"block_pub"`
	Signers              []BlockSigner `json:"block_signer_urls"`
	Quorum               int
	MaxIssuanceWindow    time.Duration
}

Config encapsulates Core-level, persistent configuration options.

func Load

func Load(ctx context.Context, db pg.DB) (*Config, error)

Load loads the stored configuration, if any, from the database.

Jump to

Keyboard shortcuts

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