ethermine

package module
v0.0.0-...-94abe5b Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 3 Imported by: 0

README

go-ethermine

GoDoc reference GitHub GitHub go.mod Go version

An unoffical golang client for ethermine and their generic pool API.

Getting started

Install
go get -u github.com/thelolagemann/go-ethermine
Example usage
...
// pool interaction
stats, err := Ethermine.Stats()
if err != nil {
    // handle err...
}
fmt.Printf("Ethermine is mining $%.2f an hour!", (stats.PoolStats.BlocksPerHour*5)*stats.Price.USD)
// Output: Ethermine is mining $430049.51 an hour!
...
// miner interaction
miner := Ethermine.Miner("ADDRESS")
stats, err := miner.Stats()
if err != nil {
    // handle err
}
fmt.Printf("Unpaid balance: %v", stats.Unpaid)
...
// worker interaction
worker := miner.Worker("MINER_NAME")
stats, err := worker.Stats()
if err !=- nil {
    // handle err`
}
fmt.Printf("Worker hashrate: %v", stats.CurrentHashrate)

View the godocs for more detailed documentation.

Documentation

Overview

Package ethermine is an unofficial golang client for ethpool, ethermine and flypool, using their generic pool API. View https://api.ethermine.org/docs for detailed documentation of their API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Ethermine default client for Ethermine
	Ethermine = &Pool{"https://api.ethermine.org"}

	// EthermineETC default client for ETC ethermine
	EthermineETC = &Pool{"https://api-etc.ethermine.org"}

	// Flypool default client for flypool
	Flypool = &Pool{"https://api.flypool.org"}

	// Ethpool default client for Ethpool
	Ethpool = &Pool{"https://api.ethpool.org"}
)

Functions

This section is empty.

Types

type Miner

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

Miner is a convenience struct that embeds a Pool alongside a miners address.

func NewMiner

func NewMiner(address string, pool *Pool) *Miner

NewMiner create a new miner with the provided address and pool.

func (*Miner) History

func (m *Miner) History() (res *MinerHistoryResponse, err error)

History returns a historic record of the miners performance, ordered by time ascending.

func (*Miner) Payouts

func (m *Miner) Payouts() (res *MinerPayoutsResponse, err error)

Payouts returns a historic record of the miners payouts, ordered by time ascending.

func (*Miner) Rounds

func (m *Miner) Rounds() (res *MinerRoundsResponse, err error)

Rounds returns a historic record of the miners rounds and the base units allocated to them, ordered by block number descending.

func (*Miner) Settings

func (m *Miner) Settings() (res *MinerSettingsResponse, err error)

Settings returns the miners current settings. Both the email and ip fields will be masked.

func (*Miner) Stats

func (m *Miner) Stats() (res *MinerStatisticsResponse, err error)

Stats returns a historic record of the miners stats, ordered by time ascending.

func (*Miner) Worker

func (m *Miner) Worker(worker string) *Worker

Worker is a convenience function for accessing workers. All it does is return a Worker embedded with the recieving miner and the workers name.

func (*Miner) WorkersMonitor

func (m *Miner) WorkersMonitor() (res []*WorkerStatsResponse, err error)

WorkersMonitor returns a list of the workers currently active under the miner. Note this is for monitoring purposes only and does not provide historical data. Dead workers will be displayed for up to 7 days.

func (*Miner) WorkersStats

func (m *Miner) WorkersStats() (res []*WorkerStatsResponse, err error)

WorkersStats returns all of the miners workers current statistics, ordered by name ascending.

type MinerHistoryResponse

type MinerHistoryResponse []struct {
	Time             int     `json:"time"`
	ReportedHashrate int     `json:"reportedHashrate"`
	CurrentHashrate  float64 `json:"currentHashrate"`
	ValidShares      int     `json:"validShares"`
	InvalidShares    int     `json:"invalidShares"`
	StaleShares      int     `json:"staleShares"`
	AverageHashrate  float64 `json:"averageHashrate"`
	ActiveWorkers    int     `json:"activeWorkers"`
}

MinerHistoryResponse is the json response returned by the /miner/:miner/history endpoint.

type MinerPayoutsResponse

type MinerPayoutsResponse []struct {
	Start  int    `json:"start"`
	End    int    `json:"end"`
	Amount int64  `json:"amount"`
	TxHash string `json:"txHash"`
	PaidOn int    `json:"paidOn"`
}

MinerPayoutsResponse is the json response returned by the /miner/:miner/payouts endpoint.

type MinerRoundsResponse

type MinerRoundsResponse []struct {
	Block  int   `json:"block"`
	Amount int64 `json:"amount"`
}

MinerRoundsResponse is the json response returned by the /miner/:miner/rounds endpoint.

type MinerSettingsResponse

type MinerSettingsResponse struct {
	Monitor   int    `json:"monitor"`
	MinPayout int64  `json:"minPayout"`
	Email     string `json:"email"`
	IP        string `json:"ip"`
}

MinerSettingsResponse is the json response returned by the /miner/:miner/settings endpoint.

type MinerStatisticsResponse

type MinerStatisticsResponse struct {
	Time             int     `json:"time"`
	LastSeen         int     `json:"lastSeen"`
	ReportedHashrate int     `json:"reportedHashrate"`
	CurrentHashrate  float64 `json:"currentHashrate"`
	ValidShares      int     `json:"validShares"`
	InvalidShares    int     `json:"invalidShares"`
	StaleShares      int     `json:"staleShares"`
	AverageHashrate  float64 `json:"averageHashrate"`
	ActiveWorkers    int     `json:"activeWorkers"`
	Unpaid           int64   `json:"unpaid"`
	Unconfirmed      float64 `json:"unconfirmed"`
	CoinsPerMin      float64 `json:"coinsPerMin"`
	UsdPerMin        float64 `json:"usdPerMin"`
	BtcPerMin        float64 `json:"btcPerMin"`
}

MinerStatisticsResponse is the json response returned by the /miner/:miner/currentStats.

type Pool

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

Pool is the base client used for sending requests to the generic API.

func (*Pool) MinedBlocks

func (p *Pool) MinedBlocks() (pRes *PoolMinedBlocksResponse, err error)

MinedBlocks returns a list of blocks mined by the pool, ordered by time ascending.

func (*Pool) Miner

func (p *Pool) Miner(address string) *Miner

Miner returns a Miner with the recieving pool embedded.

func (*Pool) NetworkStats

func (p *Pool) NetworkStats() (pRes *PoolNetworkStatsResponse, err error)

NetworkStats returns current network stats, including hashrate and difficulty.

func (*Pool) ServerHashrate

func (p *Pool) ServerHashrate() (pRes *PoolServerHashrateResponse, err error)

ServerHashrate returns a historic record of the pools hashrate, ordered by time ascending.

func (*Pool) Stats

func (p *Pool) Stats() (pRes *PoolStatsResponse, err error)

Stats returns basic pool stats such as recently mined blocks, current pricing information, hashrate and more.

type PoolMinedBlocksResponse

type PoolMinedBlocksResponse []struct {
	Time       int   `json:"time"`
	NbrBlocks  int   `json:"nbrBlocks"`
	Difficulty int64 `json:"difficulty"`
}

PoolMinedBlocksResponse is the json response returned by the /blocks/history endpoint.

type PoolNetworkStatsResponse

type PoolNetworkStatsResponse struct {
	Time       int     `json:"time"`
	BlockTime  float64 `json:"blockTime"`
	Difficulty int64   `json:"difficulty"`
	Hashrate   int64   `json:"hashrate"`
	USD        float64 `json:"usd"`
	BTC        float64 `json:"btc"`
}

PoolNetworkStatsResponse is the json response returned by the /networkStats endpoint.

type PoolServerHashrateResponse

type PoolServerHashrateResponse []struct {
	Time     int     `json:"time"`
	Server   string  `json:"server"`
	Hashrate float64 `json:"hashrate"`
}

PoolServerHashrateResponse is the json response returned by the /servers/history endpoint.

type PoolStatsResponse

type PoolStatsResponse struct {
	TopMiners   []interface{} `json:"topMiners"`
	MinedBlocks []struct {
		Number int    `json:"number"`
		Miner  string `json:"miner"`
		Time   int    `json:"time"`
	} `json:"minedBlocks"`
	PoolStats struct {
		HashRate      float64 `json:"hashRate"`
		Miners        int     `json:"miners"`
		Workers       int     `json:"workers"`
		BlocksPerHour float64 `json:"blocksPerHour"`
	} `json:"poolStats"`
	Price struct {
		USD float64 `json:"usd"`
		BTC float64 `json:"btc"`
	} `json:"price"`
}

PoolStatsResponse is the json response returned by the /poolStats endpoint.

type Worker

type Worker struct {
	*Miner
	// contains filtered or unexported fields
}

Worker is a convenience struct that embeds a Miner alongside a workers name, this allows for easy access to per-worker endpoints.

func (*Worker) History

func (w *Worker) History() (res []*WorkerStatsResponse, err error)

History returns a historic record of the workers statistics, ordered by time ascending.

func (*Worker) Stats

func (w *Worker) Stats() (res *WorkerStatsResponse, err error)

Stats returns the workers current statistics.

type WorkerStatsResponse

type WorkerStatsResponse struct {
	Worker           string  `json:"worker"`
	Time             int     `json:"time"`
	LastSeen         int     `json:"lastSeen"`
	ReportedHashrate int     `json:"reportedHashrate"`
	CurrentHashrate  float64 `json:"currentHashrate"`
	ValidShares      int     `json:"validShares"`
	InvalidShares    int     `json:"invalidShares"`
	StaleShares      int     `json:"staleShares"`
	AverageHashrate  float64 `json:"averageHashrate"`
}

WorkersStatsResponse is the json response returned by the various worker endpoints. TODO split?

Jump to

Keyboard shortcuts

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