common

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: ISC Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Major uint = 1
	Minor uint = 0
	Patch uint = 1
)

These constants define the application version and follow the semantic versioning 2.0.0 spec (http://semver.org/).

View Source
const (
	CoinBaseVersion = "0.10.3"
)

Variables

View Source
var (
	// PreRelease is defined as a variable so it can be overridden during
	// the build process with '-ldflags "-X github.com/Qitmeer/qitmeer/version.PreRelease=foo"' if
	// needed.  It MUST only contain characters from semanticAlphabet per
	// the semantic versioning spec.
	PreRelease = ""

	// appBuild is defined as a variable so it can be overridden during the
	// build process with '-ldflags "-X github.com/Qitmeer/qitmeer/version.Build=foo"' if needed.  It
	// MUST only contain characters from semanticBuildAlphabet per the
	// semantic versioning spec.
	Build = "dev"
)
View Source
var CurrentHeight = uint64(0)
View Source
var JobID = ""
View Source
var MinerLoger log.Logger

log is a logger that is initialized with no output filters. This means the package will not perform any logging by default until the caller requests it.

Functions

func BlockBitsToTarget

func BlockBitsToTarget(bits string, width int) []byte

func CheckBase58Addr

func CheckBase58Addr(addr, network string, p *params.Params) bool

func ConvertLogLevel

func ConvertLogLevel(level string) l.Lvl

func DiffToTarget

func DiffToTarget(diff float64, powLimit *big.Int, powType pow.PowType) (*big.Int, error)

func FormatHashRate

func FormatHashRate(h float64, unit string) string

FormatHashRate sets the units properly when displaying a hashrate.

func GetCurrentDir

func GetCurrentDir() string

func GetNeedHashTimesByTarget

func GetNeedHashTimesByTarget(target string) *big.Int

func GetVersion

func GetVersion() string

func InArray

func InArray(val interface{}, arr interface{}) bool

func InitNet

func InitNet(network string, p *params.Params) *params.Params

func Int2lehex

func Int2lehex(x int64, width int) string

func Int2varinthex

func Int2varinthex(x int64) string

func RandUint64

func RandUint64() uint64

func Reverse

func Reverse(src []byte) []byte

Reverse reverses a byte array.

func ReverseByWidth

func ReverseByWidth(s []byte, width int) []byte

func String

func String() string

version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/).

func Timeout

func Timeout(fun func(), t int64, callBack func())

func UpdateSysTime

func UpdateSysTime()

func UpdateSystemDate

func UpdateSystemDate(dateTime string) bool

func UseLogger

func UseLogger(logger log.Logger)

UseLogger uses a specified Logger to output package logging info.

func Usleep

func Usleep(sec int)

Types

type CommandConfig

type CommandConfig struct {
	ListDevices bool `short:"l" long:"listdevices" description:"List number of devices."`
	Version     bool `short:"v" long:"version" description:"show the version of miner"`
}

type FileConfig

type FileConfig struct {
	ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
	// Debugging options
	MinerLogFile   string `long:"minerlog" description:"Write miner log file"`
	LogRotatorSize int64  `long:"logrotatorsize" description:"log rotator size"`
}

type GlobalConfig

type GlobalConfig struct {
	OptionConfig    OptionalConfig
	LogConfig       FileConfig
	DeviceConfig    CommandConfig
	SoloConfig      SoloConfig
	PoolConfig      PoolConfig
	NecessaryConfig NecessaryConfig
}

func LoadConfig

func LoadConfig() (*GlobalConfig, []string, error)

loadConfig initializes and parses the config using a config file and command line options.

The configuration proceeds as follows:

  1. Start with a default config with sane settings
  2. Pre-parse the command line to check for an alternative config file
  3. Load configuration file overwriting defaults with any specified options
  4. Parse CLI options and overwrite/add any specified options

The above results in btcd functioning properly without any config settings while still allowing the user to override settings with config files and command line options. Command line options always take precedence.

type NecessaryConfig

type NecessaryConfig struct {
	// Config / log options
	Pow     string `short:"P" long:"pow" description:"blake2bd|cuckaroo|cuckatoo"`
	Symbol  string `short:"S" long:"symbol" description:"Symbol" default-mask:"PMEER"`
	NetWork string `short:"N" long:"network" description:"network privnet|testnet|mainnet" default-mask:"testnet"`
	Param   *params.Params
}

type OptionalConfig

type OptionalConfig struct {
	// Config / log options
	CPUMiner      bool   `long:"cpuminer" description:"CPUMiner" default-mask:"false"`
	CpuWorkers    int    `long:"cpuworkers" description:"CPUWorkers" default-mask:"1"`
	Proxy         string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
	ProxyUser     string `long:"proxyuser" description:"Username for proxy server"`
	ProxyPass     string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
	Timeout       int    `long:"timeout" description:"rpc timeout." default-mask:"60"`
	UseDevices    string `` /* 132-byte string literal not displayed */
	MaxTxCount    int    `long:"max_tx_count" description:"max pack tx count" default-mask:"10000000"`
	MaxSigCount   int    `long:"max_sig_count" description:"max sign tx count" default-mask:"400000000"`
	LogLevel      string `long:"log_level" description:"info|debug|error|warn|trace" default-mask:"info"`
	StatsServer   string `long:"stats_server" description:"stats web server" default-mask:"127.0.0.1:1235"`
	Restart       int    ` description:"restart server" default-mask:"0"`
	Accept        int    ` description:"Accept count" default-mask:"0"`
	Reject        int    ` description:"Reject count" default-mask:"0"`
	Stale         int    ` description:"Stale count" default-mask:"0"`
	Target        string ` description:"Target"`
	NumOfChips    int    `long:"num_of_chips" description:"num of chips" default-mask:"1"`
	TaskInterval  int    `long:"task_interval" description:"get blocktemplate interval" default-mask:"5000"`
	TaskForceStop bool   `` /* 149-byte string literal not displayed */
	ForceSolo     bool   `long:"force_solo" description:"force solo mining" default-mask:"false"`
	Freqs         string `long:"freqs" description:"freq settings" default-mask:"1000,200|"`
	BaseDiff      uint   `long:"base_diff" description:"base_diff settings,default 4G" default-mask:"224"`
	UartPath      string `long:"uart_path" description:"uarts path split with ," default-mask:"/dev/ttyS1"`
}

type PoolConfig

type PoolConfig struct {
	// Pool related options
	Pool         string `short:"o" long:"pool" description:"Pool to connect to (e.g.stratum+tcp://pool:port)"`
	PoolUser     string `short:"m" long:"pooluser" description:"Pool username"`
	PoolTLS      bool   `long:"pooltls" default-mask:"-" description:"Pool tls"`
	SkipTLSCERT  bool   `long:"skiptlscert" default-mask:"-" description:"skip pool tls cert"`
	PoolPassword string `short:"n" long:"poolpass" default-mask:"-" description:"Pool password"`
}

type RpcClient

type RpcClient struct {
	Cfg      *GlobalConfig
	GbtID    int64
	SubmitID int64
}

func (*RpcClient) RpcResult

func (rpc *RpcClient) RpcResult(method string, params []interface{}, id string) []byte

type SoloConfig

type SoloConfig struct {
	// RPC connection options
	MinerAddr        string `short:"M" long:"mineraddress" description:"Miner Address" default-mask:""`
	RPCServer        string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
	RPCUser          string `short:"u" long:"rpcuser" description:"RPC username"`
	RPCPassword      string `short:"p" long:"rpcpass" default-mask:"-" description:"RPC password"`
	RandStr          string `long:"randstr" description:"Rand String,Your Unique Marking." default-mask:""`
	NoTLS            bool   `long:"notls" description:"Do not verify tls certificates" default-mask:"true"`
	RPCCert          string `long:"rpccert" description:"RPC server certificate chain for validation"`
	ConfirmHeight    uint64 `long:"confirmheight" description:"min confirm height" default-mask:"3"`
	NotConfirmHeight uint64 `long:"notconfirmheight" description:"min confirm height" default-mask:"50000000"`
}

Directories

Path Synopsis
Package flags provides an extensive command line option parser.
Package flags provides an extensive command line option parser.
Current limitations:
Current limitations:

Jump to

Keyboard shortcuts

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