karlsenstratum

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 34 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 GetAverageHashrateGHs

func GetAverageHashrateGHs(stats *WorkStats) float64

func InitInvalidCounter

func InitInvalidCounter(worker *gostratum.StratumContext, errorType string)

func InitWorkerCounters

func InitWorkerCounters(worker *gostratum.StratumContext)

func ListenAndServe

func ListenAndServe(cfg BridgeConfig) error

func MiningStateGenerator

func MiningStateGenerator() any

func RecordBlockFound

func RecordBlockFound(worker *gostratum.StratumContext, nonce, bluescore uint64, hash string)

func RecordDisconnect

func RecordDisconnect(worker *gostratum.StratumContext)

func RecordDupeShare

func RecordDupeShare(worker *gostratum.StratumContext)

func RecordInvalidShare

func RecordInvalidShare(worker *gostratum.StratumContext)

func RecordNetworkStats

func RecordNetworkStats(hashrate uint64, blockCount uint64, difficulty float64)

func RecordNewJob

func RecordNewJob(worker *gostratum.StratumContext)

func RecordShareFound

func RecordShareFound(worker *gostratum.StratumContext, shareDiff float64)

func RecordStaleShare

func RecordStaleShare(worker *gostratum.StratumContext)

func RecordWeakShare

func RecordWeakShare(worker *gostratum.StratumContext)

func RecordWorkerError

func RecordWorkerError(address string, shortError ErrorShortCodeT)

func SerializeBlockHeader

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

func StartPromServer

func StartPromServer(log *zap.SugaredLogger, port string)

func TargetToDiff added in v2.2.0

func TargetToDiff(target *big.Int) float64

Types

type BridgeConfig

type BridgeConfig struct {
	StratumPort     string        `yaml:"stratum_port"`
	RPCServer       string        `yaml:"karlsend_address"`
	PromPort        string        `yaml:"prom_port"`
	PrintStats      bool          `yaml:"print_stats"`
	UseLogFile      bool          `yaml:"log_to_file"`
	HealthCheckPort string        `yaml:"health_check_port"`
	SoloMining      bool          `yaml:"solo_mining"`
	BlockWaitTime   time.Duration `yaml:"block_wait_time"`
	MinShareDiff    uint          `yaml:"min_share_diff"`
	VarDiff         bool          `yaml:"var_diff"`
	SharesPerMin    uint          `yaml:"shares_per_min"`
	VarDiffStats    bool          `yaml:"var_diff_stats"`
	ExtranonceSize  uint          `yaml:"extranonce_size"`
	TestnetMining   bool          `yaml:"testnet_mining"`
}

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 KarlsenApi

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

func NewKarlsenAPI

func NewKarlsenAPI(address string, blockWaitTime time.Duration, logger *zap.SugaredLogger) (*KarlsenApi, error)

func (*KarlsenApi) GetBlockTemplate

func (*KarlsenApi) Start

func (ks *KarlsenApi) 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 WorkStats

type WorkStats struct {
	BlocksFound        atomic.Int64
	SharesFound        atomic.Int64
	SharesDiff         atomic.Float64
	StaleShares        atomic.Int64
	InvalidShares      atomic.Int64
	WorkerName         string
	StartTime          time.Time
	LastShare          time.Time
	VarDiffStartTime   time.Time
	VarDiffSharesFound atomic.Int64
	VarDiffWindow      int
	MinDiff            atomic.Float64
}

Jump to

Keyboard shortcuts

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