hashrate

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDestURL    = fmt.Errorf("invalid url")
	ErrCannotDecryptDest = fmt.Errorf("cannot decrypt")
)

Functions

This section is empty.

Types

type BaseTerms

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

BaseTerms holds the terms of the contract with common methods for both encrypted and decrypted terms

func (*BaseTerms) Balance

func (b *BaseTerms) Balance() *big.Int

func (*BaseTerms) BlockchainState

func (p *BaseTerms) BlockchainState() BlockchainState

func (*BaseTerms) Buyer

func (b *BaseTerms) Buyer() string

func (*BaseTerms) Copy

func (b *BaseTerms) Copy() *BaseTerms

func (*BaseTerms) Duration

func (b *BaseTerms) Duration() time.Duration

func (*BaseTerms) Elapsed

func (p *BaseTerms) Elapsed() time.Duration

func (*BaseTerms) EndTime

func (p *BaseTerms) EndTime() time.Time

func (*BaseTerms) HasFutureTerms

func (b *BaseTerms) HasFutureTerms() bool

func (*BaseTerms) HashrateGHS

func (b *BaseTerms) HashrateGHS() float64

func (*BaseTerms) ID

func (b *BaseTerms) ID() string

func (*BaseTerms) IsDeleted

func (b *BaseTerms) IsDeleted() bool

func (*BaseTerms) Price

func (b *BaseTerms) Price() *big.Int

func (*BaseTerms) PriceLMR

func (b *BaseTerms) PriceLMR() float64

PriceLMR returns price in LMR without decimals

func (*BaseTerms) ProfitTarget

func (b *BaseTerms) ProfitTarget() int8

func (*BaseTerms) ResetStartTime

func (b *BaseTerms) ResetStartTime()

ResetStartTime needed to change internal state after closeout event so contract will be considered not running TODO: refactor for better state handling

func (*BaseTerms) Seller

func (b *BaseTerms) Seller() string

func (*BaseTerms) StartTime

func (b *BaseTerms) StartTime() time.Time

func (*BaseTerms) Validator

func (b *BaseTerms) Validator() string

func (*BaseTerms) Version

func (b *BaseTerms) Version() uint32

type BlockchainState

type BlockchainState int
const (
	BlockchainStateAvailable BlockchainState = 0
	BlockchainStateRunning   BlockchainState = 1
)

func (BlockchainState) String

func (b BlockchainState) String() string

type EncryptedTerms

type EncryptedTerms struct {
	BaseTerms
	ValidatorUrlEncrypted string
	DestEncrypted         string
}

EncryptedTerms holds the terms of the contract where destination is encrypted

func NewTerms

func NewTerms(contractID, seller, buyer string, startsAt time.Time, duration time.Duration, hashrate float64, price *big.Int, profitTarget int8, state BlockchainState, isDeleted bool, balance *big.Int, hasFutureTerms bool, version uint32, validatorUrlEncrypted string, destEncrypted string, validatorAddress string) *EncryptedTerms

func (*EncryptedTerms) Decrypt

func (t *EncryptedTerms) Decrypt(privateKey string) (*Terms, error)

Decrypt decrypts the validator url, if error returns the terms with dest set to nil and error

func (*EncryptedTerms) DecryptPoolDest

func (t *EncryptedTerms) DecryptPoolDest(privateKey string) (*Terms, error)

Decrypt decrypts the destination pool url, if error returns the terms with dest set to nil and error

type Terms

type Terms struct {
	BaseTerms
	ValidatorURL   *url.URL
	DestinationURL *url.URL
}

Terms holds the terms of the contract where destination is decrypted

func (*Terms) Dest

func (p *Terms) Dest() *url.URL

func (*Terms) Encrypt

func (t *Terms) Encrypt(privateKey string) (*Terms, error)

func (*Terms) PoolDest

func (p *Terms) PoolDest() *url.URL

type ValidationStage

type ValidationStage int8
const (
	ValidationStageNotApplicable ValidationStage = 0
	ValidationStageNotValidating ValidationStage = 1
	ValidationStageValidating    ValidationStage = 2
	ValidationStageFinished      ValidationStage = 3
)

func (ValidationStage) String

func (s ValidationStage) String() string

Directories

Path Synopsis
Package avgcounter implements a simple EMA (Exponential Moving Average) counter.
Package avgcounter implements a simple EMA (Exponential Moving Average) counter.

Jump to

Keyboard shortcuts

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