tsdb

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteBlocksBeforeEndTime

func DeleteBlocksBeforeEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string, period int,
) error

func DeleteGlobalSharesBeforeEndTime

func DeleteGlobalSharesBeforeEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
) error

func DeleteMinerSharesBeforeEndTime

func DeleteMinerSharesBeforeEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
) error

func DeleteRawBlocksBeforeTime

func DeleteRawBlocksBeforeTime(
	q dbcl.Querier,
	chain string,
	timestamp time.Time,
) error

func DeleteWorkerSharesBeforeEndTime

func DeleteWorkerSharesBeforeEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
) error

func GetBlockMaxEndTime

func GetBlockMaxEndTime(q dbcl.Querier, chain string, period int) (time.Time, error)

func GetBlocksAverageSlow

func GetBlocksAverageSlow(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (float64, error)

func GetEarningMaxEndTime

func GetEarningMaxEndTime(q dbcl.Querier, chain string, period int) (time.Time, error)

func GetGlobalEarningsAverage

func GetGlobalEarningsAverage(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (float64, error)

func GetGlobalSharesAverage

func GetGlobalSharesAverage(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (float64, error)

func GetMinerEarningsAverage

func GetMinerEarningsAverage(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (map[uint64]float64, error)

func GetMinerSharesAverage

func GetMinerSharesAverage(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (map[uint64]float64, error)

func GetPriceMaxTimestamp

func GetPriceMaxTimestamp(q dbcl.Querier, chain string) (time.Time, error)

func GetRawBlockMaxHashByHeight

func GetRawBlockMaxHashByHeight(q dbcl.Querier, chain string) (string, error)

func GetRawBlockMaxHeight

func GetRawBlockMaxHeight(q dbcl.Querier, chain string) (uint64, error)

func GetRawBlockMaxTimestamp

func GetRawBlockMaxTimestamp(q dbcl.Querier, chain string) (time.Time, error)

func GetRawBlockMaxTimestampBeforeTime

func GetRawBlockMaxTimestampBeforeTime(q dbcl.Querier, chain string, timestamp time.Time) (time.Time, error)

func GetWorkerSharesAverage

func GetWorkerSharesAverage(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
	duration time.Duration,
) (map[uint64]float64, error)

func InsertBlocks

func InsertBlocks(q dbcl.Querier, objects ...*Block) error

func InsertFinalBlocks

func InsertFinalBlocks(q dbcl.Querier, objects ...*Block) error

func InsertFinalGlobalShares

func InsertFinalGlobalShares(q dbcl.Querier, objects ...*Share) error

func InsertFinalMinerShares

func InsertFinalMinerShares(q dbcl.Querier, objects ...*Share) error

func InsertFinalWorkerShares

func InsertFinalWorkerShares(q dbcl.Querier, objects ...*Share) error

func InsertGlobalEarnings

func InsertGlobalEarnings(q dbcl.Querier, objects ...*Earning) error

func InsertGlobalShares

func InsertGlobalShares(q dbcl.Querier, objects ...*Share) error

func InsertMinerEarnings

func InsertMinerEarnings(q dbcl.Querier, objects ...*Earning) error

func InsertMinerShares

func InsertMinerShares(q dbcl.Querier, objects ...*Share) error

func InsertPartialBlocks

func InsertPartialBlocks(q dbcl.Querier, objects ...*Block) error

func InsertPartialGlobalShares

func InsertPartialGlobalShares(q dbcl.Querier, objects ...*Share) error

func InsertPartialMinerShares

func InsertPartialMinerShares(q dbcl.Querier, objects ...*Share) error

func InsertPartialWorkerShares

func InsertPartialWorkerShares(q dbcl.Querier, objects ...*Share) error

func InsertPrices

func InsertPrices(q dbcl.Querier, objects ...*Price) error

func InsertRawBlocks

func InsertRawBlocks(q dbcl.Querier, objects ...*RawBlock) error

func InsertWorkerShares

func InsertWorkerShares(q dbcl.Querier, objects ...*Share) error

func New

func New(args map[string]string) (*dbcl.Client, error)

Types

type Block

type Block struct {
	ChainID string `db:"chain_id"`

	Value            float64 `db:"value"`
	Difficulty       float64 `db:"difficulty"`
	BlockTime        float64 `db:"block_time"`
	Hashrate         float64 `db:"hashrate"`
	UncleRate        float64 `db:"uncle_rate"`
	Profitability    float64 `db:"profitability"`
	AvgProfitability float64 `db:"avg_profitability"`

	// columns not present in the table,
	// only helpful for summary query and miner
	// profitability estimates
	ProfitabilityUSD    float64 `db:"profitability_usd"`
	AvgProfitabilityUSD float64 `db:"avg_profitability_usd"`
	ProfitabilityBTC    float64 `db:"profitability_btc"`
	AvgProfitabilityBTC float64 `db:"avg_profitability_btc"`
	ProfitabilityETH    float64 `db:"profitability_eth"`
	AvgProfitabilityETH float64 `db:"avg_profitability_eth"`

	Pending    bool      `db:"pending"`
	Count      uint64    `db:"count"`
	UncleCount uint64    `db:"uncle_count"`
	TxCount    uint64    `db:"tx_count"`
	Period     int       `db:"period"`
	StartTime  time.Time `db:"start_time"`
	EndTime    time.Time `db:"end_time"`
}

func GetBlocks

func GetBlocks(q dbcl.Querier, chain string, period int) ([]*Block, error)

func GetBlocksAdjustedEmission

func GetBlocksAdjustedEmission(q dbcl.Querier, period int) ([]*Block, error)

func GetBlocksAdjustedValue

func GetBlocksAdjustedValue(q dbcl.Querier, period int) ([]*Block, error)

func GetBlocksProfitability

func GetBlocksProfitability(q dbcl.Querier, period int) ([]*Block, error)

func GetBlocksSingleMetric

func GetBlocksSingleMetric(q dbcl.Querier, metric string, period int) ([]*Block, error)

func GetBlocksWithProfitabilityLast

func GetBlocksWithProfitabilityLast(q dbcl.Querier, period int) ([]*Block, error)

func GetPendingBlocksAtEndTime

func GetPendingBlocksAtEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
) ([]*Block, error)

func GetRawBlockRollup

func GetRawBlockRollup(q dbcl.Querier, chain string, start, end time.Time) (*Block, error)

type Earning

type Earning struct {
	ChainID string  `db:"chain_id"`
	MinerID *uint64 `db:"miner_id"`

	Value    float64 `db:"value"`
	AvgValue float64 `db:"avg_value"`

	Pending   bool      `db:"pending"`
	Count     uint64    `db:"count"`
	Period    int       `db:"period"`
	StartTime time.Time `db:"start_time"`
	EndTime   time.Time `db:"end_time"`
}

func GetGlobalEarningsSingleMetric

func GetGlobalEarningsSingleMetric(q dbcl.Querier, metric string, period int) ([]*Earning, error)

func GetMinerEarningsSingleMetric

func GetMinerEarningsSingleMetric(
	q dbcl.Querier,
	minerIDs []uint64,
	metric string,
	period int,
) ([]*Earning, error)

type Price

type Price struct {
	ChainID string `db:"chain_id"`

	PriceUSD float64 `db:"price_usd"`
	PriceBTC float64 `db:"price_btc"`
	PriceETH float64 `db:"price_eth"`

	Timestamp time.Time `db:"timestamp"`
}

type RawBlock

type RawBlock struct {
	ID      uint64 `db:"id"`
	ChainID string `db:"chain_id"`

	Hash       string  `db:"hash"`
	Height     uint64  `db:"height"`
	Value      float64 `db:"value"`
	Difficulty float64 `db:"difficulty"`
	UncleCount uint64  `db:"uncle_count"`
	TxCount    uint64  `db:"tx_count"`

	Timestamp time.Time `db:"timestamp"`
}

type Share

type Share struct {
	ChainID  string  `db:"chain_id"`
	MinerID  *uint64 `db:"miner_id"`
	WorkerID *uint64 `db:"worker_id"`

	Miners                 uint64  `db:"miners"`
	Workers                uint64  `db:"workers"`
	AcceptedShares         uint64  `db:"accepted_shares"`
	AcceptedAdjustedShares uint64  `db:"accepted_adjusted_shares"`
	RejectedShares         uint64  `db:"rejected_shares"`
	RejectedAdjustedShares uint64  `db:"rejected_adjusted_shares"`
	InvalidShares          uint64  `db:"invalid_shares"`
	InvalidAdjustedShares  uint64  `db:"invalid_adjusted_shares"`
	Hashrate               float64 `db:"hashrate"`
	AvgHashrate            float64 `db:"avg_hashrate"`

	Pending   bool      `db:"pending"`
	Count     uint64    `db:"count"`
	Period    int       `db:"period"`
	StartTime time.Time `db:"start_time"`
	EndTime   time.Time `db:"end_time"`
}

func GetGlobalShares

func GetGlobalShares(q dbcl.Querier, chain string, period int) ([]*Share, error)

func GetGlobalSharesLast

func GetGlobalSharesLast(q dbcl.Querier, period int) ([]*Share, error)

func GetGlobalSharesSingleMetric

func GetGlobalSharesSingleMetric(q dbcl.Querier, metric string, period int) ([]*Share, error)

func GetMinerShares

func GetMinerShares(q dbcl.Querier, minerIDs []uint64, chain string, period int) ([]*Share, error)

func GetMinerSharesByEndTime

func GetMinerSharesByEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	minerIDs []uint64,
	chain string,
	period int,
) ([]*Share, error)

func GetMinerSharesSingleMetric

func GetMinerSharesSingleMetric(
	q dbcl.Querier,
	minerIDs []uint64,
	metric string,
	period int,
) ([]*Share, error)

func GetMinersSharesLast

func GetMinersSharesLast(
	q dbcl.Querier,
	minerIDs []uint64,
	period int,
) ([]*Share, error)

func GetMinersSharesSum

func GetMinersSharesSum(
	q dbcl.Querier,
	minerIDs []uint64,
	period int,
	duration time.Duration,
) ([]*Share, error)

func GetPendingGlobalSharesByEndTime

func GetPendingGlobalSharesByEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string,
	period int,
) ([]*Share, error)

func GetPendingMinerSharesByEndTime

func GetPendingMinerSharesByEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string, period int,
) ([]*Share, error)

func GetPendingWorkerSharesByEndTime

func GetPendingWorkerSharesByEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	chain string, period int,
) ([]*Share, error)

func GetWorkerShares

func GetWorkerShares(
	q dbcl.Querier,
	workerID uint64,
	chain string,
	period int,
) ([]*Share, error)

func GetWorkerSharesAllChainsByEndTime

func GetWorkerSharesAllChainsByEndTime(
	q dbcl.Querier,
	timestamp time.Time,
	workerIDs []uint64,
	period int,
) ([]*Share, error)

func GetWorkerSharesLast

func GetWorkerSharesLast(q dbcl.Querier, workerID uint64, period int) ([]*Share, error)

func GetWorkerSharesSingleMetric

func GetWorkerSharesSingleMetric(
	q dbcl.Querier,
	workerID uint64,
	metric string,
	period int,
) ([]*Share, error)

func GetWorkerSharesSum

func GetWorkerSharesSum(
	q dbcl.Querier,
	workerIDs []uint64,
	period int,
	duration time.Duration,
) ([]*Share, error)

Jump to

Keyboard shortcuts

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