helper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: LGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenesisFileName       = "./genesis.json"
	DefaultChainName      = "example"
	DefaultChainID        = 100
	DefaultPremineBalance = "0x3635C9ADC5DEA00000" // 1000 ETH
	DefaultConsensus      = "pow"
	DefaultMaxSlots       = 4096
	GenesisGasUsed        = 458752  // 0x70000
	GenesisGasLimit       = 5242880 // 0x500000
)
View Source
const (
	StatError   = "StatError"
	ExistsError = "ExistsError"
)

Variables

This section is empty.

Functions

func FillPremineMap

func FillPremineMap(
	premineMap map[types.Address]*chain.GenesisAccount,
	premine helperFlags.ArrayFlags,
) error

FillPremineMap fills the premine map for the genesis.json file with passed in balances and accounts

func FormatKV

func FormatKV(in []string) string

FormatKV formats key value pairs:

Key = Value

Key = <none>

func FormatList

func FormatList(in []string) string

FormatList formats a list, using a specific blank value replacement

func GenerateFlagDesc

func GenerateFlagDesc(flagEl string, descriptor FlagDescriptor) string

GenerateFlagDesc generates the flag descriptions in a readable format

func GenerateHelp

func GenerateHelp(synopsys string, usage string, flagMap map[string]FlagDescriptor) string

GenerateHelp is a utility function called by every command's Help() method

func GenerateUsage

func GenerateUsage(baseCommand string, flagMap map[string]FlagDescriptor) string

GenerateUsage is a helper function for generating command usage text

func HandleSignals

func HandleSignals(closeFn func(), ui cli.Ui) int

HandleSignals is a helper method for handling signals sent to the console Like stop, error, etc.

func MergeMaps added in v0.1.0

func MergeMaps(maps ...map[string]interface{}) map[string]interface{}

MergeMaps is a helper method for merging multiple maps. If two or more maps have the same keys, the map that is passed in later will have its key value override the previous same key values

func WriteGenesisToDisk

func WriteGenesisToDisk(chain *chain.Chain, genesisPath string) error

WriteGenesisToDisk writes the passed in configuration to a genesis.json file at the specified path

Types

type Base

type Base struct {
	UI      cli.Ui
	FlagMap map[string]FlagDescriptor
}

Base has common fields for each command

func (*Base) DefineFlags

func (c *Base) DefineFlags(ds ...FlagDefiner)

DefineFlags initializes and defines the common command flags

func (*Base) NewFlagSet

func (m *Base) NewFlagSet(n string, ss ...FlagSetter) *flag.FlagSet

FlagSet initializes Flag Set

type CommandResult

type CommandResult interface {
	// Return result for stdout
	Output() string
}

type Config

type Config struct {
	Chain          string                 `json:"chain_config"`
	Secrets        string                 `json:"secrets_config"`
	DataDir        string                 `json:"data_dir"`
	BlockGasTarget string                 `json:"block_gas_target"`
	GRPCAddr       string                 `json:"grpc_addr"`
	JSONRPCAddr    string                 `json:"jsonrpc_addr"`
	Telemetry      *Telemetry             `json:"telemetry"`
	Network        *Network               `json:"network"`
	Seal           bool                   `json:"seal"`
	TxPool         *TxPool                `json:"tx_pool"`
	LogLevel       string                 `json:"log_level"`
	Dev            bool                   `json:"dev_mode"`
	DevInterval    uint64                 `json:"dev_interval"`
	Join           string                 `json:"join_addr"`
	Consensus      map[string]interface{} `json:"consensus"`
}

Config defines the server configuration params

func BootstrapDevCommand

func BootstrapDevCommand(baseCommand string, args []string) (*Config, error)

BootstrapDevCommand creates a config and generates the dev genesis file

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default server configuration

func ReadConfig

func ReadConfig(baseCommand string, args []string) (*Config, error)

func (*Config) BuildConfig

func (c *Config) BuildConfig() (*server.Config, error)

BuildConfig Builds the config based on set parameters

type FlagDefiner

type FlagDefiner interface {
	DefineFlags(map[string]FlagDescriptor)
}

type FlagDescriptor

type FlagDescriptor struct {
	Description       string   // Flag description
	Arguments         []string // Arguments list
	ArgumentsOptional bool     // Flag indicating if flag arguments are optional
	FlagOptional      bool
}

FlagDescriptor contains the description elements for a command flag

func (*FlagDescriptor) AreArgumentsOptional

func (fd *FlagDescriptor) AreArgumentsOptional() bool

AreArgumentsOptional checks if the flag arguments are optional

func (*FlagDescriptor) GetArgumentsList

func (fd *FlagDescriptor) GetArgumentsList() []string

GetArgumentsList gets the list of arguments for the flag

func (*FlagDescriptor) GetDescription

func (fd *FlagDescriptor) GetDescription() string

GetDescription gets the flag description

func (*FlagDescriptor) IsFlagOptional

func (fd *FlagDescriptor) IsFlagOptional() bool

IsFlagOptional checks if the flag itself is optional

type FlagSetter

type FlagSetter interface {
	FlagSet(*flag.FlagSet)
}

type FormatterFlag

type FormatterFlag struct {
	UI     cli.Ui
	IsJSON bool
}

FormatterFlag is a helper utility for formatter

func (*FormatterFlag) DefineFlags

func (f *FormatterFlag) DefineFlags(flagMap map[string]FlagDescriptor)

DefineFlags sets some flags for json output

func (*FormatterFlag) FlagSet

func (f *FormatterFlag) FlagSet(fs *flag.FlagSet)

FlagSet adds some default commands for json flag

func (*FormatterFlag) OutputError

func (f *FormatterFlag) OutputError(e error)

OutputError is helper function to print output with different format

func (*FormatterFlag) OutputResult

func (f *FormatterFlag) OutputResult(r CommandResult)

OutputResult is helper function to print result with different format

type GRPCFlag

type GRPCFlag struct {
	Addr string
}

GRPCFlag is a helper utility for GRPC flag and provides gRPC connection

func (*GRPCFlag) Conn

func (g *GRPCFlag) Conn() (*grpc.ClientConn, error)

Conn returns a grpc connection

func (*GRPCFlag) DefineFlags

func (g *GRPCFlag) DefineFlags(flagMap map[string]FlagDescriptor)

DefineFlags sets some flags for grpc settings

func (*GRPCFlag) FlagSet

func (m *GRPCFlag) FlagSet(f *flag.FlagSet)

FlagSet adds some default commands to handle grpc connections with the server

type GenesisGenError

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

GenesisGenError is a specific error type for generating genesis

func VerifyGenesisExistence

func VerifyGenesisExistence(genesisPath string) *GenesisGenError

VerifyGenesisExistence checks if the genesis file at the specified path is present

func (*GenesisGenError) GetMessage

func (g *GenesisGenError) GetMessage() string

GetMessage returns the message of the genesis generation error

func (*GenesisGenError) GetType

func (g *GenesisGenError) GetType() string

GetType returns the type of the genesis generation error

type HelpGenerator

type HelpGenerator interface {
	DefineFlags()
}

type Network

type Network struct {
	NoDiscover bool   `json:"no_discover"`
	Addr       string `json:"libp2p_addr"`
	NatAddr    string `json:"nat_addr"`
	Dns        string `json:"dns_addr"`
	MaxPeers   uint64 `json:"max_peers"`
}

Network defines the network configuration params

type Telemetry

type Telemetry struct {
	PrometheusAddr string `json:"prometheus_addr"`
}

Telemetry holds the config details for metric services.

type TxPool

type TxPool struct {
	Locals     string `json:"locals"`
	NoLocals   bool   `json:"no_locals"`
	PriceLimit uint64 `json:"price_limit"`
	MaxSlots   uint64 `json:"max_slots"`
}

TxPool defines the TxPool configuration params

Jump to

Keyboard shortcuts

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