types

package
v0.0.0-...-5ed304f Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownInputType = fmt.Errorf("unknown input type")
)

Functions

func BoolPtr

func BoolPtr(v bool) *bool

func BoolValue

func BoolValue(v *bool) bool

func Float32Ptr

func Float32Ptr(v float32) *float32

func Float32Value

func Float32Value(v *float32) float32

func Float64Ptr

func Float64Ptr(v float64) *float64

func Float64Value

func Float64Value(v *float64) float64

func Int32Ptr

func Int32Ptr(v int32) *int32

func Int32alue

func Int32alue(v *int32) int32

func Int64Ptr

func Int64Ptr(v int64) *int64

func Int64Value

func Int64Value(v *int64) int64

func IntPtr

func IntPtr(v int) *int

func IntValue

func IntValue(v *int) int

func StringPtr

func StringPtr(v string) *string

func StringValue

func StringValue(v *string) string

func TimePtr

func TimePtr(v time.Time) *time.Time

func TimeValue

func TimeValue(v *time.Time) time.Time

func Uint32Ptr

func Uint32Ptr(v uint32) *uint32

func Uint32Value

func Uint32Value(v *uint32) uint32

func Uint64Ptr

func Uint64Ptr(v uint64) *uint64

func Uint64Value

func Uint64Value(v *uint64) uint64

func UintPtr

func UintPtr(v uint) *uint

func UintValue

func UintValue(v *uint) uint

Types

type AccountingType

type AccountingType int
const (
	UTXOStructure AccountingType = iota
	AccountStructure
)

type BlockBuilder

type BlockBuilder interface {
	SerializeHeader(work *StratumWork) ([]byte, []byte, error)
	SerializeBlock(work *StratumWork) ([]byte, error)
	PartialJob() []interface{}
}

type Deposit

type Deposit struct {
	ID        string
	TxID      string
	Value     string
	Fee       string
	Completed bool
}

type Difficulty

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

func (*Difficulty) Bits

func (d *Difficulty) Bits() uint32

func (*Difficulty) Mul

func (d *Difficulty) Mul(factor int64) *Difficulty

func (*Difficulty) SetFromBig

func (d *Difficulty) SetFromBig(targetBig *big.Int, maxDiffBig *big.Int) *Difficulty

func (*Difficulty) SetFromBits

func (d *Difficulty) SetFromBits(bits uint32, maxDiffBig *big.Int) *Difficulty

func (*Difficulty) SetFromValue

func (d *Difficulty) SetFromValue(value uint64, maxDiffBig *big.Int) *Difficulty

func (*Difficulty) TargetBig

func (d *Difficulty) TargetBig() *big.Int

func (*Difficulty) TargetHex

func (d *Difficulty) TargetHex() string

func (*Difficulty) TargetPrefixedHex

func (d *Difficulty) TargetPrefixedHex() string

func (*Difficulty) Value

func (d *Difficulty) Value() uint64

type EarningMetric

type EarningMetric string
const (
	EarningValue        EarningMetric = "value"
	EarningAverageValue EarningMetric = "avg_value"
)

func ParseEarningMetric

func ParseEarningMetric(raw string) (EarningMetric, error)

type Exchange

type Exchange interface {
	ID() ExchangeID
	GetTradeTimeout() time.Duration

	// account
	GetAccountStatus() error

	// rate
	GetRate(string) (float64, error)
	GetHistoricalRates(string, time.Time, time.Time, bool) (map[time.Time]float64, error)
	GetOutputThresholds() map[string]*big.Int
	GetPrices(map[string]map[string]*big.Int) (map[string]map[string]float64, error)

	// wallet
	GetWalletStatus(string) (bool, bool, error)
	GetWalletBalance(string) (float64, float64, error)

	// deposit
	GetDepositAddress(string) (string, error)
	GetDepositByTxID(string, string) (*Deposit, error)
	GetDepositByID(string, string) (*Deposit, error)

	// transfer
	TransferToTradeAccount(string, float64) error
	TransferToMainAccount(string, float64) error

	// trade
	GenerateTradePath(string, string) ([]*Trade, error)
	CreateTrade(string, TradeDirection, float64) (string, error)
	GetTradeByID(string, string, float64) (*Trade, error)
	CancelTradeByID(string, string) error

	// withdrawal
	CreateWithdrawal(string, string, float64) (string, error)
	GetWithdrawalByID(string, string) (*Withdrawal, error)
	NeedsWithdrawalFeeSubtraction() bool
}

type ExchangeID

type ExchangeID int
const (
	BinanceID ExchangeID = iota
	KucoinID
	BittrexID
	MEXCGlobalID
)

type Hash

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

func (*Hash) Big

func (h *Hash) Big() *big.Int

func (*Hash) Bytes

func (h *Hash) Bytes() []byte

func (*Hash) Difficulty

func (h *Hash) Difficulty(maxDiff *big.Int) uint64

func (*Hash) Hex

func (h *Hash) Hex() string

func (*Hash) MeetsDifficulty

func (h *Hash) MeetsDifficulty(diff *Difficulty) bool

func (*Hash) PrefixedHex

func (h *Hash) PrefixedHex() string

func (*Hash) SetFromBytes

func (h *Hash) SetFromBytes(value []byte) *Hash

func (*Hash) SetFromHex

func (h *Hash) SetFromHex(value string) (*Hash, error)

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

type Market

type Market struct {
	Market    string
	Base      string
	Quote     string
	Direction TradeDirection
}

type MiningNode

type MiningNode interface {
	PayoutNode
	Mocked() bool
	HandleHostPoolInfoRequest(http.ResponseWriter, *http.Request)

	// constants
	GetShareDifficulty(int) *Difficulty
	GetAdjustedShareDifficulty() float64
	GetMaxDifficulty() *big.Int
	GetImmatureDepth() uint64
	GetMatureDepth() uint64
	CalculateHashrate(float64, float64) float64

	// stratum helpers
	GetSubscribeResponses([]byte, string, string) ([]interface{}, error)
	GetAuthorizeResponses(int) ([]interface{}, error)
	GetSetDifficultyResponse(int) (interface{}, error)
	GetClientType(string) int
	MarshalJob(interface{}, *StratumJob, bool, int, int) (interface{}, error)
	ParseWork([]json.RawMessage, string) (*StratumWork, error)

	// mining helpers
	GetBlockExplorerURL(*pooldb.Round) string
	GetStatus() (uint64, bool, error)
	PingHosts() ([]string, []uint64, []bool, []error)
	GetBlocks(uint64, uint64) ([]*tsdb.RawBlock, error)
	GetBlocksByHash(string, uint64) ([]*tsdb.RawBlock, error)
	JobNotify(context.Context, time.Duration) chan *StratumJob
	SubmitWork(*StratumJob, *StratumWork, int) (ShareStatus, *Hash, *pooldb.Round, error)
	UnlockRound(*pooldb.Round) error
	MatureRound(*pooldb.Round) ([]*pooldb.UTXO, error)
}

type NetworkMetric

type NetworkMetric string
const (
	NetworkValue         NetworkMetric = "value"
	NetworkDifficulty    NetworkMetric = "difficulty"
	NetworkBlockTime     NetworkMetric = "block_time"
	NetworkHashrate      NetworkMetric = "hashrate"
	NetworkProfitability NetworkMetric = "profitability"
	NetworkEmission      NetworkMetric = "emission"
)

func ParseNetworkMetric

func ParseNetworkMetric(raw string) (NetworkMetric, error)

type Number

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

func (*Number) Big

func (n *Number) Big() *big.Int

func (*Number) BytesBE

func (n *Number) BytesBE() []byte

func (*Number) BytesLE

func (n *Number) BytesLE() []byte

func (*Number) Hex

func (n *Number) Hex() string

func (*Number) PrefixedHex

func (n *Number) PrefixedHex() string

func (*Number) SetFromBytes

func (n *Number) SetFromBytes(value []byte) *Number

note that the uint64 will not fit if the value is greater than a uint64, even though we allow the full precision to be stored in the big int

func (*Number) SetFromHex

func (n *Number) SetFromHex(value string) (*Number, error)

func (*Number) SetFromString

func (n *Number) SetFromString(value string) (*Number, error)

func (*Number) SetFromValue

func (n *Number) SetFromValue(value uint64) *Number

func (*Number) UnmarshalJSON

func (n *Number) UnmarshalJSON(data []byte) error

func (*Number) Value

func (n *Number) Value() uint64

type PayoutNode

type PayoutNode interface {
	Name() string
	Chain() string
	Address() string
	GetUnits() *Number
	GetAccountingType() AccountingType
	GetAddressPrefix() string
	ShouldMergeUTXOs() bool
	ValidateAddress(string) bool

	// tx helpers
	GetTxExplorerURL(string) string
	GetAddressExplorerURL(string) string
	GetBalance() (*big.Int, error)
	GetTx(string) (*TxResponse, error)
	CreateTx([]*TxInput, []*TxOutput) (string, string, error)
	BroadcastTx(string) (string, error)
}

type PeriodType

type PeriodType int
const (
	Period15m PeriodType = iota
	Period1h
	Period4h
	Period1d
)

func ParsePeriodType

func ParsePeriodType(raw string) (PeriodType, error)

func (PeriodType) Average

func (t PeriodType) Average() time.Duration

func (PeriodType) AverageWindow

func (t PeriodType) AverageWindow() int

func (PeriodType) GenerateRange

func (t PeriodType) GenerateRange(endTime time.Time) map[time.Time]bool

func (PeriodType) Retention

func (t PeriodType) Retention() time.Duration

func (PeriodType) RetentionWindow

func (t PeriodType) RetentionWindow() int

func (PeriodType) Rollup

func (t PeriodType) Rollup() time.Duration

type ShareMetric

type ShareMetric string
const (
	ShareHashrate        ShareMetric = "hashrate"
	ShareAverageHashrate ShareMetric = "avg_hashrate"
	ShareAcceptedCount   ShareMetric = "accepted_adjusted_shares"
	ShareRejectedCount   ShareMetric = "rejected_adjusted_shares"
	ShareRejectedRate    ShareMetric = "accepted_adjusted_shares, rejected_adjusted_shares"
)

func ParseShareMetric

func ParseShareMetric(raw string) (ShareMetric, error)

type ShareStatus

type ShareStatus int
const (
	AcceptedShare ShareStatus = iota
	RejectedShare
	InvalidShare
)

func (ShareStatus) String

func (status ShareStatus) String() string

type Solution

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

func (*Solution) Data

func (s *Solution) Data() []uint64

func (*Solution) Hex

func (s *Solution) Hex() string

func (*Solution) PrefixedHex

func (s *Solution) PrefixedHex() string

func (*Solution) SetFromData

func (s *Solution) SetFromData(data []uint64) *Solution

func (*Solution) SetFromHex

func (s *Solution) SetFromHex(raw string) (*Solution, error)

func (*Solution) Size

func (s *Solution) Size() int

func (*Solution) UnmarshalJSON

func (s *Solution) UnmarshalJSON(data []byte) error

type StratumJob

type StratumJob struct {
	HostID       string
	ID           string
	Header       *Hash
	HeaderHash   *Hash
	Seed         *Hash
	Height       *Number
	Difficulty   *Difficulty
	Timestamp    time.Time
	Version      *Number
	BlockBuilder BlockBuilder
	CoinbaseTxID *Hash
	Data         interface{} // @TODO: fix this (allow you to store a struct of a lot of data [for AE/KAS])
}

type StratumWork

type StratumWork struct {
	WorkerID         string
	JobID            string
	Nonce            *Number
	Hash             *Hash
	MixDigest        *Hash     // for ethash/progpow
	CuckooSolution   *Solution // for cuckoo
	EquihashSolution []byte    // for equihash
}

type Trade

type Trade struct {
	ID        string
	FromChain string
	ToChain   string
	Market    string
	Direction TradeDirection
	Increment int

	Value    string
	Proceeds string
	Fees     string
	Price    string

	Completed bool
	Active    bool
	Cancelled bool
}

type TradeDirection

type TradeDirection int
const (
	TradeBuy TradeDirection = iota
	TradeSell
)

func (TradeDirection) String

func (d TradeDirection) String() string

type TradeStrategy

type TradeStrategy int
const (
	TradeMarket TradeStrategy = iota
	TradeLimit
	TradeLimitMarket
	TradeExpiringLimitToLimitMarket
)

type TransactionType

type TransactionType int
const (
	DepositTx TransactionType = iota
	PayoutTx
	MergeTx
)

type TxInput

type TxInput struct {
	Index      uint32
	Hash       string
	Value      *big.Int
	FeeBalance *big.Int
	Data       []byte
}

type TxOutput

type TxOutput struct {
	Address    string
	Value      *big.Int
	Fee        *big.Int
	FeeBalance *big.Int
	SplitFee   bool
}

type TxResponse

type TxResponse struct {
	Hash        string
	BlockHash   string
	BlockNumber uint64
	From        string
	To          string
	Value       *big.Int
	Fee         *big.Int
	FeeBalance  *big.Int
	Confirmed   bool
	Outputs     []*UTXOResponse
}

type UTXOResponse

type UTXOResponse struct {
	Hash    string
	Index   uint32
	Value   uint64
	Address string
}

type Withdrawal

type Withdrawal struct {
	ID        string
	TxID      string
	Value     string
	Fee       string
	Completed bool
}

Jump to

Keyboard shortcuts

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