Documentation ¶
Index ¶
- Constants
- func WriteStatToBatch(batch *leveldb.Batch, stat Stat, timestamp int64)
- func WriteTotalStatToBatch(batch *leveldb.Batch, stat TotalStat, timestamp int64)
- type BestShare
- type Block
- type Database
- func (db *Database) Close()
- func (db *Database) GetAndWriteCachedValues() error
- func (db *Database) GetBlocksUnsorted() []Block
- func (db *Database) GetRoundTime() int64
- func (db *Database) GetTotalAverageHashrate() *big.Int
- func (db *Database) GetTotalHistory() ([]TotalStat, error)
- func (db *Database) GetTotalShares() (TotalShares, error)
- func (db *Database) GetTotalStatsByTimestamp(timestamp int64) (TotalStat, error)
- func (db *Database) GetUnsortedBestShares() []BestShare
- func (db *Database) GetValidSharesThenReset() (uint64, error)
- func (db *Database) GetWorkers() []Worker
- func (db *Database) IncrValidShares() error
- func (db *Database) PruneStats(deleteDataOlderThanSecs int64)
- func (db *Database) WriteBestShare(bestShare BestShare, timestamp int64) error
- func (db *Database) WriteMinedBlock(block Block) error
- type Stat
- type TotalShares
- type TotalStat
- type Worker
Constants ¶
const AverageTotalHashrateKey = "average_total_hashrate"
AverageTotalHashrateKey is used to identify if key is average total hashrate item
BestSharePrefix is used to map best share db objects
const MinedBlockPrefix = "block__"
MinedBlockPrefix is used to map block db objects
MinedValidSharesKey is used to identify if key is mined valid shares counter
const StatPrefix = "stat__"
StatPrefix is used to map stat db objects
TotalSharesKey is used to identify if key is total shares item
const TotalStatPrefix = "total__"
TotalStatPrefix is used to map summarized stat db objects
Variables ¶
This section is empty.
Functions ¶
func WriteStatToBatch ¶
WriteStatToBatch writes worker stat object to the LevelDB batch
Types ¶
type BestShare ¶
type BestShare struct {}
BestShare represents an interface for a best share DB object
type Block ¶
type Block struct { Hash string `json:"hash"` Number uint64 `json:"number"` Type string `json:"type"` WorkerName string `json:"worker_name"` Difficulty float64 `json:"difficulty"` Timestamp int64 `json:"timestamp"` Confirmed bool `json:"confirmed"` MinedHashes float64 `json:"mined_hashes"` RoundTime int64 `json:"round_time"` Luck float64 `json:"luck"` }
Block represents an interface for a block DB object
type Database ¶
Database represents the interface to the LevelDB database
func (*Database) GetAndWriteCachedValues ¶
GetAndWriteCachedValues gets (calculates) and writes cached values to the db
func (*Database) GetBlocksUnsorted ¶
GetBlocksUnsorted returns the unsorted blocks from the Database
func (*Database) GetRoundTime ¶
GetRoundTime returns round time
func (*Database) GetTotalAverageHashrate ¶
GetTotalAverageHashrate returns total average hashrate which was put by GetAndWriteCachedValues
func (*Database) GetTotalHistory ¶
GetTotalHistory returns all "total" history (a day)
func (*Database) GetTotalShares ¶
func (db *Database) GetTotalShares() (TotalShares, error)
GetTotalShares returns total amount of shares which was put by GetAndWriteCachedValues
func (*Database) GetTotalStatsByTimestamp ¶
GetTotalStatsByTimestamp returns TotalStat by specified timestamp
func (*Database) GetUnsortedBestShares ¶
GetUnsortedBestShares returns the unsorted best shares from the Database
func (*Database) GetValidSharesThenReset ¶
GetValidSharesThenReset gets the mined valid shares counter and resets it
func (*Database) GetWorkers ¶
GetWorkers returns current workers
func (*Database) IncrValidShares ¶
IncrValidShares increments mined valid shares counter (used to precisely calculate luck)
func (*Database) PruneStats ¶
PruneStats removes data with the age more than `deleteDataOlderThanSecs`
func (*Database) WriteBestShare ¶
WriteBestShare writes best share to the database
func (*Database) WriteMinedBlock ¶
WriteMinedBlock writes mined block to the database
type Stat ¶
type Stat struct { Timestamp int64 `json:"timestamp"` WorkerName string `json:"worker_name"` ReportedHashrate float64 `json:"reported_hashrate"` EffectiveHashrate float64 `json:"effective_hashrate"` IPAddress string `json:"ip_address"` }
Stat represents an interface for a stat DB object
type TotalShares ¶
type TotalShares struct {}
TotalShares represents an interface to total shares db object