Documentation
¶
Index ¶
- Constants
- Variables
- func GetMaxGlobalError(elapsed time.Duration, minError float64, flatness, skipPeriod time.Duration) float64
- type ContractFactory
- type ContractWatcherBuyer
- func (p *ContractWatcherBuyer) Dest() string
- func (p *ContractWatcherBuyer) Done() <-chan struct{}
- func (p *ContractWatcherBuyer) Err() error
- func (p *ContractWatcherBuyer) Error() error
- func (p *ContractWatcherBuyer) FulfillmentStartTime() time.Time
- func (p *ContractWatcherBuyer) PoolDest() string
- func (p *ContractWatcherBuyer) ResourceEstimates() map[string]float64
- func (p *ContractWatcherBuyer) ResourceEstimatesActual() map[string]float64
- func (p *ContractWatcherBuyer) ResourceType() string
- func (p *ContractWatcherBuyer) Role() resources.ContractRole
- func (p *ContractWatcherBuyer) SetData(terms *hashrateContract.Terms)
- func (p *ContractWatcherBuyer) SetError(err error)
- func (p *ContractWatcherBuyer) StartFulfilling(ctx context.Context)
- func (p *ContractWatcherBuyer) StarvingGHS() int
- func (p *ContractWatcherBuyer) State() resources.ContractState
- func (p *ContractWatcherBuyer) StopFulfilling()
- func (p *ContractWatcherBuyer) ValidationStage() hashrateContract.ValidationStage
- type ContractWatcherSellerV2
- func (p *ContractWatcherSellerV2) Dest() string
- func (p *ContractWatcherSellerV2) Done() <-chan struct{}
- func (p *ContractWatcherSellerV2) Err() error
- func (p *ContractWatcherSellerV2) Error() error
- func (p *ContractWatcherSellerV2) FulfillmentStartTime() time.Time
- func (p *ContractWatcherSellerV2) GetDeliveryLogs() ([]DeliveryLogEntry, error)
- func (p *ContractWatcherSellerV2) IsRunning() bool
- func (p *ContractWatcherSellerV2) PoolDest() string
- func (p *ContractWatcherSellerV2) Reset()
- func (p *ContractWatcherSellerV2) ResourceEstimates() map[string]float64
- func (p *ContractWatcherSellerV2) ResourceEstimatesActual() map[string]float64
- func (p *ContractWatcherSellerV2) ResourceType() string
- func (p *ContractWatcherSellerV2) Role() resources.ContractRole
- func (p *ContractWatcherSellerV2) SetError(err error)
- func (p *ContractWatcherSellerV2) SetTerms(terms *hashrate.Terms)
- func (p *ContractWatcherSellerV2) ShouldBeRunning() bool
- func (p *ContractWatcherSellerV2) StartFulfilling() error
- func (p *ContractWatcherSellerV2) StarvingGHS() int
- func (p *ContractWatcherSellerV2) State() resources.ContractState
- func (p *ContractWatcherSellerV2) StopFulfilling()
- func (p *ContractWatcherSellerV2) ValidationStage() hashrateContract.ValidationStage
- type ControllerBuyer
- type ControllerSeller
- func (c *ControllerSeller) GetTermsFromBlockchain(ctx context.Context) (*hashrateContract.Terms, error)
- func (c *ControllerSeller) LoadTermsFromBlockchain(ctx context.Context) error
- func (c *ControllerSeller) Run(ctx context.Context) error
- func (c *ControllerSeller) SyncState(ctx context.Context) error
- type DeliveryLog
- type DeliveryLogEntry
Constants ¶
View Source
const ( ResourceTypeHashrate = "hashrate" ResourceEstimateHashrateGHS = "hashrate_ghs" )
Variables ¶
View Source
var ( ErrContractDest = errors.New("contract destination error") ErrUnderdelivery = errors.New("contract is not delivering enough hashrate") )
View Source
var ( ErrNotRunningBlockchain = fmt.Errorf("contract is not running in blockchain") ErrStopped = fmt.Errorf("contract is stopped") ErrAlreadyRunning = fmt.Errorf("contract is already running") )
View Source
var (
AdjustmentThresholdGHS = 100.0
)
View Source
var (
ErrContractClosed = errors.New("contract closed")
)
Functions ¶
Types ¶
type ContractFactory ¶
type ContractFactory struct {
// contains filtered or unexported fields
}
func NewContractFactory ¶
func NewContractFactory( allocator *allocator.Allocator, hashrateFactory func() *hashrate.Hashrate, globalHashrate *hashrate.GlobalHashrate, store *contracts.HashrateEthereum, logFactory func(contractID string) (interfaces.ILogger, error), privateKey string, cycleDuration time.Duration, shareTimeout time.Duration, hrErrorThreshold float64, hashrateCounterNameBuyer string, validatorFlatness time.Duration, validatorStartTime time.Time, defaultDest *url.URL, ) (*ContractFactory, error)
func (*ContractFactory) CreateContract ¶
func (c *ContractFactory) CreateContract(contractData *hashrateContract.EncryptedTerms) (resources.Contract, error)
func (*ContractFactory) GetType ¶
func (c *ContractFactory) GetType() resources.ResourceType
type ContractWatcherBuyer ¶
type ContractWatcherBuyer struct { //deps *hashrateContract.Terms // contains filtered or unexported fields }
func NewContractWatcherBuyer ¶
func NewContractWatcherBuyer( terms *hashrateContract.Terms, hashrateFactory func() *hashrate.Hashrate, allocator *allocator.Allocator, globalHashrate *hashrate.GlobalHashrate, log interfaces.ILogger, cycleDuration time.Duration, shareTimeout time.Duration, hrErrorThreshold float64, hashrateCounterNameBuyer string, hrValidationFlatness time.Duration, validatorStartTime time.Time, role resources.ContractRole, defaultDest *url.URL, ) *ContractWatcherBuyer
func (*ContractWatcherBuyer) Dest ¶
func (p *ContractWatcherBuyer) Dest() string
func (*ContractWatcherBuyer) Done ¶
func (p *ContractWatcherBuyer) Done() <-chan struct{}
func (*ContractWatcherBuyer) Err ¶
func (p *ContractWatcherBuyer) Err() error
func (*ContractWatcherBuyer) Error ¶
func (p *ContractWatcherBuyer) Error() error
func (*ContractWatcherBuyer) FulfillmentStartTime ¶
func (p *ContractWatcherBuyer) FulfillmentStartTime() time.Time
func (*ContractWatcherBuyer) PoolDest ¶
func (p *ContractWatcherBuyer) PoolDest() string
func (*ContractWatcherBuyer) ResourceEstimates ¶
func (p *ContractWatcherBuyer) ResourceEstimates() map[string]float64
func (*ContractWatcherBuyer) ResourceEstimatesActual ¶
func (p *ContractWatcherBuyer) ResourceEstimatesActual() map[string]float64
func (*ContractWatcherBuyer) ResourceType ¶
func (p *ContractWatcherBuyer) ResourceType() string
func (*ContractWatcherBuyer) Role ¶
func (p *ContractWatcherBuyer) Role() resources.ContractRole
func (*ContractWatcherBuyer) SetData ¶
func (p *ContractWatcherBuyer) SetData(terms *hashrateContract.Terms)
func (*ContractWatcherBuyer) SetError ¶
func (p *ContractWatcherBuyer) SetError(err error)
func (*ContractWatcherBuyer) StartFulfilling ¶
func (p *ContractWatcherBuyer) StartFulfilling(ctx context.Context)
func (*ContractWatcherBuyer) StarvingGHS ¶
func (p *ContractWatcherBuyer) StarvingGHS() int
func (*ContractWatcherBuyer) State ¶
func (p *ContractWatcherBuyer) State() resources.ContractState
func (*ContractWatcherBuyer) StopFulfilling ¶
func (p *ContractWatcherBuyer) StopFulfilling()
func (*ContractWatcherBuyer) ValidationStage ¶
func (p *ContractWatcherBuyer) ValidationStage() hashrateContract.ValidationStage
type ContractWatcherSellerV2 ¶
type ContractWatcherSellerV2 struct { // deps *hashrate.Terms // contains filtered or unexported fields }
func NewContractWatcherSellerV2 ¶
func NewContractWatcherSellerV2(terms *hashrateContract.Terms, cycleDuration time.Duration, hashrateFactory func() *hr.Hashrate, allocator *allocator.Allocator, log interfaces.ILogger) *ContractWatcherSellerV2
func (*ContractWatcherSellerV2) Dest ¶
func (p *ContractWatcherSellerV2) Dest() string
terms getters
func (*ContractWatcherSellerV2) Done ¶
func (p *ContractWatcherSellerV2) Done() <-chan struct{}
func (*ContractWatcherSellerV2) Err ¶
func (p *ContractWatcherSellerV2) Err() error
func (*ContractWatcherSellerV2) Error ¶
func (p *ContractWatcherSellerV2) Error() error
func (*ContractWatcherSellerV2) FulfillmentStartTime ¶
func (p *ContractWatcherSellerV2) FulfillmentStartTime() time.Time
state getters
func (*ContractWatcherSellerV2) GetDeliveryLogs ¶
func (p *ContractWatcherSellerV2) GetDeliveryLogs() ([]DeliveryLogEntry, error)
func (*ContractWatcherSellerV2) IsRunning ¶
func (p *ContractWatcherSellerV2) IsRunning() bool
func (*ContractWatcherSellerV2) PoolDest ¶
func (p *ContractWatcherSellerV2) PoolDest() string
func (*ContractWatcherSellerV2) Reset ¶
func (p *ContractWatcherSellerV2) Reset()
Reset resets the contract state
func (*ContractWatcherSellerV2) ResourceEstimates ¶
func (p *ContractWatcherSellerV2) ResourceEstimates() map[string]float64
func (*ContractWatcherSellerV2) ResourceEstimatesActual ¶
func (p *ContractWatcherSellerV2) ResourceEstimatesActual() map[string]float64
func (*ContractWatcherSellerV2) ResourceType ¶
func (p *ContractWatcherSellerV2) ResourceType() string
func (*ContractWatcherSellerV2) Role ¶
func (p *ContractWatcherSellerV2) Role() resources.ContractRole
constants
func (*ContractWatcherSellerV2) SetError ¶
func (p *ContractWatcherSellerV2) SetError(err error)
func (*ContractWatcherSellerV2) SetTerms ¶
func (p *ContractWatcherSellerV2) SetTerms(terms *hashrate.Terms)
terms setters
func (*ContractWatcherSellerV2) ShouldBeRunning ¶
func (p *ContractWatcherSellerV2) ShouldBeRunning() bool
func (*ContractWatcherSellerV2) StartFulfilling ¶
func (p *ContractWatcherSellerV2) StartFulfilling() error
func (*ContractWatcherSellerV2) StarvingGHS ¶
func (p *ContractWatcherSellerV2) StarvingGHS() int
func (*ContractWatcherSellerV2) State ¶
func (p *ContractWatcherSellerV2) State() resources.ContractState
func (*ContractWatcherSellerV2) StopFulfilling ¶
func (p *ContractWatcherSellerV2) StopFulfilling()
func (*ContractWatcherSellerV2) ValidationStage ¶
func (p *ContractWatcherSellerV2) ValidationStage() hashrateContract.ValidationStage
type ControllerBuyer ¶
type ControllerBuyer struct { *ContractWatcherBuyer // contains filtered or unexported fields }
func NewControllerBuyer ¶
func NewControllerBuyer(contract *ContractWatcherBuyer, store *contracts.HashrateEthereum, privKey string, autoClaimReward bool) *ControllerBuyer
func (*ControllerBuyer) LoadTermsFromBlockchain ¶
func (c *ControllerBuyer) LoadTermsFromBlockchain(ctx context.Context) error
LoadTermsFromBlockchain loads terms from blockchain and decrypts destination pool if exists
type ControllerSeller ¶
type ControllerSeller struct { *ContractWatcherSellerV2 // contains filtered or unexported fields }
func NewControllerSeller ¶
func NewControllerSeller(contract *ContractWatcherSellerV2, store *contracts.HashrateEthereum, privKey string) *ControllerSeller
func (*ControllerSeller) GetTermsFromBlockchain ¶
func (c *ControllerSeller) GetTermsFromBlockchain(ctx context.Context) (*hashrateContract.Terms, error)
func (*ControllerSeller) LoadTermsFromBlockchain ¶
func (c *ControllerSeller) LoadTermsFromBlockchain(ctx context.Context) error
LoadTermsFromBlockchain loads terms from blockchain and decrypts them, if decryption fails, still updates terms with nil dest
type DeliveryLog ¶
type DeliveryLog struct { Entries []DeliveryLogEntry // contains filtered or unexported fields }
func NewDeliveryLog ¶
func NewDeliveryLog() *DeliveryLog
func (*DeliveryLog) AddEntry ¶
func (l *DeliveryLog) AddEntry(entry DeliveryLogEntry)
func (*DeliveryLog) GetEntries ¶
func (l *DeliveryLog) GetEntries() ([]DeliveryLogEntry, error)
type DeliveryLogEntry ¶
Click to show internal directories.
Click to hide internal directories.