storage

package
v0.0.0-...-65b2192 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockData

type BlockData struct {
	Login          string   `json:"login"`
	Height         int64    `json:"height"`
	Timestamp      int64    `json:"timestamp"`
	Difficulty     int64    `json:"difficulty"`
	TotalShares    int64    `json:"shares"`
	Uncle          bool     `json:"uncle"`
	UncleHeight    int64    `json:"uncleHeight"`
	Orphan         bool     `json:"orphan"`
	Hash           string   `json:"hash"`
	Nonce          string   `json:"-"`
	PowHash        string   `json:"-"`
	MixDigest      string   `json:"-"`
	Reward         *big.Int `json:"-"`
	ExtraReward    *big.Int `json:"-"`
	ImmatureReward string   `json:"-"`
	RewardString   string   `json:"reward"`
	RoundHeight    int64    `json:"-"`
	// contains filtered or unexported fields
}

func (*BlockData) RewardInShannon

func (b *BlockData) RewardInShannon() int64

func (*BlockData) RoundKey

func (b *BlockData) RoundKey() string

type Config

type Config struct {
	Endpoint string `json:"endpoint"`
	Password string `json:"password"`
	Database int64  `json:"database"`
	PoolSize int    `json:"poolSize"`
}

type LuckCharts

type LuckCharts struct {
	Timestamp  int64   `json:"x"`
	Height     int64   `json:"height"`
	Difficulty int64   `json:"difficulty"`
	Shares     int64   `json:"shares"`
	SharesDiff float64 `json:"sharesDiff"`
	Reward     string  `json:"reward"`
}

type Miner

type Miner struct {
	LastBeat int64 `json:"lastBeat"`
	HR       int64 `json:"hr"`
	Offline  bool  `json:"offline"`

	Blocks int64 `json:"blocks"`
	// contains filtered or unexported fields
}

type MinerCharts

type MinerCharts struct {
	Timestamp      int64  `json:"x"`
	TimeFormat     string `json:"timeFormat"`
	MinerHash      int64  `json:"minerHash"`
	MinerLargeHash int64  `json:"minerLargeHash"`
	WorkerOnline   string `json:"workerOnline"`
}

type NetCharts

type NetCharts struct {
	Timestamp  int64  `json:"x"`
	TimeFormat string `json:"timeFormat"`
	NetHash    int64  `json:"y"`
}

type PaymentCharts

type PaymentCharts struct {
	Timestamp  int64  `json:"x"`
	TimeFormat string `json:"timeFormat"`
	Amount     int64  `json:"amount"`
}

type PendingPayment

type PendingPayment struct {
	Timestamp int64  `json:"timestamp"`
	Amount    int64  `json:"amount"`
	Address   string `json:"login"`
}

type PoolCharts

type PoolCharts struct {
	Timestamp  int64  `json:"x"`
	TimeFormat string `json:"timeFormat"`
	PoolHash   int64  `json:"y"`
}

type RedisClient

type RedisClient struct {
	CoinName string
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient(cfg *Config, prefix string, pplns int64, CoinName string) *RedisClient

func (*RedisClient) BgSave

func (r *RedisClient) BgSave() (string, error)

func (*RedisClient) Check

func (r *RedisClient) Check() (string, error)

func (*RedisClient) Client

func (r *RedisClient) Client() *redis.Client

func (*RedisClient) CollectLuckCharts

func (r *RedisClient) CollectLuckCharts(max int) (stats []*LuckCharts, err error)

func (*RedisClient) CollectLuckStats

func (r *RedisClient) CollectLuckStats(windows []int) (map[string]interface{}, error)

func (*RedisClient) CollectStats

func (r *RedisClient) CollectStats(smallWindow time.Duration, maxBlocks, maxPayments int64) (map[string]interface{}, error)

func (*RedisClient) CollectWorkersStats

func (r *RedisClient) CollectWorkersStats(sWindow, lWindow time.Duration, login string) (map[string]interface{}, error)

func (*RedisClient) FlushStaleStats

func (r *RedisClient) FlushStaleStats(window, largeWindow time.Duration) (int64, error)

WARNING: Must run it periodically to flush out of window hashrate entries

func (*RedisClient) GetAllMinerAccount

func (r *RedisClient) GetAllMinerAccount() (account []string, err error)

func (*RedisClient) GetBalance

func (r *RedisClient) GetBalance(login string) (int64, error)

func (*RedisClient) GetBlacklist

func (r *RedisClient) GetBlacklist() ([]string, error)

Always returns list of addresses. If Redis fails it will return empty list.

func (*RedisClient) GetCandidates

func (r *RedisClient) GetCandidates(maxHeight int64) ([]*BlockData, error)

func (*RedisClient) GetCurrentHashrate

func (r *RedisClient) GetCurrentHashrate(login string) (int64, error)

func (*RedisClient) GetExchangeData

func (r *RedisClient) GetExchangeData(coinsymbol string) (map[string]string, error)

func (*RedisClient) GetImmatureBlocks

func (r *RedisClient) GetImmatureBlocks(maxHeight int64) ([]*BlockData, error)

func (*RedisClient) GetMinerCharts

func (r *RedisClient) GetMinerCharts(hashNum int64, login string) (stats []*MinerCharts, err error)

func (*RedisClient) GetMinerStats

func (r *RedisClient) GetMinerStats(login string, maxPayments int64) (map[string]interface{}, error)

func (*RedisClient) GetNetCharts

func (r *RedisClient) GetNetCharts(netHashLen int64) (stats []*NetCharts, err error)

func (*RedisClient) GetNodeStates

func (r *RedisClient) GetNodeStates() ([]map[string]interface{}, error)

func (*RedisClient) GetPayees

func (r *RedisClient) GetPayees() ([]string, error)

func (*RedisClient) GetPaymentCharts

func (r *RedisClient) GetPaymentCharts(login string) (stats []*PaymentCharts, err error)

func (*RedisClient) GetPendingPayments

func (r *RedisClient) GetPendingPayments() []*PendingPayment

func (*RedisClient) GetPoolCharts

func (r *RedisClient) GetPoolCharts(poolHashLen int64) (stats []*PoolCharts, err error)

func (*RedisClient) GetRewards

func (r *RedisClient) GetRewards(login string) ([]*RewardData, error)

func (*RedisClient) GetRoundShares

func (r *RedisClient) GetRoundShares(height int64, nonce string) (map[string]int64, error)

func (*RedisClient) GetShareCharts

func (r *RedisClient) GetShareCharts(shareNum int64, login string) (stats []*ShareCharts, err error)

func (*RedisClient) GetTotalShares

func (r *RedisClient) GetTotalShares() (int64, error)

func (*RedisClient) GetWhitelist

func (r *RedisClient) GetWhitelist() ([]string, error)

Always returns list of IPs. If Redis fails it will return empty list.

func (*RedisClient) IsMinerExists

func (r *RedisClient) IsMinerExists(login string) (bool, error)

func (*RedisClient) IsPayoutsLocked

func (r *RedisClient) IsPayoutsLocked() (bool, error)

func (*RedisClient) LockPayouts

func (r *RedisClient) LockPayouts(login string, amount int64) error

func (*RedisClient) NumberStratumWorker

func (r *RedisClient) NumberStratumWorker(count int)

func (*RedisClient) ResetWorkerShareStatus

func (r *RedisClient) ResetWorkerShareStatus()

Need a function to delete on round end or whatever, and another function to get.

func (*RedisClient) RollbackBalance

func (r *RedisClient) RollbackBalance(login string, amount int64) error

func (*RedisClient) StoreExchangeData

func (r *RedisClient) StoreExchangeData(ExchangeData []map[string]interface{})

func (*RedisClient) UnlockPayouts

func (r *RedisClient) UnlockPayouts() error

func (*RedisClient) UpdateBalance

func (r *RedisClient) UpdateBalance(login string, amount int64) error

Deduct miner's balance for payment

func (*RedisClient) WriteBlock

func (r *RedisClient) WriteBlock(login, id string, params []string, diff, roundDiff int64, height uint64, window time.Duration) (bool, error)

func (*RedisClient) WriteBlocksFound

func (r *RedisClient) WriteBlocksFound(ms, ts int64, login, id, share string, diff int64)

func (*RedisClient) WriteDiffCharts

func (r *RedisClient) WriteDiffCharts(time1 int64, time2 string, netHash string) error

func (*RedisClient) WriteImmatureBlock

func (r *RedisClient) WriteImmatureBlock(block *BlockData, roundRewards map[string]int64) error

func (*RedisClient) WriteMaturedBlock

func (r *RedisClient) WriteMaturedBlock(block *BlockData, roundRewards map[string]int64) error

func (*RedisClient) WriteMinerCharts

func (r *RedisClient) WriteMinerCharts(time1 int64, time2, k string, hash, largeHash, workerOnline int64) error

func (*RedisClient) WriteNodeState

func (r *RedisClient) WriteNodeState(id string, height uint64, diff *big.Int, blocktime float64) error

func (*RedisClient) WriteOrphan

func (r *RedisClient) WriteOrphan(block *BlockData) error

func (*RedisClient) WritePayment

func (r *RedisClient) WritePayment(login, txHash string, amount int64) error

func (*RedisClient) WritePendingOrphans

func (r *RedisClient) WritePendingOrphans(blocks []*BlockData) error

func (*RedisClient) WritePoolCharts

func (r *RedisClient) WritePoolCharts(time1 int64, time2 string, poolHash string) error

func (*RedisClient) WriteReward

func (r *RedisClient) WriteReward(login string, amount int64, percent *big.Rat, immature bool, block *BlockData) error

func (*RedisClient) WriteShare

func (r *RedisClient) WriteShare(login, id string, params []string, diff int64, height uint64, window time.Duration) (bool, error)

func (*RedisClient) WriteShareCharts

func (r *RedisClient) WriteShareCharts(time1 int64, time2, login string, valid, stale, workerOnline int64) error

func (*RedisClient) WriteWorkerShareStatus

func (r *RedisClient) WriteWorkerShareStatus(login string, id string, valid bool, stale bool, invalid bool)

lets try to fuck without understanding and see if it works

type RewardData

type RewardData struct {
	Height    int64   `json:"blockheight"`
	Timestamp int64   `json:"timestamp"`
	BlockHash string  `json:"blockhash"`
	Reward    int64   `json:"reward"`
	Percent   float64 `json:"percent"`
	Immature  bool    `json:"immature"`
}

type ShareCharts

type ShareCharts struct {
	Timestamp    int64  `json:"x"`
	TimeFormat   string `json:"timeFormat"`
	Valid        int64  `json:"valid"`
	Stale        int64  `json:"stale"`
	WorkerOnline string `json:"workerOnline"`
}

type SumRewardData

type SumRewardData struct {
	Interval int64  `json:"inverval"`
	Reward   int64  `json:"reward"`
	Name     string `json:"name"`
	Offset   int64  `json:"offset"`
	Blocks   int64  `json:"blocks"`
}

type TimestampSorter

type TimestampSorter []*LuckCharts

func (TimestampSorter) Len

func (a TimestampSorter) Len() int

func (TimestampSorter) Less

func (a TimestampSorter) Less(i, j int) bool

func (TimestampSorter) Swap

func (a TimestampSorter) Swap(i, j int)

type Worker

type Worker struct {
	Miner
	TotalHR         int64   `json:"hr2"`
	ValidShares     int64   `json:"valid"`
	StaleShares     int64   `json:"stale"`
	InvalidShares   int64   `json:"invalid"`
	ValidPercent    float64 `json:"v_per"`
	StalePercent    float64 `json:"s_per"`
	InvalidPercent  float64 `json:"i_per"`
	WorkerStatus    int64   `json:"w_stat"`
	WorkerStatushas int64   `json:"w_stat_s"`
}

Jump to

Keyboard shortcuts

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