metrics

package
v0.0.0-...-2cc1159 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics deals with the block db and metrics

func NewMetrics

func NewMetrics(exporterPort uint16, dbHost string, dbPort uint16, dbUser string, dbPass string, dbName string, lookbackWindow int, rpcPerPage int) (*Metrics, error)

NewMetrics returns a new metrics instance

func (*Metrics) BackfillBlocks

func (m *Metrics) BackfillBlocks() error

BackfillBlocks loads all the blocks from the chia full node and stores the relevant data into the metrics DB

func (*Metrics) CalculateNakamoto

func (m *Metrics) CalculateNakamoto(peakHeight uint32, thresholdPercent int, ignoreAddresses []string) (int, error)

CalculateNakamoto calculates the NC for the given peak height and percentage

func (*Metrics) CloseWebsocket

func (m *Metrics) CloseWebsocket() error

CloseWebsocket closes the websocket connection

func (*Metrics) DeleteBlockRecords

func (m *Metrics) DeleteBlockRecords() error

DeleteBlockRecords deletes all records from the blocks table in the database

func (*Metrics) FillBlockGaps

func (m *Metrics) FillBlockGaps() error

FillBlockGaps looks for gaps in the blocks table and fetches the missing blocks Avoids anything below the lowest block currently in the table We work from lowest height to the highest height, so that we can always be sure the preceding transaction block is present before the non-tx blocks that follow it, so that we can borrow the timestamp from the TX block

func (*Metrics) FillTimestampGaps

func (m *Metrics) FillTimestampGaps() error

FillTimestampGaps In some cases, there might be blocks that for one reason or another, dont have a timestamp associated This identifies those gaps, and adds the missing timestamps

func (*Metrics) GetNewestBlock

func (m *Metrics) GetNewestBlock() (uint32, error)

GetNewestBlock returns the newest block height from the DB

func (*Metrics) GetNonTXBlockTimestamp

func (m *Metrics) GetNonTXBlockTimestamp(blockHeight uint32) sql.NullString

GetNonTXBlockTimestamp returns a timestamp to use for a non-transaction block. Returns the timestamp from the next lowest block that has a timestamp This relies on processing blocks from oldest to the newest The only case where we DONT process blocks in this order is the backfill --delete-first option, which goes backwards, so there is useful data ASAP For this case, the "fill missing timestamps" will catch and resolve the issue

func (*Metrics) GetOldestBlock

func (m *Metrics) GetOldestBlock() (uint32, error)

GetOldestBlock returns the oldest block height from the DB

func (*Metrics) LookbackWindow

func (m *Metrics) LookbackWindow() uint32

LookbackWindow returns the configured lookback window

func (*Metrics) OpenWebsocket

func (m *Metrics) OpenWebsocket() error

OpenWebsocket sets up the RPC client and subscribes to relevant topics

func (*Metrics) StartServer

func (m *Metrics) StartServer() error

StartServer starts the metrics server

Jump to

Keyboard shortcuts

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