Documentation
¶
Index ¶
- Constants
- Variables
- type Allocator
- func (p *Allocator) AddVettedListener(f func(ID string)) ListenerHandle
- func (p *Allocator) AllocateFullMinersForHR(ID string, hrGHS float64, dest *url.URL, duration time.Duration, ...) (minerIDs []string, deltaGHS float64)
- func (p *Allocator) AllocatePartialForJob(ID string, jobNeeded float64, dest *url.URL, cycleEndTimeout time.Duration, ...) (minerIDJob MinerIDJob, remainderGHS float64)
- func (p *Allocator) GetMiners() *lib.Collection[*Scheduler]
- func (p *Allocator) GetMinersFulfillingContract(contractID string, cycleDuration time.Duration) []*MinerItemJobScheduled
- func (p *Allocator) InvokeVettedListeners(minerID string)
- func (p *Allocator) RemoveVettedListener(s ListenerHandle)
- type DestItem
- type HashrateFactory
- type ListenerHandle
- type MinerIDJob
- type MinerItem
- type MinerItemJobScheduled
- type MinerStatus
- type MinerTask
- type OnDisconnectCb
- type OnEndCb
- type OnSubmitCb
- type Scheduler
- func (p *Scheduler) AddTask(ID string, dest *url.URL, jobSubmitted float64, onSubmit OnSubmitCb, ...)
- func (p *Scheduler) GetConnectedAt() time.Time
- func (p *Scheduler) GetCurrentDest() *url.URL
- func (p *Scheduler) GetCurrentDifficulty() float64
- func (p *Scheduler) GetDestConns() *map[string]string
- func (p *Scheduler) GetDestinations(cycleDuration time.Duration) []*DestItem
- func (p *Scheduler) GetHashrate() proxy.Hashrate
- func (p *Scheduler) GetID() string
- func (p *Scheduler) GetJobCouldBeScheduledTill(interval time.Duration) float64
- func (p *Scheduler) GetStats() interface{}
- func (p *Scheduler) GetStatus(cycleDuration time.Duration) MinerStatus
- func (p *Scheduler) GetTaskCount() int
- func (p *Scheduler) GetTasksByID(ID string) []*MinerTask
- func (p *Scheduler) GetTotalScheduledJob() float64
- func (p *Scheduler) GetUptime() time.Duration
- func (p *Scheduler) GetUsedHashrate() proxy.Hashrate
- func (p *Scheduler) GetWorkerName() string
- func (p *Scheduler) HashrateGHS() float64
- func (p *Scheduler) ID() string
- func (p *Scheduler) IsAcceptingTasks(duration time.Duration) bool
- func (p *Scheduler) IsBusy(cycleDuration time.Duration) bool
- func (p *Scheduler) IsDisconnecting() bool
- func (p *Scheduler) IsFree() bool
- func (p *Scheduler) IsPartialBusy(cycleDuration time.Duration) bool
- func (p *Scheduler) IsVetting() bool
- func (p *Scheduler) RemoveTasksByID(ID string)
- func (p *Scheduler) Run(ctx context.Context) error
- func (p *Scheduler) SetPrimaryDest(dest *url.URL)
- type StratumProxyInterface
- type TaskList
- func (p *TaskList) Add(ID string, dest *url.URL, job float64, deadline time.Time, onSubmit OnSubmitCb, ...) int
- func (p *TaskList) Cancel(contractID string)
- func (p *TaskList) CancelAll()
- func (p *TaskList) LockNextTask() (t *MinerTask, ok bool)
- func (p *TaskList) Range(f func(task *MinerTask) bool)
- func (p *TaskList) Size() int
- func (p *TaskList) Unlock()
- func (p *TaskList) UnlockAndRemove()
Constants ¶
View Source
const ( HashratePredictionAdjustment = 1.0 AllocationMinDuration = 5 * time.Second AllocationMinJob = 5000.0 )
Variables ¶
View Source
var ( ErrConnPrimary = errors.New("failed to connect to primary dest") ErrConnDest = errors.New("failed to connect to dest") ErrProxyExited = errors.New("proxy exited") ErrTaskDeadlineExceeded = errors.New("task deadline exceeded") ErrTaskMinerDisconnected = errors.New("miner disconnected") )
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
func NewAllocator ¶
func (*Allocator) AddVettedListener ¶
func (p *Allocator) AddVettedListener(f func(ID string)) ListenerHandle
func (*Allocator) AllocateFullMinersForHR ¶
func (*Allocator) AllocatePartialForJob ¶
func (*Allocator) GetMinersFulfillingContract ¶
func (p *Allocator) GetMinersFulfillingContract(contractID string, cycleDuration time.Duration) []*MinerItemJobScheduled
func (*Allocator) InvokeVettedListeners ¶
func (*Allocator) RemoveVettedListener ¶
func (p *Allocator) RemoveVettedListener(s ListenerHandle)
type HashrateFactory ¶
type ListenerHandle ¶
type ListenerHandle int
type MinerIDJob ¶
type MinerItemJobScheduled ¶
type MinerStatus ¶
type MinerStatus uint8
const ( MinerStatusVetting MinerStatus = iota // vetting period MinerStatusFree // serving default pool MinerStatusBusy // fully or partially serving contract(s) MinerStatusPartialBusy // partially serving contract(s) MinerStatusDisconnecting // error or connection closeout caused the miner to disconnect, it might be briefly available in miners collection )
func (MinerStatus) String ¶
func (m MinerStatus) String() string
type MinerTask ¶
type MinerTask struct { ID string Dest *url.URL Job float64 Deadline time.Time OnSubmit OnSubmitCb OnDisconnect OnDisconnectCb OnEnd OnEndCb RemainingJobToSubmit *atomic.Int64 // contains filtered or unexported fields }
func NewTask ¶
func NewTask(ID string, dest *url.URL, job float64, deadline time.Time, onSubmit OnSubmitCb, onDisconnect OnDisconnectCb, onEnd OnEndCb) *MinerTask
func (*MinerTask) RemainingJob ¶
type OnDisconnectCb ¶
type OnSubmitCb ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a proxy wrapper that can schedule one-time tasks to different destinations
func NewScheduler ¶
func NewScheduler(proxy StratumProxyInterface, hashrateCounterID string, defaultDest *url.URL, minerVettingShares int, hashrateFactory HashrateFactory, onVetted func(ID string), onDestErr func(contractID *string, err error), log interfaces.ILogger) *Scheduler
func (*Scheduler) AddTask ¶
func (p *Scheduler) AddTask( ID string, dest *url.URL, jobSubmitted float64, onSubmit OnSubmitCb, onDisconnect OnDisconnectCb, onEnd OnEndCb, deadline time.Time, )
AddTask adds new task to the queue
func (*Scheduler) GetConnectedAt ¶
func (*Scheduler) GetCurrentDest ¶
func (*Scheduler) GetCurrentDifficulty ¶
func (*Scheduler) GetDestConns ¶
func (*Scheduler) GetDestinations ¶
func (*Scheduler) GetHashrate ¶
func (*Scheduler) GetJobCouldBeScheduledTill ¶
func (*Scheduler) GetStatus ¶
func (p *Scheduler) GetStatus(cycleDuration time.Duration) MinerStatus
func (*Scheduler) GetTaskCount ¶
func (*Scheduler) GetTasksByID ¶
func (*Scheduler) GetTotalScheduledJob ¶
func (*Scheduler) GetUsedHashrate ¶
func (*Scheduler) GetWorkerName ¶
func (*Scheduler) HashrateGHS ¶
HashrateGHS returns hashrate in GHS
func (*Scheduler) IsAcceptingTasks ¶
AcceptsTasks returns true if there are vacant space for tasks for provided interval
func (*Scheduler) IsDisconnecting ¶
func (*Scheduler) IsPartialBusy ¶
func (*Scheduler) RemoveTasksByID ¶
func (*Scheduler) SetPrimaryDest ¶
SetPrimaryDest is not protected by mutex
type StratumProxyInterface ¶
type StratumProxyInterface interface { Connect(ctx context.Context) error // deprecated ConnectDest(ctx context.Context, newDestURL *url.URL) error Run(ctx context.Context) error SetDest(ctx context.Context, dest *url.URL, onSubmit func(diff float64)) error SetDestWithoutAutoread(ctx context.Context, dest *url.URL, onSubmit func(diff float64)) error GetID() string GetHashrate() proxy.Hashrate GetDifficulty() float64 GetDest() *url.URL GetSourceWorkerName() string GetDestWorkerName() string GetMinerConnectedAt() time.Time GetStats() map[string]int GetDestConns() *map[string]string IsVetting() bool VettingDone() <-chan struct{} GetIncomingContractID() *string }
type TaskList ¶
type TaskList struct {
// contains filtered or unexported fields
}
func NewTaskList ¶
func NewTaskList() *TaskList
func (*TaskList) LockNextTask ¶
returns the first element of the task queue
func (*TaskList) UnlockAndRemove ¶
func (p *TaskList) UnlockAndRemove()
removes lock and removes from the task queue
Click to show internal directories.
Click to hide internal directories.