pow

package
v0.0.0-...-7d63ed4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKernelSource

func GenKernelSource() string

burn a #define into the top of the kernel if you pass this in a as kernel parameter, the compiler can't unroll loops as effectively

func GetOpenCLGPUs

func GetOpenCLGPUs() ([]*cl.Device, error)

Types

type Backend

type Backend struct {
	Hasher
	TotalHashes      uint64
	HashSincePrint   uint64
	HashRateEstimate float64
}

type CpuMiner

type CpuMiner int64

func NewCpuMiner

func NewCpuMiner(id int64) *CpuMiner

func (*CpuMiner) CheckRange

func (c *CpuMiner) CheckRange(hash *HashSettings, start uint64, n uint64) (string, uint64, error)

func (*CpuMiner) Name

func (c *CpuMiner) Name() string

func (*CpuMiner) StepSize

func (c *CpuMiner) StepSize() uint64

type GpuMiner

type GpuMiner struct {
	config.GPUConfig
	// contains filtered or unexported fields
}

func NewGpuMiner

func NewGpuMiner(device *cl.Device, config *config.GPUConfig, poolEnabled bool) (*GpuMiner, error)

prepare an openCL device for work

func (*GpuMiner) CheckRange

func (g *GpuMiner) CheckRange(hash *HashSettings, start uint64, n uint64) (string, uint64, error)

func (*GpuMiner) Name

func (g *GpuMiner) Name() string

func (*GpuMiner) StepSize

func (g *GpuMiner) StepSize() uint64

number of hashes this backend checks at a time

type HashSettings

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

func NewHashSettings

func NewHashSettings(challenge *MiningChallenge, publicAddr string) *HashSettings

type Hasher

type Hasher interface {
	//base is a 52 byte slice containing the challenge and public address
	// the guessed nonce is appended to this slice and used as input to the first hash fn
	// returns a valid nonce, or empty string if none was found
	CheckRange(hash *HashSettings, start uint64, n uint64) (string, uint64, error)

	//number of hashes this backend checks at a time
	StepSize() uint64

	Name() string
}

interface for all mining implementations

type MiningChallenge

type MiningChallenge struct {
	Challenge  []byte
	Difficulty *big.Int
	RequestID  *big.Int
	RequestIDs [5]*big.Int
}

MiningChallenge holds information about a PoW challenge

type MiningGroup

type MiningGroup struct {
	Backends    []*Backend
	LastPrinted time.Time
}

func NewMiningGroup

func NewMiningGroup(hashers []Hasher) *MiningGroup

func SetupMiningGroup

func SetupMiningGroup(cfg *config.Config) (*MiningGroup, error)

func (*MiningGroup) HashRateEstimate

func (g *MiningGroup) HashRateEstimate() float64

func (*MiningGroup) Mine

func (g *MiningGroup) Mine(input chan *Work, output chan *Result)

func (*MiningGroup) PreferredWorkMultiple

func (g *MiningGroup) PreferredWorkMultiple() uint64

func (*MiningGroup) PrintHashRateSummary

func (g *MiningGroup) PrintHashRateSummary()

type MiningNotify

type MiningNotify struct {
	JobID             string
	Challenge         string
	PoolAddress       string
	LowDifficulty     *big.Int
	MedianDifficulty  *big.Int
	NetworkDifficulty *big.Int
	CleanJob          bool
}

func (*MiningNotify) UnmarshalJSON

func (n *MiningNotify) UnmarshalJSON(buf []byte) error

MiningNotify method that takes a slice of bytes and converts it into JSON-encoded data

type MiningSetDifficulty

type MiningSetDifficulty struct {
	Difficulty *big.Int
}

func (*MiningSetDifficulty) UnmarshalJSON

func (n *MiningSetDifficulty) UnmarshalJSON(buf []byte) error

MiningSetDifficulty method that takes a slice of bytes and converts it into JSON-encoded data

type MiningTasker

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

func CreateTasker

func CreateTasker(cfg *config.Config, proxy db.DataServerProxy) *MiningTasker

func (*MiningTasker) GetWork

func (mt *MiningTasker) GetWork(input chan *Work) (*Work, bool)

type Result

type Result struct {
	Work  *Work
	Nonce string
}

type SolutionHandler

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

func CreateSolutionHandler

func CreateSolutionHandler(
	cfg *config.Config,
	submitter zapCommon.TransactionSubmitter,
	proxy db.DataServerProxy) *SolutionHandler

func (*SolutionHandler) Submit

func (s *SolutionHandler) Submit(ctx context.Context, result *Result) bool

type StratumClient

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

func StratumConnect

func StratumConnect(host string, msgChan chan *StratumResponse) (*StratumClient, error)

func (*StratumClient) Listen

func (c *StratumClient) Listen()

func (*StratumClient) Request

func (c *StratumClient) Request(method string, params ...string) *StratumResponse

func (*StratumClient) Send

func (c *StratumClient) Send(request *StratumRequest) *StratumResponse

func (*StratumClient) SetTimeout

func (c *StratumClient) SetTimeout(timeout int64)

type StratumPool

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

func CreatePool

func CreatePool(cfg *config.Config, group *MiningGroup) *StratumPool

function that takes the pointer to a config.Config and a MiningGroup and returns a pointer to a StratumPool struct containing a url, minerAddress, minerPassword, log and group

func (*StratumPool) GetWork

func (p *StratumPool) GetWork(input chan *Work) (*Work, bool)

func (*StratumPool) Submit

func (p *StratumPool) Submit(ctx context.Context, result *Result) bool

type StratumRequest

type StratumRequest struct {
	Method string   `json:"method"`
	Params []string `json:"params"`
	ID     uint64   `json:"id"`
}

type StratumResponse

type StratumResponse struct {
	ID     uint64           `json:"id"`
	Result *json.RawMessage `json:"result"`
	Error  error            `json:"error,string"`
	Method string           `json:"method"`
	Params *json.RawMessage `json:"params"`
}

type Work

type Work struct {
	Challenge  *MiningChallenge
	PublicAddr string
	Start      uint64
	N          uint64
}

Jump to

Keyboard shortcuts

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