stratum

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStratumStaleWork = fmt.Errorf("Stale work, throwing away")

ErrStratumStaleWork indicates that the work to send to the pool was stale.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type BasicReply

type BasicReply struct {
	ID     interface{} `json:"id"`
	Error  StratErr    `json:"error,omitempty"`
	Result bool        `json:"result"`
}

Basic reply is a reply type for any of the simple messages.

type Config

type Config struct {
	Pool      string
	User      string
	Pass      string
	Proxy     string
	ProxyUser string
	ProxyPass string
	Version   string
}

Config holdes the config options that may be used by a stratum pool.

type NotifyRes

type NotifyRes struct {
	JobID          string
	Hash           string
	GenTX1         string
	GenTX2         string
	MerkleBranches []string
	BlockVersion   string
	Nbits          string
	Ntime          string
	CleanJobs      bool
}

NotifyRes models the json from a mining.notify message.

type NotifyWork

type NotifyWork struct {
	Clean             bool
	ExtraNonce1       string
	ExtraNonce2       uint64
	ExtraNonce2Length float64
	Nonce2            uint32
	CB1               string
	CB2               string
	Height            int64
	NtimeDelta        int64
	JobID             string
	Hash              string
	Nbits             string
	Ntime             string
	Version           string
	NewWork           bool
	Work              *work.Work
}

NotifyWork holds all the info recieved from a mining.notify message along with the Work data generate from it.

type PoolError

type PoolError struct {
	Code    uint64 `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

type StratErr

type StratErr struct {
	ErrNum uint64
	ErrStr string
	Result *json.RawMessage `json:"result,omitempty"`
}

StratErr is the basic error type (a number and a string) sent by the stratum server.

type Stratum

type Stratum struct {
	// The following variables must only be used atomically.
	ValidShares   uint64
	InvalidShares uint64

	sync.Mutex

	Conn   net.Conn
	Reader *bufio.Reader
	ID     uint64

	Diff     float64
	Target   *big.Int
	PoolWork NotifyWork

	Started uint32
	// contains filtered or unexported fields
}

Stratum holds all the shared information for a stratum connection. XXX most of these should be unexported and use getters/setters.

func StratumConn

func StratumConn(pool, user, pass, proxy, proxyUser, proxyPass, version string) (*Stratum, error)

StratumConn starts the initial connection to a stratum pool and sets defaults in the pool object.

func (*Stratum) Auth

func (s *Stratum) Auth() error

Auth sends a message to the pool to authorize a worker.

func (*Stratum) Listen

func (s *Stratum) Listen()

Listen is the listener for the incoming messages from the stratum pool.

func (*Stratum) PrepSubmit

func (s *Stratum) PrepSubmit(data []byte, jobID string) (Submit, error)

PrepSubmit formats a mining.sumbit message from the solved work.

func (*Stratum) PrepWork

func (s *Stratum) PrepWork() error

PrepWork converts the stratum notify to getwork style data for mining.

func (*Stratum) Reconnect

func (s *Stratum) Reconnect() error

Reconnect reconnects to a stratum server if the connection has been lost.

func (*Stratum) Subscribe

func (s *Stratum) Subscribe() error

Subscribe sends the subscribe message to get mining info for a worker.

func (*Stratum) Unmarshal

func (s *Stratum) Unmarshal(blob []byte) (interface{}, error)

Unmarshal provides a json unmarshaler for the commands. I'm sure a lot of this can be generalized but the json we deal with is pretty yucky.

type StratumMsg

type StratumMsg struct {
	Method string `json:"method"`
	// Need to make generic.
	Params []string    `json:"params"`
	ID     interface{} `json:"id"`
}

StratumMsg is the basic message object from stratum.

type StratumRsp

type StratumRsp struct {
	Method string `json:"method"`
	// Need to make generic.
	ID     interface{}      `json:"id"`
	Error  StratErr         `json:"error,omitempty"`
	Result *json.RawMessage `json:"result,omitempty"`
}

StratumRsp is the basic response type from stratum.

type Submit

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

Submit models a submission message.

type SubscribeReply

type SubscribeReply struct {
	SubscribeID       string
	ExtraNonce1       string
	ExtraNonce2Length float64
}

SubscribeReply models the server response to a subscribe message.

Jump to

Keyboard shortcuts

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