config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//MaxPoolSize is them aximum size of the transactionpool
	MaxPoolSize             uint = 2e7
	TransactionSetSizeLimit uint = 250e3
	TransactionSizeLimit    uint = 16e3
	ActualPoolSize               = uint64(MaxPoolSize - TransactionSetSizeLimit)
)

Variables

View Source
var (
	// ErrUnsupportedFileType is returned in case generation of a config is requested for
	// an unsupported file type
	ErrUnsupportedFileType = errors.New("file type not supported")
)

Functions

func GenerateBlockchain

func GenerateBlockchain(configFilePath, outputDir string, opts *BlockchainGenerationOpts) error

GenerateBlockchain imports a config file and uses it to generate a blockchain

func GenerateConfigFile

func GenerateConfigFile(filepath string, opts *ConfigGenerationOpts) error

GenerateConfigFile generates a blockchain config file

Types

type Authcoin

type Authcoin struct {
	AddressUpdate   Version `json:"addressUpdate" yaml:"addressUpdate" validate:"required"`
	ConditionUpdate Version `json:"conditionUpdate" yaml:"conditionUpdate" validate:"required"`
}

type Binaries

type Binaries struct {
	Client string `json:"client,omitempty" yaml:"client,omitempty"`
	Daemon string `json:"daemon,omitempty" yaml:"daemon,omitempty"`
}

type Blockchain

type Blockchain struct {
	Name         string              `json:"name" yaml:"name" validate:"required"`
	LongName     string              `json:"longName,omitempty" yaml:"longName,omitempty"`
	Version      string              `json:"version,omitempty" yaml:"version,omitempty"`
	Repository   string              `json:"repository" yaml:"repository" validate:"required"`
	Currency     *Currency           `json:"currency" yaml:"currency" validate:"required"`
	Ports        *Ports              `json:"ports" yaml:"ports" validate:"required"`
	Binaries     *Binaries           `json:"binaries,omitempty" yaml:"binaries,omitempty"`
	Transactions *Transactions       `json:"transactions,omitempty" yaml:"transactions,omitempty"`
	Networks     map[string]*Network `json:"networks,omitempty" yaml:"networks,omitempty" validate:"gt=0,dive,required"`
}

type BlockchainGenerationOpts

type BlockchainGenerationOpts struct {
	FrontendExplorerType FrontendExplorerType
	FrontendFaucet       bool
}

type BootstrapPeer

type BootstrapPeer struct {
	modules.NetAddress
}

func (BootstrapPeer) MarshalText

func (bp BootstrapPeer) MarshalText() ([]byte, error)

MarshalText will marshall JSON/YAML BootstrapPeer type

func (*BootstrapPeer) UnmarshalText

func (bp *BootstrapPeer) UnmarshalText(text []byte) error

UnmarshalText will unMarshall JSON/YAML BootstrapPeer type

type Caddy

type Caddy struct {
	DNS string `json:"dns" yaml:"dns" validate:"required"`
	TLS string `json:"tls" yaml:"tls" validate:"required"`
}

type Condition

type Condition struct {
	types.UnlockConditionProxy
}

func NewMultisigCondition

func NewMultisigCondition(minSignatureCount uint64, uhs ...types.UnlockHash) Condition

func (Condition) MarshalJSON

func (c Condition) MarshalJSON() ([]byte, error)

func (Condition) MarshalYAML

func (c Condition) MarshalYAML() (interface{}, error)

MarshalYAML will marshal the condition type into our specific format

func (*Condition) UnmarshalJSON

func (c *Condition) UnmarshalJSON(data []byte) error

func (*Condition) UnmarshalYAML

func (c *Condition) UnmarshalYAML(unmarshal func(v interface{}) error) error

type Config

type Config struct {
	Template   Template    `json:"template,omitempty" yaml:"template,omitempty"`
	Frontend   *Frontend   `json:"frontend,omitempty" yaml:"frontend,omitempty"`
	Generation *Generation `json:"generation,omitempty" yaml:"generation,omitempty"`
	Blockchain *Blockchain `json:"blockchain" yaml:"blockchain" validate:"required"`
}

func BuildConfigStruct

func BuildConfigStruct(filePath string, opts *ConfigGenerationOpts) *Config

BuildConfigStruct builds to default values in our config struct

func ImportAndValidateConfig

func ImportAndValidateConfig(configFilePath string) (*Config, error)

ImportAndValidateConfig imports a config file and validates it

type ConfigGenerationOpts

type ConfigGenerationOpts struct {
	PluginMintingEnabled  bool
	PluginAuthcoinEnabled bool
}

type Currency

type Currency struct {
	Unit      string `json:"unit" yaml:"unit" validate:"required"`
	Precision uint64 `json:"precision" yaml:"precision" validate:"required"`
}

type Explorer

type Explorer struct {
	Caddy `json:"caddy,omitempty" yaml:"caddy,omitempty"`
}

type Faucet

type Faucet struct {
	Caddy `json:"caddy,omitempty" yaml:"caddy,omitempty"`
}

type Fraction

type Fraction struct {
	Denominator, Numerator int64
}

Fraction represents ratio.

func (Fraction) MarshalText

func (f Fraction) MarshalText() ([]byte, error)

MarshalText will marshall JSON/YAML fraction type

func (*Fraction) UnmarshalText

func (f *Fraction) UnmarshalText(text []byte) error

UnmarshalText will unMarshall JSON/YAML fraction type

type Frontend

type Frontend struct {
	Explorer *Explorer `json:"explorer,omitempty" yaml:"explorer,omitempty"`
	Faucet   *Faucet   `json:"faucet,omitempty" yaml:"faucet,omitempty"`
}

type FrontendExplorerType

type FrontendExplorerType uint8

FrontendExplorerType defines the type of explorer to be generated

func (*FrontendExplorerType) FromString

func (et *FrontendExplorerType) FromString(str string) error

FromString tries to parse the passed string in to a valid FrontendExplorerType and returns an error if it is not recognized

func (FrontendExplorerType) String

func (et FrontendExplorerType) String() string

type Generation

type Generation struct {
	Ignore              []GlobPattern `json:"ignore" yaml:"ignore" validate:"required"`
	DisableGoFormatting bool          `json:"disableGoFormatting,omitempty" yaml:"disableGoFormatting,omitempty"`
}

type Genesis

type Genesis struct {
	CoinOutputs           []Output   `json:"coinOuputs" yaml:"coinOutputs" validate:"required"`
	BlockStakeOutputs     []Output   `json:"blockStakeOutputs" yaml:"blockStakeOutputs" validate:"required"`
	Minting               *Condition `json:"minting,omitempty" yaml:"minting,omitempty"`
	Authcoin              *Condition `json:"authcoin,omitempty" yaml:"authcoin,omitempty"`
	GenesisBlockTimestamp int64      `json:"genesisBlockTimestamp" yaml:"genesisBlockTimestamp" validate:"required"`
}

type GlobPattern

type GlobPattern struct {
	// contains filtered or unexported fields
}

func (GlobPattern) MarshalText

func (gp GlobPattern) MarshalText() ([]byte, error)

func (GlobPattern) Match

func (gp GlobPattern) Match(str string) bool

func (*GlobPattern) UnmarshalText

func (gp *GlobPattern) UnmarshalText(text []byte) error

type Minting

type Minting struct {
	ConditionUpdate  Version  `json:"conditionUpdate" yaml:"conditionUpdate" validate:"required"`
	CoinCreation     Version  `json:"coinCreation" yaml:"coinCreation" validate:"required"`
	CoinDestruction  *Version `json:"coinDestruction,omitempty" yaml:"coinDestruction,omitempty"`
	RequireMinerFees bool     `json:"requireMinerFees,omitempty" yaml:"requireMinerFees,omitempty"`
}

type Network

type Network struct {
	NetworkType            NetworkType      `json:"networkType" yaml:"networkType" validate:"required"`
	Genesis                *Genesis         `json:"genesis" yaml:"genesis" validate:"required"`
	TransactionFeePool     string           `json:"transactionFeePool,omitempty" yaml:"transactionFeePool,omitempty"`
	BlockSizeLimit         uint64           `json:"blockSizeLimit,omitempty" yaml:"blockSizeLimit,omitempty"`
	ArbitraryDataSizeLimit uint64           `json:"arbitraryDataSizeLimit,omitempty" yaml:"arbitraryDataSizeLimit,omitempty"`
	BlockCreatorFee        string           `json:"blockCreatorFee,omitempty" yaml:"blockCreatorFee,omitempty"`
	MinimumTransactionFee  string           `json:"minimumTransactionFee,omitempty" yaml:"minimumTransactionFee,omitempty"`
	BlockFrequency         uint64           `json:"blockFrequency,omitempty" yaml:"blockFrequency,omitempty"`
	MaturityDelay          uint64           `json:"maturityDelay,omitempty" yaml:"maturityDelay,omitempty"`
	MedianTimestampWindow  uint64           `json:"medianTimestampWindow,omitempty" yaml:"medianTimestampWindow,omitempty"`
	TargetWindow           uint64           `json:"targetWindow,omitempty" yaml:"targetWindow,omitempty"`
	MaxAdjustmentUp        Fraction         `json:"maxAdjustmentUp,omitempty" yaml:"maxAdjustmentUp,omitempty"`
	MaxAdjustmentDown      Fraction         `json:"maxAdjustmentDown,omitempty" yaml:"maxAdjustmentDown,omitempty"`
	FutureThreshold        uint64           `json:"futureTreshold,omitempty" yaml:"futureTreshold,omitempty"`
	ExtremeFutureThreshold uint64           `json:"extremeFutureTreshold,omitempty" yaml:"extremeFutureTreshold,omitempty"`
	StakeModifierDelay     uint64           `json:"stakeModifierDelay,omitempty" yaml:"stakeModifierDelay,omitempty"`
	BlockStakeAging        uint64           `json:"blockStakeAging,omitempty" yaml:"blockStakeAging,omitempty"`
	TransactionPool        TransactionPool  `json:"transactionPool,omitempty" yaml:"transactionPool,omitempty"`
	BootstrapPeers         []*BootstrapPeer `json:"bootstrapPeers" yaml:"bootstrapPeers" validate:"required"`
}

type NetworkType

type NetworkType int

NetworkType is the type of the network

const (
	NetworkTypeStandard NetworkType = iota + 1
	NetworkTypeTestnet
	NetworkTypeDevnet
)

NetworkType start with 1 because 0 breaks tests and serialization

type Output

type Output struct {
	Value     string    `json:"value" yaml:"value" validate:"required"`
	Condition Condition `json:"condition" yaml:"condition" validate:"required"`
}

type Ports

type Ports struct {
	API uint16 `json:"api,omitempty" yaml:"api,omitempty" validate:"nefield=RPC"`
	RPC uint16 `json:"rpc,omitempty" yaml:"rpc,omitempty" validate:"nefield=API"`
}

type Template

type Template struct {
	Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`
	Version    string `json:"version,omitempty" yaml:"version,omitempty"`
}

type TemplateConfig

type TemplateConfig struct {
	Frontend TemplateFrontendConfig `json:"frontend" validate:"required"`
}

type TemplateFrontendConfig

type TemplateFrontendConfig struct {
	Explorer map[string]TemplateFrontendTypeConfig `json:"explorer" validate:"required"`
	Faucet   map[string]TemplateFrontendTypeConfig `json:"Faucet" validate:"required"`
}

type TemplateFrontendTypeConfig

type TemplateFrontendTypeConfig struct {
	Repository string `json:"repo" validate:"required"`
	Branch     string `json:"branch" validate:"required"`
}

type TransactionPool

type TransactionPool struct {
	TransactionSizeLimit    uint   `json:"transactionSizeLimit" yaml:"transactionSizeLimit"`
	TransactionSetSizeLimit uint   `json:"transactionSetSizeLimit" yaml:"transactionSetSizeLimit"`
	PoolSizeLimit           uint64 `json:"poolSizeLimit" yaml:"poolSizeLimit"`
}

type Transactions

type Transactions struct {
	Default  *Version  `json:"default,omitempty" yaml:"default,omitempty"`
	Minting  *Minting  `json:"minting,omitempty" yaml:"minting,omitempty"`
	Authcoin *Authcoin `json:"authcoin,omitempty" yaml:"authcoin,omitempty"`
}

type UnlockHash

type UnlockHash struct {
	types.UnlockHash
}

func (UnlockHash) MarshalText

func (u UnlockHash) MarshalText() ([]byte, error)

MarshalText will marshall JSON/YAML UnlockHash type

func (*UnlockHash) UnmarshalText

func (u *UnlockHash) UnmarshalText(text []byte) error

UnmarshalText will unMarshall JSON/YAML UnlockHash type

type Version

type Version struct {
	Version uint64 `json:"version" yaml:"version" validate:"required"`
}

Jump to

Keyboard shortcuts

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