Documentation ¶
Index ¶
- Variables
- func BackgroundColor() tcell.Color
- func CleanAndExpandPath(path, datadir string) string
- func Conf(args []string, tokens Tokens, app *App) int
- func Copy(args []string, tokens Tokens, app *App) int
- func Create(args []string, tokens Tokens, app *App) int
- func Ctl(args []string, tokens Tokens, app *App) int
- func DimColor() tcell.Color
- func EnsureDir(fileName string) bool
- func FileExists(filePath string) bool
- func GUI(args []string, tokens Tokens, app *App) int
- func GenAddr(name string, port int) func(r *Row, in interface{}) bool
- func GenAddrs(name string, port int) func(r *Row, in interface{}) bool
- func GenCA(args []string, tokens Tokens, app *App) int
- func GenCerts(args []string, tokens Tokens, app *App) int
- func Help(args []string, tokens Tokens, app *App) int
- func List(args []string, tokens Tokens, app *App) int
- func MainColor() tcell.Color
- func MakeConfig(c *App) (out *nine.Config)
- func MinUint32(a, b uint32) uint32
- func Mine(args []string, tokens Tokens, app *App) int
- func New(args []string, tokens Tokens, app *App) int
- func Node(args []string, tokens Tokens, app *App) int
- func NormalizeAddress(addr, defaultPort string) string
- func NormalizeAddresses(addrs []string, defaultPort string) []string
- func PrelightColor() tcell.Color
- func RemoveDuplicateAddresses(addrs []string) []string
- func Run(args []string, tokens Tokens, app *App) int
- func Shell(args []string, tokens Tokens, app *App) int
- func Test(args []string, tokens Tokens, app *App) int
- func TestHandler(args []string, tokens Tokens, app *App) int
- func TextColor() tcell.Color
- func UseLogger(logger *cl.SubSystem)
- func Wallet(args []string, tokens Tokens, app *App) int
- type App
- type AppGenerator
- type AppGenerators
- type Cat
- type CatGenerator
- func Addr(name string, defPort int, g ...RowGenerator) CatGenerator
- func Addrs(name string, defPort int, g ...RowGenerator) CatGenerator
- func Algo(name string, g ...RowGenerator) CatGenerator
- func Dir(name string, g ...RowGenerator) CatGenerator
- func Duration(name string, g ...RowGenerator) CatGenerator
- func Enable(name string, g ...RowGenerator) CatGenerator
- func Enabled(name string, g ...RowGenerator) CatGenerator
- func File(name string, g ...RowGenerator) CatGenerator
- func Float(name string, g ...RowGenerator) CatGenerator
- func Int(name string, g ...RowGenerator) CatGenerator
- func Level(g ...RowGenerator) CatGenerator
- func Net(name string, g ...RowGenerator) CatGenerator
- func Port(name string, g ...RowGenerator) CatGenerator
- func Tag(name string, g ...RowGenerator) CatGenerator
- func Tags(name string, g ...RowGenerator) CatGenerator
- type CatGenerators
- type CatJSON
- type Cats
- func (r *Cats) Bool(cat, item string) (out *bool)
- func (r *Cats) Duration(cat, item string) (out *time.Duration)
- func (r *Cats) Float(cat, item string) (out *float64)
- func (r *Cats) GetSortedKeys() (out []string)
- func (r *Cats) Int(cat, item string) (out *int)
- func (r *Cats) Map(cat, item string) (out *nine.Mapstringstring)
- func (r *Cats) Str(cat, item string) (out *string)
- func (r *Cats) Tags(cat, item string) (out *[]string)
- type CatsJSON
- type Command
- type CommandGenerator
- type CommandGenerators
- type CommandHandler
- type Commands
- type Iface
- type Line
- type Optional
- type Precedent
- type Row
- type RowGenerator
- type RowGenerators
- type Token
- type Tokens
Constants ¶
This section is empty.
Variables ¶
var DataDir string = filepath.Dir(util.AppDataDir("9", false))
var Log = cl.NewSubSystem("cmd/config", ll.DEFAULT)
Log is the logger for node
var NetParams = map[string]*nine.Params{ "mainnet": &nine.MainNetParams, "testnet": &nine.TestNet3Params, "simnet": &nine.SimNetParams, "regtestnet": &nine.RegressionNetParams, }
var Networks = []string{"mainnet", "testnet", "simnet", "regtestnet"}
var Valid = struct { File, Dir, Port, Bool, Int, Tag, Tags, Algo, Float, Duration, Net, Level func(*Row, interface{}) bool }{ File: func(r *Row, in interface{}) bool { var s *string switch I := in.(type) { case string: s = &I case *string: s = I default: return false } if len(*s) > 0 { ss := CleanAndExpandPath(*s, *datadir) if r != nil { r.String = fmt.Sprint(ss) if r.Value == nil { r.Value = NewIface() } r.Value.Put(ss) r.App.SaveConfig() return true } else { return false } } return false }, Dir: func(r *Row, in interface{}) bool { var s *string switch I := in.(type) { case string: s = &I case *string: s = I default: return false } if len(*s) > 0 { ss := CleanAndExpandPath(*s, *datadir) if r != nil { r.String = fmt.Sprint(ss) if r.Value == nil { r.Value = NewIface() } r.Value.Put(ss) r.App.SaveConfig() return true } else { return false } } return false }, Port: func(r *Row, in interface{}) bool { var s string var ii int isString := false switch I := in.(type) { case string: s = I isString = true case *string: s = *I isString = true case int: ii = I case *int: ii = *I default: return false } if isString { n, e := strconv.Atoi(s) if e != nil { return false } ii = n } if ii < 1025 || ii > 65535 { return false } if r != nil { r.Value.Put(ii) r.String = fmt.Sprint(ii) r.App.SaveConfig() } return true }, Bool: func(r *Row, in interface{}) bool { var sb string var b bool switch I := in.(type) { case string: sb = I if strings.ToUpper(sb) == "TRUE" { b = true goto boolout } if strings.ToUpper(sb) == "FALSE" { b = false goto boolout } case *string: sb = *I if strings.ToUpper(sb) == "TRUE" { b = true goto boolout } if strings.ToUpper(sb) == "FALSE" { b = false goto boolout } case bool: b = I case *bool: b = *I default: return false } boolout: if r != nil { r.String = fmt.Sprint(b) r.Value.Put(b) r.App.SaveConfig() } return true }, Int: func(r *Row, in interface{}) bool { var s string var ii int isString := false switch I := in.(type) { case string: s = I isString = true case *string: s = *I isString = true case int: ii = I case *int: ii = *I default: return false } if isString { n, e := strconv.Atoi(s) if e != nil { return false } ii = n } if r != nil { r.String = fmt.Sprint(ii) r.Value.Put(ii) r.App.SaveConfig() } return true }, Tag: func(r *Row, in interface{}) bool { var s string switch I := in.(type) { case string: s = I case *string: s = *I default: return false } s = strings.TrimSpace(s) if len(s) < 1 { return false } if r != nil { r.Value.Put(s) r.String = fmt.Sprint(s) r.App.SaveConfig() } return true }, Tags: func(r *Row, in interface{}) bool { var s []string existing, ok := r.Value.Get().([]string) if !ok { existing = []string{} } switch I := in.(type) { case string: s = append(s, I) case *string: s = append(s, *I) case []string: s = I case *[]string: s = *I case []interface{}: for _, x := range I { so, ok := x.(string) if ok { s = append(s, so) } } case nil: return false default: fmt.Println("invalid type", in, reflect.TypeOf(in)) return false } for _, sse := range s { existing = append(existing, sse) } if r != nil { tmpMap := make(map[string]struct{}) for _, x := range existing { tmpMap[x] = struct{}{} } existing = []string{} for i := range tmpMap { existing = append(existing, i) } sort.Strings(existing) r.Value.Put(existing) r.String = fmt.Sprint(existing) r.App.SaveConfig() } return true }, Algo: func(r *Row, in interface{}) bool { var s string switch I := in.(type) { case string: s = I case *string: s = *I default: return false } var o string options := getAlgoOptions() for _, x := range options { if s == x { o = s } } if o == "" { rnd := "random" o = rnd } if r != nil { r.String = fmt.Sprint(o) r.Value.Put(o) r.App.SaveConfig() } return true }, Float: func(r *Row, in interface{}) bool { var s string var f float64 isString := false switch I := in.(type) { case string: s = I isString = true case *string: s = *I isString = true case float64: f = I case *float64: f = *I default: return false } if isString { ff, e := strconv.ParseFloat(s, 64) if e != nil { return false } f = ff } if r != nil { r.Value.Put(f) r.String = fmt.Sprint(f) r.App.SaveConfig() } return true }, Duration: func(r *Row, in interface{}) bool { var s string var t time.Duration isString := false switch I := in.(type) { case string: s = I isString = true case *string: s = *I isString = true case time.Duration: t = I case *time.Duration: t = *I default: return false } if isString { dd, e := time.ParseDuration(s) if e != nil { return false } t = dd } if r != nil { r.String = fmt.Sprint(t) r.Value.Put(t) r.App.SaveConfig() } return true }, Net: func(r *Row, in interface{}) bool { var sn string switch I := in.(type) { case string: sn = I case *string: sn = *I default: return false } found := false for _, x := range Networks { if x == sn { found = true *nine.ActiveNetParams = *NetParams[x] } } if r != nil && found { r.String = fmt.Sprint(sn) r.Value.Put(sn) r.App.SaveConfig() } return found }, Level: func(r *Row, in interface{}) bool { var sl string switch I := in.(type) { case string: sl = I case *string: sl = *I default: return false } found := false for x := range cl.Levels { if x == sl { found = true } } if r != nil && found { r.String = fmt.Sprint(sl) r.Value.Put(sl) r.App.SaveConfig() } return found }, }
Valid is a collection of validator functions for the different types used in a configuration. These functions optionally can accept a *Row and with this they assign the validated, parsed value into the Value slot.
Functions ¶
func BackgroundColor ¶
func CleanAndExpandPath ¶
CleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it.
func EnsureDir ¶
EnsureDir checks a file could be written to a path, creates the directories as needed
func FileExists ¶
FileExists reports whether the named file or directory exists.
func MakeConfig ¶
func MinUint32 ¶
MinUint32 is a helper function to return the minimum of two uint32s. This avoids a math import and the need to cast to floats.
func NormalizeAddress ¶
NormalizeAddress returns addr with the passed default port appended if there is not already a port specified.
func NormalizeAddresses ¶
NormalizeAddresses returns a new slice with all the passed peer addresses normalized with the given default port, and all duplicates removed.
func PrelightColor ¶
func RemoveDuplicateAddresses ¶
RemoveDuplicateAddresses returns a new slice with all duplicate entries in addrs removed.
Types ¶
type App ¶
type App struct { Name string Tagline string About string Version func() string Default func(ctx *App) int Cats Cats Commands Commands Config *nine.Config }
func NewApp ¶
func NewApp(name string, g ...AppGenerator) (out *App)
func (*App) MarshalJSON ¶
func (*App) SaveConfig ¶
func (app *App) SaveConfig()
func (*App) UnmarshalJSON ¶
type AppGenerator ¶
type AppGenerator func(ctx *App)
func About ¶
func About(ver string) AppGenerator
func Cmd ¶
func Cmd(name string, g ...CommandGenerator) AppGenerator
func DefaultRunner ¶
func DefaultRunner(fn func(ctx *App) int) AppGenerator
func Group ¶
func Group(name string, g ...CatGenerator) AppGenerator
func Tagline ¶
func Tagline(ver string) AppGenerator
func Version ¶
func Version(ver string) AppGenerator
type AppGenerators ¶
type AppGenerators []AppGenerator
func (*AppGenerators) RunAll ¶
func (r *AppGenerators) RunAll(app *App)
type Cat ¶
func (Cat) GetSortedKeys ¶
type CatGenerator ¶
type CatGenerator func(ctx *Cat)
func Addr ¶
func Addr(name string, defPort int, g ...RowGenerator) CatGenerator
func Addrs ¶
func Addrs(name string, defPort int, g ...RowGenerator) CatGenerator
func Algo ¶
func Algo(name string, g ...RowGenerator) CatGenerator
func Dir ¶
func Dir(name string, g ...RowGenerator) CatGenerator
func Duration ¶
func Duration(name string, g ...RowGenerator) CatGenerator
func Enable ¶
func Enable(name string, g ...RowGenerator) CatGenerator
func Enabled ¶
func Enabled(name string, g ...RowGenerator) CatGenerator
func File ¶
func File(name string, g ...RowGenerator) CatGenerator
func Float ¶
func Float(name string, g ...RowGenerator) CatGenerator
func Int ¶
func Int(name string, g ...RowGenerator) CatGenerator
func Level ¶
func Level(g ...RowGenerator) CatGenerator
func Net ¶
func Net(name string, g ...RowGenerator) CatGenerator
func Port ¶
func Port(name string, g ...RowGenerator) CatGenerator
func Tag ¶
func Tag(name string, g ...RowGenerator) CatGenerator
func Tags ¶
func Tags(name string, g ...RowGenerator) CatGenerator
type CatGenerators ¶
type CatGenerators []CatGenerator
func (*CatGenerators) RunAll ¶
func (r *CatGenerators) RunAll(cat Cat)
type CatJSON ¶
func (*CatJSON) GetSortedKeys ¶
GetSortedKeys returns the keys of a map in alphabetical order
type Cats ¶
func (*Cats) GetSortedKeys ¶
func (*Cats) Map ¶
func (r *Cats) Map(cat, item string) (out *nine.Mapstringstring)
Map returns the pointer to a value in the category map
type CatsJSON ¶
func (*CatsJSON) GetSortedKeys ¶
type CommandGenerator ¶
type CommandGenerator func(ctx *Command)
func Detail ¶
func Detail(usage string) CommandGenerator
func Opts ¶
func Opts(opts ...string) CommandGenerator
func Pattern ¶
func Pattern(patt string) CommandGenerator
func Precs ¶
func Precs(precs ...string) CommandGenerator
func Short ¶
func Short(usage string) CommandGenerator
type CommandGenerators ¶
type CommandGenerators []CommandGenerator
func (*CommandGenerators) RunAll ¶
func (r *CommandGenerators) RunAll() *Command
type Commands ¶
func (*Commands) GetSortedKeys ¶
type Row ¶
type RowGenerator ¶
type RowGenerator func(ctx *Row)
func Default ¶
func Default(in interface{}) RowGenerator
Default sets the default value for a config item
func Max ¶
func Max(max int) RowGenerator
Max attaches to the validator a test that enforces a maximum
func Min ¶
func Min(min int) RowGenerator
Min attaches to the validator a test that enforces a minimum
func RandomString ¶
func RandomString(n int) RowGenerator
RandomsString generates a random number and converts to base32 for a default random password of some number of characters
func Usage ¶
func Usage(usage string) RowGenerator
Usage populates the usage field for information about a config item
type RowGenerators ¶
type RowGenerators []RowGenerator
func (*RowGenerators) RunAll ¶
func (r *RowGenerators) RunAll(row *Row)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pod is a full-node Parallelcoin implementation written in Go.
|
pod is a full-node Parallelcoin implementation written in Go. |
integration/rpctest
Package rpctest provides a pod-specific RPC testing harness crafting and executing integration tests by driving a `pod` instance via the `RPC` interface.
|
Package rpctest provides a pod-specific RPC testing harness crafting and executing integration tests by driving a `pod` instance via the `RPC` interface. |
mempool
Package mempool provides a policy-enforced pool of unmined bitcoin transactions.
|
Package mempool provides a policy-enforced pool of unmined bitcoin transactions. |