kaspastratum

package
v0.0.0-...-507f73e Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStaleShare = fmt.Errorf("stale share")
	ErrDupeShare  = fmt.Errorf("duplicate share")
)

Functions

func BigDiffToLittle

func BigDiffToLittle(diff *big.Int) float64

func CalculateTarget

func CalculateTarget(bits uint64) big.Int

func DiffToHash

func DiffToHash(diff float64) float64

func DiffToTarget

func DiffToTarget(diff float64) *big.Int

func GenerateJobHeader

func GenerateJobHeader(headerData []byte) []uint64

func GenerateLargeJobParams

func GenerateLargeJobParams(headerData []byte, timestamp uint64) string

func ListenAndServe

func ListenAndServe(cfg BridgeConfig) error

func MiningStateGenerator

func MiningStateGenerator() any

func SerializeBlockHeader

func SerializeBlockHeader(template *appmessage.RPCBlock) ([]byte, error)

Types

type AuthDbQuery

type AuthDbQuery struct {
	CurrentTime string
	SesUid      string
	RemoteAddr  string
	WalletAddr  string
	WorkerName  string
	Password    string
	RemoteApp   string
}

type BridgeConfig

type BridgeConfig struct {
	StratumPort    string        `yaml:"stratum_port"`
	RPCServer      string        `yaml:"kaspad_address"`
	UseLogFile     bool          `yaml:"log_to_file"`
	BlockWaitTime  time.Duration `yaml:"block_wait_time"`
	MinShareDiff   uint          `yaml:"min_share_diff"`
	ExtranonceSize uint          `yaml:"extranonce_size"`
	PoolWallet     string        `yaml:"pool_wallet"`
	OraConnStr     string        `yaml:"ora_connstr"`
}

type ErrorJob

type ErrorJob struct {
	Coin      string
	Method    string
	JobType   string
	JobText   string
	ErrorText string
}

type ErrorShortCodeT

type ErrorShortCodeT string
const (
	ErrNoMinerAddress    ErrorShortCodeT = "err_no_miner_address"
	ErrFailedBlockFetch  ErrorShortCodeT = "err_failed_block_fetch"
	ErrInvalidAddressFmt ErrorShortCodeT = "err_malformed_wallet_address"
	ErrMissingJob        ErrorShortCodeT = "err_missing_job"
	ErrBadDataFromMiner  ErrorShortCodeT = "err_bad_data_from_miner"
	ErrFailedSendWork    ErrorShortCodeT = "err_failed_sending_work"
	ErrFailedSetDiff     ErrorShortCodeT = "err_diff_set_failed"
	ErrDisconnected      ErrorShortCodeT = "err_worker_disconnected"
)

type KaspaApi

type KaspaApi struct {
	PoolWallet string
	// contains filtered or unexported fields
}

func NewKaspaAPI

func NewKaspaAPI(address string, blockWaitTime time.Duration, logger *zap.SugaredLogger, PoolWallet string) (*KaspaApi, error)

func (*KaspaApi) GetBlockTemplate

func (*KaspaApi) Start

func (ks *KaspaApi) Start(ctx context.Context, blockCb func())

type MiningState

type MiningState struct {
	Jobs    map[int]*appmessage.RPCBlock
	JobLock sync.Mutex
	// contains filtered or unexported fields
}

func GetMiningState

func GetMiningState(ctx *gostratum.StratumContext) *MiningState

func (*MiningState) AddJob

func (ms *MiningState) AddJob(job *appmessage.RPCBlock) int

func (*MiningState) GetJob

func (ms *MiningState) GetJob(id int) (*appmessage.RPCBlock, bool)

type OraBackend

type OraBackend struct {
	Jobs       map[uint32]OraJob
	JobLock    sync.RWMutex
	FileLock   sync.RWMutex
	JobCounter uint32
	JobDeleted uint32
	Coin       string
	Db         *sql.DB
	// contains filtered or unexported fields
}

func NewOraBackend

func NewOraBackend(coin string, logger *zap.SugaredLogger, connstr string) (*OraBackend, error)

func (*OraBackend) AddJob

func (ob *OraBackend) AddJob(jobType string, jobText string)

func (*OraBackend) AddObj

func (ob *OraBackend) AddObj(jobType string, jobObj any)

type OraJob

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

type SubmitBlockDbQuery

type SubmitBlockDbQuery struct {
	CurrentTime string
	SesUid      string
	BlockState  string
	BlockHash   string
}

type SubmitShareDbQuery

type SubmitShareDbQuery struct {
	CurrentTime string
	SesUid      string
	ShareState  string
	Difficulty  float64
}

Jump to

Keyboard shortcuts

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