Documentation
¶
Index ¶
- Constants
- Variables
- func AppDataDir(appName string, roaming bool) string
- func BlockBitsToTarget(bits string, width int) []byte
- func CheckBase58Addr(addr, network string, p *params.Params) bool
- func ConvertHashToString(hash bitcoinpay.Hash) string
- func ConvertLogLevel(level string) l.Lvl
- func DiffToTarget(diff float64, powLimit *big.Int, powType pow.PowType) (*big.Int, error)
- func FormatHashRate(h float64, unit string) string
- func GetCurrentDir() string
- func GetDevices(t cl.DeviceType, needPlatform string) []*cl.Device
- func GetNeedHashTimesByTarget(target string) *big.Int
- func GetVersion() string
- func HexMustDecode(hexStr string) []byte
- func InArray(val interface{}, arr interface{}) bool
- func InitNet(network string, p *params.Params) *params.Params
- func Int2lehex(x int64, width int) string
- func Int2varinthex(x int64) string
- func RandUint32() (uint32, error)
- func RandUint64() uint64
- func Reverse(src []byte) []byte
- func ReverseByWidth(s []byte, width int) []byte
- func RolloverExtraNonce(v *uint32)
- func SliceContains(s []uint64, e uint64) bool
- func SliceRemove(s []uint64, e uint64) []uint64
- func String() string
- func Target2BlockBits(target string) []byte
- func Timeout(timeout time.Duration, runFunc func()) bool
- func TimeoutRun(timeout time.Duration, runFunc, afterFun func()) bool
- func Uint32EndiannessSwap(v uint32) uint32
- func UseLogger(logger log.Logger)
- func Usleep(sec int)
- type CommandConfig
- type FileConfig
- type GlobalConfig
- type NecessaryConfig
- type OptionalConfig
- type PoolConfig
- type RpcClient
- type SoloConfig
Constants ¶
const ( Major uint = 0 Minor uint = 5 Patch uint = 0 )
These constants define the application version and follow the semantic versioning 2.0.0 spec (http://semver.org/).
Variables ¶
var ( // PreRelease is defined as a variable so it can be overridden during // the build process with '-ldflags "-X github.com/btceasypay/bitcoinpay/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/btceasypay/bitcoinpay/version.Build=foo"' if needed. It // MUST only contain characters from semanticBuildAlphabet per the // semantic versioning spec. Build = "dev" )
var CurrentHeight = uint64(0)
var DevicesTypesForCPUMining = cl.DeviceTypeCPU
var DevicesTypesForGPUMining = cl.DeviceTypeGPU
var JobID = ""
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 AppDataDir ¶
AppDataDir returns an operating system specific directory to be used for storing application data for an application.
The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice. An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.
The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default.
Example results:
dir := AppDataDir("myapp", false) POSIX (Linux/BSD): ~/.myapp Mac OS: $HOME/Library/Application Support/Myapp Windows: %LOCALAPPDATA%\Myapp Plan 9: $home/myapp
func BlockBitsToTarget ¶
func ConvertHashToString ¶
func ConvertHashToString(hash bitcoinpay.Hash) string
func ConvertLogLevel ¶
func DiffToTarget ¶
func FormatHashRate ¶
FormatHashRate sets the units properly when displaying a hashrate.
func GetCurrentDir ¶
func GetCurrentDir() string
func GetDevices ¶
func GetDevices(t cl.DeviceType, needPlatform string) []*cl.Device
func GetVersion ¶
func GetVersion() string
func HexMustDecode ¶
func Int2varinthex ¶
func RandUint32 ¶
func RandUint64 ¶
func RandUint64() uint64
func ReverseByWidth ¶
func RolloverExtraNonce ¶
func RolloverExtraNonce(v *uint32)
RolloverExtraNonce rolls over the extraNonce if it goes over 0x00FFFFFF many hashes, since the first byte is reserved for the ID.
func SliceContains ¶
func SliceRemove ¶
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 Target2BlockBits ¶
func TimeoutRun ¶
func Uint32EndiannessSwap ¶
Uint32EndiannessSwap swaps the endianness of a uint32.
Types ¶
type CommandConfig ¶
type FileConfig ¶
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:
- Start with a default config with sane settings
- Pre-parse the command line to check for an alternative config file
- Load configuration file overwriting defaults with any specified options
- 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:"BTP"` 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"` 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"` TrimmerCount int `long:"trimmerTimes" description:"the cuckaroo trimmer times"` Intensity int `` /* 132-byte string literal not displayed */ WorkSize int `` /* 158-byte string literal not displayed */ Timeout int `long:"timeout" description:"rpc timeout." default-mask:"60"` UseDevices string `` /* 135-byte string literal not displayed */ MaxTxCount int `long:"max_tx_count" description:"max pack tx count" default-mask:"1000"` MaxSigCount int `long:"max_sig_count" description:"max sign tx count" default-mask:"4000"` 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"` EdgeBits int `long:"edge_bits" description:"edge bits" default-mask:"24"` LocalSize int `long:"local_size" description:"local size" default-mask:"4096"` GroupSize int `long:"group_size" description:"work group size" default-mask:"256"` Cuda bool `long:"cuda" description:"is cuda" default-mask:"false"` TaskInterval int `long:"task_interval" description:"get blocktemplate interval" default-mask:"2"` TaskForceStop bool `` /* 152-byte string literal not displayed */ MiningSyncMode bool `long:"mining_sync_mode" description:"force stop the current task when new task come." default-mask:"true"` ForceSolo bool `long:"force_solo" description:"force solo mining" default-mask:"false"` BigGraphStartHeight int `` /* 139-byte string literal not displayed */ Expand int `long:"expand" description:"expand enum 0,1,2" default-mask:"0"` Ntrims int `long:"ntrims" description:"trim times " default-mask:"50"` Genablocks int `long:"genablocks" description:"genablocks" default-mask:"4096"` Genatpb int `long:"genatpb" description:"genatpb" default-mask:"256"` Genbtpb int `long:"genbtpb" description:"genbtpb" default-mask:"256"` Trimtpb int `long:"trimtpb" description:"genbtpb" default-mask:"64"` Tailtpb int `long:"tailtpb" description:"tailtpb" default-mask:"1024"` Recoverblocks int `long:"recoverblocks" description:"recoverblocks" default-mask:"1024"` Recovertpb int `long:"recovertpb" description:"recovertpb" default-mask:"1024"` }
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"` PoolPassword string `short:"n" long:"poolpass" default-mask:"-" description:"Pool password"` }
type RpcClient ¶
type RpcClient struct {
Cfg *GlobalConfig
}
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:"Come from Bitcoinpay!"` NoTLS bool `long:"notls" description:"Do not verify tls certificates" default-mask:"true"` RPCCert string `long:"rpccert" description:"RPC server certificate chain for validation"` }