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: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixRegisterKey = "register_"
	PrefixJobKey      = "job_"
	PrefixShareKey    = "share_"
)
View Source
const (
	KeyRegId                = "id"
	KeyRegPayoutAddress     = "payoutAddress"
	KeyRegPoolTag           = "poolTag"
	KeyRegCoinType          = "coinType"
	KeyRegUsedTestNet       = "usedTestNet"
	KeyRegExtraNonce1Length = "extraNonce1Length"
	KeyRegExtraNonce2Length = "extraNonce2Length"
)

Variables

View Source
var (
	CoinTypeBTC string = "BTC"
)

Functions

This section is empty.

Types

type Block

type Block struct {
	Hash string
	Data string
}

func NewBlock

func NewBlock(hash string, data string) *Block

type BlockCoinBasePart

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

func NewBlockCoinBasePart

func NewBlockCoinBasePart() *BlockCoinBasePart

type BlockHeaderPart

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

func NewBlockHeaderPart

func NewBlockHeaderPart() *BlockHeaderPart

type CacheService

type CacheService interface {
	SetRegisterContext(key RegisterKey, r *Register) error
	GetRegisterContext(key RegisterKey) (*Register, error)
	DelRegisterContext(key RegisterKey) error
	SetBlockTransactions(key JobKey, expireTs int, transactions []*Transaction) error
	GetBlockTransactions(key JobKey) ([]*Transaction, error)
	SetShareHash(key ShareKey, hash string) error
	ExistShareHash(key ShareKey, hash string) (bool, error)
	ClearShareHistory(key ShareKey) error
}

type CoinService

type CoinService interface {
	IsValidAddress(address string, isUsedTestNet bool) bool
	GetLatestStratumJob(r *Register) (*StratumJobPart, []*Transaction, error)
	MakeBlock(r *Register, header *BlockHeaderPart, base *BlockCoinBasePart, transactions []*Transaction) (*Block, error)
	SubmitBlock(data string) (bool, error)
	IsSolveHash(hash string, targetDifficulty *big.Int) (bool, error)
	GetTargetDifficulty(bits string) (*big.Int, error)
	CalculateShareComputePower(difficulty *big.Int) (*big.Int, error)
	GetNewBlockHeight() (int, error)
}

type JobKey

type JobKey string

func GenJobKey

func GenJobKey(registerId string, height int32, curTimeTs int32) JobKey

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) GetCacheService

func (m *Manager) GetCacheService() CacheService

func (*Manager) GetCoinService

func (m *Manager) GetCoinService(coinType string) CoinService

func (*Manager) SetCacheService

func (m *Manager) SetCacheService(service CacheService) *Manager

func (*Manager) SetCoinService

func (m *Manager) SetCoinService(coinType string, service CoinService) *Manager

type Register

type Register struct {
	Id                string
	PayoutAddress     string
	PoolTag           string
	CoinType          string
	UsedTestNet       bool
	ExtraNonce1Length int
	ExtraNonce2Length int
}

func NewRegister

func NewRegister() *Register

func (*Register) IsValid

func (r *Register) IsValid() bool

type RegisterKey

type RegisterKey string

func GenRegisterKey

func GenRegisterKey(registerId string) RegisterKey

type ShareKey

type ShareKey string

func GenShareKey

func GenShareKey(registerId string, height int32) ShareKey

type StratumJobMetaPart

type StratumJobMetaPart struct {
	Height    int32
	MinTimeTs int32
	CurTimeTs int32
}

func NewStratumJobMetaPart

func NewStratumJobMetaPart() *StratumJobMetaPart

type StratumJobPart

type StratumJobPart struct {
	PrevHash     string
	CoinBase1    string
	CoinBase2    string
	MerkleBranch []string
	Version      string
	NBits        string
	Meta         *StratumJobMetaPart
}

func NewStratumJobPart

func NewStratumJobPart() *StratumJobPart

func (*StratumJobPart) ToPBStratumJob

func (job *StratumJobPart) ToPBStratumJob() *pb.StratumJob

type Transaction

type Transaction struct {
	Data string
	Hash string
}

func NewBlockTransactionPart

func NewBlockTransactionPart(hash string, data string) *Transaction

Directories

Path Synopsis
coin
btc

Jump to

Keyboard shortcuts

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