service

package
v0.0.0-...-e66b27f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorExtractJobId = errors.New("extract job id error.")
)

Functions

func ExtractJobId

func ExtractJobId(jobId string) (string, int32, int, uint64, error)

func GenerateJobId

func GenerateJobId(prefix string, height int32, index int, difficulty uint64) string

Types

type BlockLog

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

func NewBlockLog

func NewBlockLog() *BlockLog

func (*BlockLog) GetClientIP

func (l *BlockLog) GetClientIP() string

func (*BlockLog) GetExtName

func (l *BlockLog) GetExtName() string

func (*BlockLog) GetHash

func (l *BlockLog) GetHash() string

func (*BlockLog) GetHeight

func (l *BlockLog) GetHeight() int32

func (*BlockLog) GetHostName

func (l *BlockLog) GetHostName() string

func (*BlockLog) GetPid

func (l *BlockLog) GetPid() int32

func (*BlockLog) GetServerIP

func (l *BlockLog) GetServerIP() string

func (*BlockLog) GetUserAgent

func (l *BlockLog) GetUserAgent() string

func (*BlockLog) GetUserName

func (l *BlockLog) GetUserName() string

func (*BlockLog) GetWorkerName

func (l *BlockLog) GetWorkerName() string

func (*BlockLog) SetClientIP

func (l *BlockLog) SetClientIP(ip string) *BlockLog

func (*BlockLog) SetExtName

func (l *BlockLog) SetExtName(extName string) *BlockLog

func (*BlockLog) SetHash

func (l *BlockLog) SetHash(hash string) *BlockLog

func (*BlockLog) SetHeight

func (l *BlockLog) SetHeight(height int32) *BlockLog

func (*BlockLog) SetHostName

func (l *BlockLog) SetHostName(hostName string) *BlockLog

func (*BlockLog) SetPid

func (l *BlockLog) SetPid(pid int32) *BlockLog

func (*BlockLog) SetServerIP

func (l *BlockLog) SetServerIP(ip string) *BlockLog

func (*BlockLog) SetUserAgent

func (l *BlockLog) SetUserAgent(userAgent string) *BlockLog

func (*BlockLog) SetUserName

func (l *BlockLog) SetUserName(userName string) *BlockLog

func (*BlockLog) SetWorkerName

func (l *BlockLog) SetWorkerName(workerName string) *BlockLog

type LogService

type LogService interface {
	Init() error
	AddBlockLog(coinType string, t time.Time, blockLog *BlockLog) (bool, error)
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) GetLogService

func (m *Manager) GetLogService() LogService

func (*Manager) GetSphereService

func (m *Manager) GetSphereService() StratumService

func (*Manager) GetStatsService

func (m *Manager) GetStatsService() StatsService

func (*Manager) GetUserService

func (m *Manager) GetUserService() UserService

func (*Manager) Init

func (m *Manager) Init() error

func (*Manager) SetLogService

func (m *Manager) SetLogService(service LogService) *Manager

func (*Manager) SetSphereService

func (m *Manager) SetSphereService(service StratumService) *Manager

func (*Manager) SetStatsService

func (m *Manager) SetStatsService(service StatsService) *Manager

func (*Manager) SetUserService

func (m *Manager) SetUserService(service UserService) *Manager

type ShareBlockHash

type ShareBlockHash string

type ShareComputePower

type ShareComputePower float64

type ShareLog

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

func NewShareLog

func NewShareLog() *ShareLog

func (*ShareLog) GetClientIP

func (l *ShareLog) GetClientIP() string

func (*ShareLog) GetComputePower

func (l *ShareLog) GetComputePower() float64

func (*ShareLog) GetExtName

func (l *ShareLog) GetExtName() string

func (*ShareLog) GetHeight

func (l *ShareLog) GetHeight() int32

func (*ShareLog) GetHostName

func (l *ShareLog) GetHostName() string

func (*ShareLog) GetIsRight

func (l *ShareLog) GetIsRight() bool

func (*ShareLog) GetPid

func (l *ShareLog) GetPid() int32

func (*ShareLog) GetServerIP

func (l *ShareLog) GetServerIP() string

func (*ShareLog) GetUserAgent

func (l *ShareLog) GetUserAgent() string

func (*ShareLog) GetUserName

func (l *ShareLog) GetUserName() string

func (*ShareLog) GetWorkerName

func (l *ShareLog) GetWorkerName() string

func (*ShareLog) SetClientIP

func (l *ShareLog) SetClientIP(ip string) *ShareLog

func (*ShareLog) SetComputePower

func (l *ShareLog) SetComputePower(computePower float64) *ShareLog

func (*ShareLog) SetExtName

func (l *ShareLog) SetExtName(extName string) *ShareLog

func (*ShareLog) SetHeight

func (l *ShareLog) SetHeight(height int32) *ShareLog

func (*ShareLog) SetHostName

func (l *ShareLog) SetHostName(hostName string) *ShareLog

func (*ShareLog) SetIsRight

func (l *ShareLog) SetIsRight(isRight bool) *ShareLog

func (*ShareLog) SetPid

func (l *ShareLog) SetPid(pid int32) *ShareLog

func (*ShareLog) SetServerIP

func (l *ShareLog) SetServerIP(ip string) *ShareLog

func (*ShareLog) SetUserAgent

func (l *ShareLog) SetUserAgent(userAgent string) *ShareLog

func (*ShareLog) SetUserName

func (l *ShareLog) SetUserName(userName string) *ShareLog

func (*ShareLog) SetWorkerName

func (l *ShareLog) SetWorkerName(workerName string) *ShareLog

type ShareResult

type ShareResult struct {
	State        ShareState
	ComputePower ShareComputePower
	BlockHash    ShareBlockHash
}

type ShareState

type ShareState int
const (
	SeparatorJobId            = "_"
	StateUnknown   ShareState = iota
	StateSuccess
	StateSuccessSubmitBlock
	StateErrDuplicateShare
	StateErrLowDifficultyShare
	StateErrJobNotFound
)

type StatsService

type StatsService interface {
	Init() error
	AddShareLog(coinType string, t time.Time, shareLog *ShareLog) (bool, error)
}

type StratumConfig

type StratumConfig struct {
	CoinType          string
	PoolTag           string
	PayoutAddress     string
	ExtraNonce1Length int
	ExtraNonce2Length int
}

func NewStratumConfig

func NewStratumConfig() *StratumConfig

type StratumJob

type StratumJob struct {
	JobId        string
	PrevHash     string
	CoinBase1    string
	CoinBase2    string
	MerkleBranch []string
	Version      string
	NBits        string
	NTime        string
	CleanJobs    bool
	Meta         *StratumJobMeta
}

func NewStratumJob

func NewStratumJob() *StratumJob

func (*StratumJob) Fill

func (job *StratumJob) Fill(jobId string, ts int64, cleanJobs bool) *StratumJob

func (*StratumJob) ToJSONInterface

func (job *StratumJob) ToJSONInterface() []interface{}

func (*StratumJob) ToShare

func (job *StratumJob) ToShare() *StratumShare

type StratumJobMeta

type StratumJobMeta struct {
	Height    int32
	MinTimeTs int32
	CurTimeTs int32
}

func NewStratumJobMeta

func NewStratumJobMeta() *StratumJobMeta

type StratumService

type StratumService interface {
	Init() error
	Register(config *StratumConfig, info *SysInfo) error
	GetLatestStratumJob() (*StratumJob, error)
	Subscribe(ctx context.Context, handler SubscribeHandler)
	SubmitShare(share *StratumShare, difficulty uint64) (ShareResult, error)
	ClearShareHistory(height int32) (bool, error)
	UnRegister() (bool, error)
}

type StratumShare

type StratumShare struct {
	StratumShareHeader
	StratumShareCoinBase
	Meta *StratumShareMeta
}

func NewStratumShare

func NewStratumShare() *StratumShare

type StratumShareCoinBase

type StratumShareCoinBase struct {
	ExtraNonce1 string
	ExtraNonce2 string
	CoinBase1   string
	CoinBase2   string
}

type StratumShareHeader

type StratumShareHeader struct {
	Version  string
	NTime    string
	NBits    string
	Nonce    string
	PrevHash string
}

type StratumShareMeta

type StratumShareMeta struct {
	Height   int32
	JobCurTs int32
}

func NewStratumShareMeta

func NewStratumShareMeta() *StratumShareMeta

func (*StratumShareMeta) GetHeight

func (meta *StratumShareMeta) GetHeight() int32

func (*StratumShareMeta) GetJobCurTs

func (meta *StratumShareMeta) GetJobCurTs() int32

type SubscribeHandler

type SubscribeHandler func(job *StratumJob)

type SysInfo

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

func NewSysInfo

func NewSysInfo() *SysInfo

func (*SysInfo) GetHostName

func (ctx *SysInfo) GetHostName() (string, error)

func (*SysInfo) GetPid

func (ctx *SysInfo) GetPid() int

type UserService

type UserService interface {
	Init() error
	Login(username string, password string) proto.AuthorizeResult
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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