core

package
v1.0.24 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: ISC Imports: 15 Imported by: 0

Documentation

Overview

* Qitmeer james

Copyright (c) 2019 The qitmeer developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2019 The qitmeer developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

View Source
const SYMBOL_PMEER = "MEER"

Variables

View Source
var ErrJsonType = errors.New("Unexpected type in json.")

ErrJsonType is an error for json that we do not expect.

Functions

func GetPowType

func GetPowType(powName string) pow.PowType

Types

type BaseDevice

type BaseDevice interface {
	Mine(wg *sync.WaitGroup)
	Update()
	InitDevice()
	Status(wg *sync.WaitGroup)
	GetIsValid() bool
	SetIsValid(valid bool)
	GetMinerId() int
	GetAverageHashRate() float64
	GetName() string
	GetStart() uint64
	SetPool(pool bool)
	SetNewWork(w BaseWork)
	SetForceUpdate(force bool)
	Release()
	GetMinerType() string
	SubmitShare(substr chan string)
	StopTask()
	GetIsRunning() bool
}

type BaseWork

type BaseWork interface {
	Get() bool
	Submit(h *types.BlockHeader, gbtID string) (string, int, error)
	PoolGet() bool
	PoolSubmit(subm string) error
}

type Device

type Device struct {
	Cfg              *common.GlobalConfig //must init
	DeviceName       string
	HasNewWork       bool
	ForceStop        bool
	AllDiffOneShares uint64
	AverageHashRate  float64
	MinerId          uint32
	NonceStep        uint64
	NonceStart       uint64
	LocalItemSize    int
	NonceOut         []byte
	Started          int64
	GlobalItemSize   int
	CurrentWorkID    uint64
	Quit             context.Context //must init
	sync.Mutex
	Wg           sync.WaitGroup
	Pool         bool        //must init
	IsValid      bool        //is valid
	SubmitData   chan string //must
	NewWork      chan BaseWork
	Err          error
	MiningType   string
	UartPath     string
	StopTaskChan chan bool
	IsRunning    bool
}

func (*Device) GetAverageHashRate

func (this *Device) GetAverageHashRate() float64

func (*Device) GetIntensity

func (this *Device) GetIntensity() int

func (*Device) GetIsRunning

func (this *Device) GetIsRunning() bool

func (*Device) GetIsValid

func (this *Device) GetIsValid() bool

func (*Device) GetMinerId

func (this *Device) GetMinerId() int

func (*Device) GetMinerType

func (this *Device) GetMinerType() string

func (*Device) GetName

func (this *Device) GetName() string

func (*Device) GetStart

func (this *Device) GetStart() uint64

func (*Device) GetWorkSize

func (this *Device) GetWorkSize() int

func (*Device) Init

func (this *Device) Init(i int, pool bool, ctx context.Context, cfg *common.GlobalConfig, allCount uint64)

func (*Device) InitDevice

func (this *Device) InitDevice()

func (*Device) Release

func (d *Device) Release()

func (*Device) SetForceUpdate

func (this *Device) SetForceUpdate(force bool)

func (*Device) SetIsValid

func (this *Device) SetIsValid(valid bool)

func (*Device) SetNewWork

func (this *Device) SetNewWork(work BaseWork)

func (*Device) SetPool

func (this *Device) SetPool(b bool)

func (*Device) SetWorkSize

func (this *Device) SetWorkSize(size int)

func (*Device) Status

func (this *Device) Status(wg *sync.WaitGroup)

func (*Device) StopTask

func (this *Device) StopTask()

func (*Device) SubmitShare

func (this *Device) SubmitShare(substr chan string)

func (*Device) Update

func (this *Device) Update()

type MinerRobot

type MinerRobot struct {
	Cfg              *common.GlobalConfig //config
	ValidShares      uint64
	PendingShares    uint64
	StaleShares      uint64
	InvalidShares    uint64
	AllDiffOneShares uint64
	Wg               *sync.WaitGroup
	Started          uint32
	Quit             context.Context
	Work             *Work
	ClDevices        []string
	Rpc              *common.RpcClient
	Pool             bool
	SubmitStr        chan string
	UseDevices       []string
}

func (*MinerRobot) InitDevice

func (this *MinerRobot) InitDevice()

init GPU device

type Robot

type Robot interface {
	Run(ctx context.Context) // uses device to calulate the nonce
	ListenWork()             //listen the solo or pool work
	SubmitWork()             //submit the work
}

type Stratum

type Stratum struct {
	sync.Mutex
	Cfg           *common.GlobalConfig
	Conn          net.Conn
	Reader        *bufio.Reader
	ID            uint64
	Started       uint32
	Timeout       uint32
	ValidShares   uint64
	InvalidShares uint64
	StaleShares   uint64
	SubmitIDs     []uint64
	SubID         uint64
	AuthID        uint64
	PowType       pow.PowType
	Quit          context.Context
}

func (*Stratum) Auth

func (s *Stratum) Auth() error

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

func (*Stratum) ConnectRetry

func (this *Stratum) ConnectRetry()

func (*Stratum) Listen

func (this *Stratum) Listen(handle func(data string))

func (*Stratum) Reconnect

func (s *Stratum) Reconnect() error

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

func (*Stratum) StratumConn

func (this *Stratum) StratumConn(cfg *common.GlobalConfig, ctx context.Context) error

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

func (*Stratum) Subscribe

func (s *Stratum) Subscribe() error

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

type StratumMsg

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

type Work

type Work struct {
	Cfg   *common.GlobalConfig
	Rpc   *common.RpcClient
	Clean bool
	sync.Mutex
	Quit        context.Context
	Started     uint32
	GetWorkTime int64
	LastSub     string //last submit string
}

standard work template

Jump to

Keyboard shortcuts

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