stratum

package
v0.0.0-...-07a8cb0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	SubscriptionId []byte
	Options        *config.Options
	RemoteAddress  net.Addr

	Socket      net.Conn
	SocketBufIO *bufio.ReadWriter

	LastActivity time.Time
	Shares       *Shares

	IsAuthorized           bool
	SubscriptionBeforeAuth bool

	ExtraNonce1 []byte

	VarDiff *vardiff.VarDiff

	WorkerName string
	WorkerPass string

	PendingDifficulty  *big.Float
	CurrentDifficulty  *big.Float
	PreviousDifficulty *big.Float

	BanningManager    *banningManager.BanningManager
	JobManager        *jobManager.JobManager
	SocketClosedEvent chan struct{}
}

func NewStratumClient

func NewStratumClient(subscriptionId []byte, socket net.Conn, options *config.Options, jm *jobManager.JobManager, bm *banningManager.BanningManager) *Client

func (*Client) AuthorizeFn

func (sc *Client) AuthorizeFn(ip net.Addr, port int, workerName string, password string) (authorized bool, disconnect bool, err error)

TODO: Can be DIY

func (*Client) EnqueueNextDifficulty

func (sc *Client) EnqueueNextDifficulty(nextDiff float64) bool

func (*Client) GetLabel

func (sc *Client) GetLabel() string

func (*Client) HandleAuthorize

func (sc *Client) HandleAuthorize(message *daemonManager.JsonRpcRequest, replyToSocket bool)

func (*Client) HandleMessage

func (sc *Client) HandleMessage(message *daemonManager.JsonRpcRequest)

func (*Client) HandleSubmit

func (sc *Client) HandleSubmit(message *daemonManager.JsonRpcRequest)

func (*Client) HandleSubscribe

func (sc *Client) HandleSubscribe(message *daemonManager.JsonRpcRequest)

func (*Client) Init

func (sc *Client) Init()

func (*Client) ManuallyAuthClient

func (sc *Client) ManuallyAuthClient(username, password string)

func (*Client) ManuallySetValues

func (sc *Client) ManuallySetValues(otherClient *Client)

func (*Client) SendDifficulty

func (sc *Client) SendDifficulty(diff *big.Float) bool

func (*Client) SendJsonRPC

func (sc *Client) SendJsonRPC(jsonRPCs daemonManager.JsonRpc)

func (*Client) SendMiningJob

func (sc *Client) SendMiningJob(jobParams []interface{})

func (*Client) SendSubscriptionFirstResponse

func (sc *Client) SendSubscriptionFirstResponse()

func (*Client) SetupSocket

func (sc *Client) SetupSocket()

func (*Client) ShouldBan

func (sc *Client) ShouldBan(shareValid bool) bool

type Server

type Server struct {
	Options  *config.Options
	Listener net.Listener

	DaemonManager       *daemonManager.DaemonManager
	VarDiff             *vardiff.VarDiff
	JobManager          *jobManager.JobManager
	StratumClients      map[uint64]*Client
	SubscriptionCounter *SubscriptionCounter
	BanningManager      *banningManager.BanningManager
	// contains filtered or unexported fields
}

func NewStratumServer

func NewStratumServer(options *config.Options, jm *jobManager.JobManager, bm *banningManager.BanningManager) *Server

func (*Server) BroadcastCurrentMiningJob

func (ss *Server) BroadcastCurrentMiningJob(jobParams []interface{})

func (*Server) HandleNewClient

func (ss *Server) HandleNewClient(socket net.Conn) []byte

HandleNewClient converts the conn to an underlying client instance and finally return its unique subscriptionID

func (*Server) Init

func (ss *Server) Init() (portStarted []int)

func (*Server) ManuallyAddStratumClient

func (ss *Server) ManuallyAddStratumClient(client *Client)

func (*Server) RemoveStratumClientBySubscriptionId

func (ss *Server) RemoveStratumClientBySubscriptionId(subscriptionId []byte)

type Shares

type Shares struct {
	Valid   uint64
	Invalid uint64
}

func (*Shares) BadPercent

func (s *Shares) BadPercent() float64

func (*Shares) Reset

func (s *Shares) Reset()

func (*Shares) TotalShares

func (s *Shares) TotalShares() uint64

type SubscriptionCounter

type SubscriptionCounter struct {
	Count   uint64
	Padding []byte
}

support 18446744073709551615 max conn

func NewSubscriptionCounter

func NewSubscriptionCounter() *SubscriptionCounter

func (*SubscriptionCounter) Next

func (sc *SubscriptionCounter) Next() []byte

Jump to

Keyboard shortcuts

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