miner

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Copyright © 2021 Levi Noecker <levi.noecker@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2021 Levi Noecker <levi.noecker@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	JOINOK     = "JOINOK"
	PASSFAILED = "PASSFAILED"
	PAYMENTOK  = "PAYMENTOK"
	PONG       = "PONG"
	POOLSTEPS  = "POOLSTEPS"
	STATUS     = "STATUS"
	STEPOK     = "STEPOK"
	STEPFAIL   = "STEPFAIL"
)
View Source
const CSVHEADER = "Transaction Time,Pool IP Address,Wallet Address,Request Or Response,Block,Payment Amount,Order Id\n"
View Source
const (
	HEADER = `` /* 229-byte string literal not displayed */

)

Variables

View Source
var (
	Commit    = "0000000"
	Version   = "v0.0.0"
	MinerName = fmt.Sprintf("ng%s", Version[1:])
)

Functions

func BytesToString

func BytesToString(bytes []byte) string

func CreateLogPaymentsFile

func CreateLogPaymentsFile()

func GetPoolStatus

func GetPoolStatus(opts *Opts)

func JobFeeder

func JobFeeder(comms *Comms, jobComms *JobComms)

func LogPaymentReq

func LogPaymentReq(poolIp string, wallet string, block int, amount string)

func LogPaymentResp

func LogPaymentResp(paymentMsg []string, poolIp string)

func Mine

func Mine(opts *Opts)

func Miner

func Miner(workerNum string, comms *Comms, ready chan bool)

func NewManagerComms

func NewManagerComms() *managerComms

func Parse

func Parse(comms *Comms, poolIp string, wallet string, block int, resp string)

func SolutionManager

func SolutionManager(solComms *SolutionComms, showPop bool)

Types

type Comms

type Comms struct {
	PoolAddr          chan string
	MinerSeed         chan string
	TargetString      chan string
	TargetChars       chan int
	Block             chan int
	Step              chan int
	Diff              chan int
	PoolDepth         chan int
	Balance           chan string
	PoolHashRate      chan string
	BlocksTillPayment chan int
	StepSolved        chan int
	StepFailed        chan int
	HashRate          chan int
	Jobs              chan Job
	Reports           chan Report
	Solutions         chan Solution
	Joined            chan struct{}
	Pong              chan struct{}
	PoolStatus        chan PoolStatus
	Disconnected      chan struct{}
}

func NewComms

func NewComms() *Comms

type Job

type Job struct {
	PoolAddr      string
	SeedMiner     string
	SeedPostfix   string
	SeedFull      string
	SeedFullBytes []byte
	TargetString  string
	TargetChars   int
	Diff          int
	Block         int
	Step          int
	PoolDepth     int
}

type JobComms

type JobComms struct {
	PoolAddr     chan string
	MinerSeed    chan string
	Block        chan int
	Step         chan int
	Diff         chan int
	TargetChars  chan int
	TargetString chan string
	PoolDepth    chan int
}

func NewJobComms

func NewJobComms() *JobComms

type MinerInfo

type MinerInfo struct {
	Address           string
	Balance           string
	BalanceHR         string
	BlocksTillPayment string
}

type Opts

type Opts struct {
	Cpu            int
	IpAddr         string
	IpPort         int
	PoolPw         string
	Wallets        []string
	CurrentWallet  string
	ShowPop        bool
	StatusInterval int
	ExitOnRetry    bool
}

type PoolStatus

type PoolStatus struct {
	HashRateRaw string
	HashRate    string
	FeeRaw      int
	Fee         string
	ShareRaw    int
	Share       string
	MinerCnt    string
	Miners      []MinerInfo
}

func NewPoolStatus

func NewPoolStatus(s []string) PoolStatus

s[] -> STATUS {hashrate} {fee} {share} {minerCount} [list of miners: {address}:{balance}:{blocks_until_paymet}]

func (*PoolStatus) PrettyPrint

func (p *PoolStatus) PrettyPrint()

type Report

type Report struct {
	WorkerNum string
	Hashes    int
	Duration  time.Duration
}

type Solution

type Solution struct {
	Seed       string
	HashStr    string
	Block      int
	Chars      int
	Step       int
	SolvedHash string
	TargetLen  int
	Target     string
	FullTarget string
}

type SolutionComms

type SolutionComms struct {
	Block    chan int
	Step     chan int
	Diff     chan int
	Solution chan Solution
	SendChan chan string
	StepSent chan struct{}
}

func NewSolutionComms

func NewSolutionComms(sendChan chan string) *SolutionComms

type TcpClient

type TcpClient struct {
	SendChan chan string
	RecvChan chan string
	// contains filtered or unexported fields
}

func NewTcpClient

func NewTcpClient(opts *Opts, comms *Comms, showLogs, join bool) *TcpClient

func (*TcpClient) SetAuth added in v1.6.0

func (t *TcpClient) SetAuth()

Jump to

Keyboard shortcuts

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