Documentation ¶
Index ¶
- Constants
- Variables
- type AuthReply
- type Director
- type Job
- type LoginReply
- type Mining
- func (m *Mining) Auth(p PassThruParams, resp *AuthReply) error
- func (m *Mining) Getjob(p PassThruParams, resp *Job) error
- func (m *Mining) Keepalived(p PassThruParams, resp *StatusReply) error
- func (m *Mining) Login(p PassThruParams, resp *LoginReply) error
- func (m *Mining) Submit(p PassThruParams, resp *StatusReply) error
- type PassThruParams
- type Proxy
- type Stats
- type StatusReply
- type Worker
Constants ¶
const ( // ValidateNormal just checks that there is a valid job ID and the share is // not a duplicate for this job ValidateNormal // ValidateFormat checks the results and nonce for valid size ValidateFormat // ValidateDiff checks that the result difficulty meets the target // NOT WORKING - the idea would be to include previous levels also ValidateDiff // ValidateFull TODO checks nonce against blob for result // maybe not worth it! ValidateFull )
const ( // MaxUint protects IDs from overflow if the process runs for thousands of years MaxUint = ^uint64(0) )
Variables ¶
var ( ErrMalformedJob = errors.New("bad job format from pool") ErrUnknownTargetFormat = errors.New("unrecognized format for job target") )
var ( ErrBadJobID = errors.New("invalid job id") )
var ( ErrDiffTooLow = errors.New("share difficulty too low") )
Functions ¶
This section is empty.
Types ¶
type Director ¶
type Director struct {
// contains filtered or unexported fields
}
Director might be refactored to "ProxyGroup"
func GetDirector ¶
func GetDirector() *Director
type Job ¶
type Job struct { Blob string `json:"blob"` ID string `json:"job_id"` Target string `json:"target"` // contains filtered or unexported fields }
Job is a mining job. Break it up and send chunks to workers.
func NewJobFromServer ¶
NewJobFromServer creates a Job from a pool notice
type LoginReply ¶
type Mining ¶
type Mining struct{}
RPC proxy service
func (*Mining) Auth ¶
func (m *Mining) Auth(p PassThruParams, resp *AuthReply) error
Auth is special login method for Coinhive miners
func (*Mining) Keepalived ¶
func (m *Mining) Keepalived(p PassThruParams, resp *StatusReply) error
Keepalived lets the client tell you they're still there, and you get to say "I'm still here too" Right now, we don't keep track of idle connections, so this doesn't really matter.
func (*Mining) Login ¶
func (m *Mining) Login(p PassThruParams, resp *LoginReply) error
func (*Mining) Submit ¶
func (m *Mining) Submit(p PassThruParams, resp *StatusReply) error
Submit accepts shares from a worker and passes them through to the pool. This does NOT currently recognize which worker or even what type of worker is doing the submiting, and does not return a Coinhive friendly response. But the coinhive miner doesn't care, it just doesn't keep up with submissions.
type PassThruParams ¶
type PassThruParams map[string]interface{}
PassThruParams is a generic type for handling RPC requests. It can (should) contain the context of the request in order to be handled correctly. Other than the context, everything else should be shipped off to the pool as is. If that is not the correct behavior, use another type for params.
func (PassThruParams) Context ¶
func (p PassThruParams) Context() context.Context
Context implements jsonrpc2.WithContext
func (*PassThruParams) SetContext ¶
func (p *PassThruParams) SetContext(ctx context.Context)
SetContext implements jsonrpc2.WithContext
type Proxy ¶
type Proxy struct { ID uint64 SC *stratum.Client DC *stratum.Client SS *stratum.Server // contains filtered or unexported fields }
Proxy manages a group of workers.
func (*Proxy) NextJob ¶
NextJob gets gets the next job (on the current block) and increments the nonce
type Stats ¶
type Stats struct { Timestamp time.Time Alive time.Duration Proxies int Workers int // contains filtered or unexported fields }
Stats is a struct containing information about server uptime and activity, generated on demand
type StatusReply ¶
type Worker ¶
type Worker interface { // ID is used to distinguish this worker from other workers on the proxy. ID() uint64 // SetID allows proxies to assign this value when a connection is established. SetID(uint64) // Workers must implement this method to establish communication with their assigned // proxy. The proxy connection should be stored in order to 1. Submit Shares and 2. Disconnect Cleanly SetProxy(*Proxy) Proxy() *Proxy // Disconnect closes the connection to the proxy from the worker. // Ideally it sets up the worker to try and reconnect to a new proxy through the director. Disconnect() NewJob(*Job) }
Worker does the work for the proxy. It exposes methods that allow interface with the proxy.