stratum

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UINT64MAX uint64 = 0xFFFFFFFFFFFFFFFF
)

Variables

View Source
var (
	ResultChanSize       = 100
	InitDifficulty int64 = 2000000
)
View Source
var (
	PeriodMax = float64(5) // s
	PeriodMin = float64(1.5)

	HashRateLen = 90

	MinDifficulty uint64 = 120000
)

Functions

This section is empty.

Types

type AdjustResult added in v1.0.6

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

type Auth

type Auth interface {
	Auth(username string, passwd string) bool
}

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type MineTask

type MineTask struct {
	Difficulty *big.Int
	Hash       common.Hash
	IsSubmit   bool
	Id         uint64
	NonceBegin uint64
	NonceEnd   uint64
}

type NonceMeter added in v1.0.6

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

type NonceResult added in v1.0.6

type NonceResult struct {
	TaskId uint64
	Nonce  uint64
	Id     interface{}
	Method string
}

type Notify

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

type Request

type Request struct {
	Id      interface{}   `json:"id"`
	JsonRpc string        `json:"jsonrpc,omitempty"`
	Error   interface{}   `json:"error,omitempty"`
	Result  interface{}   `json:"result,omitempty"`
	Params  []interface{} `json:"params"`
	Method  string        `json:"method"`
}

type Response

type Response struct {
	Error  *Error      `json:"error"`
	Id     interface{} `json:"id"`
	Result bool        `json:"result"`
	Method string      `json:"method"`
}

type Server

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

func NewServer

func NewServer(address string, maxConn uint, auth Auth, calcHashRate bool, fanOut bool) (*Server, error)

func (*Server) Dispatch

func (this *Server) Dispatch(hash common.Hash, difficulty *big.Int, nonceBegin, nonceEnd uint64)

Called by node

func (*Server) GetCurrentMineTask added in v1.0.6

func (this *Server) GetCurrentMineTask() *StratumTask

func (*Server) GetHashRate

func (this *Server) GetHashRate() uint64

func (*Server) ReadResult

func (this *Server) ReadResult(ch chan uint64)

func (*Server) Start

func (this *Server) Start()

func (*Server) Stop

func (this *Server) Stop()

type Session

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

func NewSession

func NewSession(auth Auth, sessionId string, conn net.Conn, initDifficulty uint64, minDifficulty uint64, server *Server, calcHashRate bool, hashRateMeterLen int) *Session

func (*Session) AdjustDifficulty added in v1.0.6

func (this *Session) AdjustDifficulty(serverDifficulty uint64) bool

func (*Session) Close

func (this *Session) Close()

func (*Session) GetDifficulty added in v1.0.6

func (this *Session) GetDifficulty() uint64

get session difficulty

func (*Session) GetHashRate

func (this *Session) GetHashRate() uint64

func (*Session) GetLastSubmitTime added in v1.0.6

func (this *Session) GetLastSubmitTime() int64

func (*Session) GetSessionId

func (this *Session) GetSessionId() string

func (*Session) NonceMeter added in v1.0.6

func (this *Session) NonceMeter(nonceDifficulty uint64)

func (*Session) RegisterAuthorizeFunc

func (this *Session) RegisterAuthorizeFunc(onAuthorize func(sessionId string))

func (*Session) RegisterCloseFunc

func (this *Session) RegisterCloseFunc(onClose func(sessionId string))

func (*Session) RegisterSubmitFunc

func (this *Session) RegisterSubmitFunc(onSubmit func(nonce uint64))

func (*Session) Start

func (this *Session) Start(calcHashRate bool)

type SimpleAuth

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

func NewSimpleAuth

func NewSimpleAuth(passwd string) *SimpleAuth

func (*SimpleAuth) Auth

func (this *SimpleAuth) Auth(username string, passwd string) bool

type StratumTask

type StratumTask struct {
	Id           uint64
	ServerTaskId uint64
	PowHash      common.Hash
	NonceBegin   uint64
	NonceEnd     uint64
	Difficulty   *big.Int
	Timestamp    int64
	IfClearTask  bool
	Submitted    bool
}

type SubscribeResult

type SubscribeResult struct {
	Error  *Error        `json:"error"`
	Id     interface{}   `json:"id"`
	Result []interface{} `json:"result"`
	Method string        `json:"method"`
}

Jump to

Keyboard shortcuts

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