Documentation ¶
Index ¶
- func AuthorizeFn(ip net.Addr, port int, workerName string, password string) (authorized bool, options map[string]float64, err error)
- func BitsToStr(bits uint32) string
- func InitClientCtxPool()
- type API
- type Activity
- type Client
- func (sc *Client) Authorize() error
- func (sc *Client) CalcHashRate() string
- func (sc *Client) CleanupMetrics()
- func (sc *Client) Disconnect()
- func (sc *Client) GetLabel() string
- func (sc *Client) HandleAuthorize(message *types.RPCRequest, replyToSocket bool)
- func (sc *Client) HandleConfigure(message *types.RPCRequest)
- func (sc *Client) HandleLogin(message *types.RPCLoginMessage, replyToSocket bool)
- func (sc *Client) HandleMessage(message *types.RPCRequest)
- func (sc *Client) HandleSubmit(message *types.RPCRequest)
- func (sc *Client) HandleSubscribe(message *types.RPCRequest)
- func (sc *Client) HandleUpdateBlock(message *types.RPCRequest)
- func (sc *Client) Init()
- func (sc *Client) InitPoolDifficulty()
- func (sc *Client) ManuallyAuthClient(username, password string)
- func (sc *Client) ManuallySetValues(otherClient *Client)
- func (sc *Client) SendDifficulty(diff *big.Float) bool
- func (sc *Client) SendJSON(data interface{})
- func (sc *Client) SendMiningJob(jobParams types.JobParams)
- func (sc *Client) SetupSocket()
- func (sc *Client) ShouldBan() bool
- func (sc *Client) VarDiffStart()
- func (sc *Client) VarDiffStop()
- func (sc *Client) VarDiffUpdate(clientOptions map[string]float64)
- type HashSortingIndexesRange
- type Job
- type JobCounter
- type JobManager
- func (jm *JobManager) CheckSolution(task tasks.MinerTask, nonce uint32, timestamp time.Time, ...) (tasks.MinerResult, bool)
- func (jm *JobManager) GetJobParamsEx(job Job, forceUpdate bool) (types.JobParams, error)
- func (jm *JobManager) ProcessSubmit(jobId string, extraNonce1 uint32, ...) (share *Share, minerResult tasks.MinerResult)
- type Metrics
- type Server
- func (ss *Server) BroadcastCurrentMiningJob(jobParams types.JobParams)
- func (ss *Server) BroadcastJob()
- func (ss *Server) HandleClientDisconnect(client *Client)
- func (ss *Server) HandleNewClient(socket net.Conn)
- func (ss *Server) HandleNewConnection()
- func (ss *Server) Init(minerResultChan chan tasks.MinerResult, ...)
- func (ss *Server) PublishPeriodicMetrics()
- func (ss *Server) RemoveStratumClientBySubscriptionId(subscriptionId uint64)
- func (ss *Server) Run(c *state.Coordinator)
- func (ss *Server) RunAPI()
- func (ss *Server) StopAPI()
- type Share
- type Shares
- type SubscriptionCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthorizeFn ¶
func AuthorizeFn(ip net.Addr, port int, workerName string, password string) (authorized bool, options map[string]float64, err error)
AuthorizeFn validates worker name and rig name.
func InitClientCtxPool ¶
func InitClientCtxPool()
Types ¶
type Client ¶
type Client struct { SubscriptionId uint64 Options *settings.Configuration RemoteAddress net.Addr Socket net.Conn SocketBufIO *bufio.ReadWriter SocketBufIOMutex sync.Mutex LastActivity time.Time Metrics *Metrics IsAuthorized bool SubscriptionBeforeAuth bool ExtraNonce1 uint32 WorkerName string WorkerPass string // TODO: used by ManuallySetValues method. Delete? CurrentTarget uint32 PreviousTarget uint32 PendingDifficulty *big.Float CurrentDifficulty *big.Float PreviousDifficulty *big.Float ClientTarget *big.Int JobManager *JobManager BanningManager *bans.BanningManager SocketClosedEvent chan struct{} SendMiningJobEvent chan Job // contains filtered or unexported fields }
func NewStratumClient ¶
func NewStratumClient(subscriptionId uint64, socket net.Conn, options *settings.Configuration, bm *bans.BanningManager, jm *JobManager, sendMiningJobEvent chan Job, stratumUpdateBlock chan events.StratumUpdateBlock) *Client
func (*Client) CalcHashRate ¶
CalcHashRate returns human form of hash rate value
func (*Client) CleanupMetrics ¶ added in v0.2.1
func (sc *Client) CleanupMetrics()
CleanupMetrics cleans up some metrics on disconnect. Otherwise they will have most recent value and show incorrect values when observing in Grafana for example.
func (*Client) Disconnect ¶ added in v0.2.1
func (sc *Client) Disconnect()
func (*Client) HandleAuthorize ¶
func (sc *Client) HandleAuthorize(message *types.RPCRequest, replyToSocket bool)
func (*Client) HandleConfigure ¶
func (sc *Client) HandleConfigure(message *types.RPCRequest)
HandleConfigure handles mining.configure stratum method. Currently, only version-rolling extension is supported. min-bit-count field is considered obsolete and does not use in the code. Example of this request:
{ "method": "mining.configure", "id": 1, "params": [ ["minimum-difficulty", "version-rolling"], { "minimum-difficulty.value": 2048, "version-rolling.mask": "1fffe000", "version-rolling.min-bit-count": 2 } ] }
func (*Client) HandleLogin ¶
func (sc *Client) HandleLogin(message *types.RPCLoginMessage, replyToSocket bool)
func (*Client) HandleMessage ¶
func (sc *Client) HandleMessage(message *types.RPCRequest)
func (*Client) HandleSubmit ¶
func (sc *Client) HandleSubmit(message *types.RPCRequest)
func (*Client) HandleSubscribe ¶
func (sc *Client) HandleSubscribe(message *types.RPCRequest)
func (*Client) HandleUpdateBlock ¶
func (sc *Client) HandleUpdateBlock(message *types.RPCRequest)
func (*Client) InitPoolDifficulty ¶
func (sc *Client) InitPoolDifficulty()
InitPoolDifficulty calculates initial pool difficulty when new stratum client is connected and sends it to the client.
func (*Client) ManuallyAuthClient ¶
func (*Client) ManuallySetValues ¶
func (*Client) SendMiningJob ¶
func (*Client) SetupSocket ¶
func (sc *Client) SetupSocket()
func (*Client) VarDiffStart ¶
func (sc *Client) VarDiffStart()
VarDiffStart starts variable difficulty feature. Every RetargetTimeWindow represented in seconds it calculates next client difficulty. It stops when receive a data via stopChan channel.
func (*Client) VarDiffStop ¶
func (sc *Client) VarDiffStop()
func (*Client) VarDiffUpdate ¶
VarDiffUpdate changes variable difficulty options for client connection on the fly.
type HashSortingIndexesRange ¶
type Job ¶
type Job struct { MinerTask tasks.MinerTask // types.JobParams JobId string PrevHashReversed string Submits map[string]struct{} GenerationTransaction [][]byte Broadcasted bool Bits uint32 // Bitcoin block bits }
func (*Job) RegisterSubmit ¶
type JobCounter ¶
type JobManager ¶
type JobManager struct { Config *settings.Configuration JobCounter *JobCounter ExtraNoncePlaceholder []byte ExtraNonceSize int // 4 CurrentJob Job ValidJobsCache *cache.Cache CoinbaseHasher func([]byte) chainhash.Hash // Not sure if this needed MinerResultChan chan tasks.MinerResult // contains filtered or unexported fields }
func NewJobManager ¶
func NewJobManager(config *settings.Configuration, minerResultChan chan tasks.MinerResult) *JobManager
func (*JobManager) CheckSolution ¶
func (*JobManager) GetJobParamsEx ¶
func (*JobManager) ProcessSubmit ¶
func (jm *JobManager) ProcessSubmit(jobId string, extraNonce1 uint32, hexExtraNonce2, hexNTime, hexNonce, hexVersionBits string, versionRolling types.VersionRolling, ipAddr net.Addr, workerName string, clientTarget *big.Int) ( share *Share, minerResult tasks.MinerResult)
type Server ¶
type Server struct { utils.StoppableMixin Config *settings.Configuration Listener net.Listener VarDiff *vardiff.VarDiff StratumClients map[uint64]*Client StratumClientsMutex sync.Mutex SubscriptionCounter *SubscriptionCounter BanningManager *bans.BanningManager JobManager *JobManager // rebroadcastTicker *time.Ticker ReceiveMiningJobEvent chan Job APIServer *API StratumUpdateBlockEvent chan events.StratumUpdateBlock // contains filtered or unexported fields }
Server describes structure of the stratum server.
func NewStratumServer ¶
func NewStratumServer(options *settings.Configuration) *Server
func (*Server) BroadcastCurrentMiningJob ¶
func (*Server) BroadcastJob ¶ added in v0.2.1
func (ss *Server) BroadcastJob()
BroadcastJob broadcasts new jobs to stratum clients.
func (*Server) HandleClientDisconnect ¶ added in v0.2.1
HandleClientDisconnect handles stratum client disconnect.
func (*Server) HandleNewClient ¶
HandleNewClient converts the connection to an underlying client instance
func (*Server) HandleNewConnection ¶ added in v0.2.1
func (ss *Server) HandleNewConnection()
func (*Server) Init ¶
func (ss *Server) Init(minerResultChan chan tasks.MinerResult, stratumUpdateBlockEvent chan events.StratumUpdateBlock)
func (*Server) PublishPeriodicMetrics ¶ added in v0.2.1
func (ss *Server) PublishPeriodicMetrics()
PublishPeriodicMetrics produces periodic metrics.
func (*Server) RemoveStratumClientBySubscriptionId ¶
func (*Server) Run ¶
func (ss *Server) Run(c *state.Coordinator)
Run sends current mining task to miner.
type Shares ¶
type Shares struct {}
func (*Shares) BadPercent ¶
func (*Shares) GetInvalid ¶
func (*Shares) IncrementInvalid ¶
func (s *Shares) IncrementInvalid()
func (*Shares) IncrementValid ¶
func (s *Shares) IncrementValid()
func (*Shares) TotalShares ¶
type SubscriptionCounter ¶
SubscriptionCounter describes number of currently connected stratum clients. Supports 18446744073709551615 max connections.
func NewSubscriptionCounter ¶
func NewSubscriptionCounter() *SubscriptionCounter
func (*SubscriptionCounter) Next ¶
func (sc *SubscriptionCounter) Next() uint64