Documentation
¶
Index ¶
- type Metrics
- func (m *Metrics) BackfillBlocks() error
- func (m *Metrics) CalculateNakamoto(peakHeight uint32, thresholdPercent int, ignoreAddresses []string) (int, error)
- func (m *Metrics) CloseWebsocket() error
- func (m *Metrics) DeleteBlockRecords() error
- func (m *Metrics) FillBlockGaps() error
- func (m *Metrics) FillTimestampGaps() error
- func (m *Metrics) GetNewestBlock() (uint32, error)
- func (m *Metrics) GetNonTXBlockTimestamp(blockHeight uint32) sql.NullString
- func (m *Metrics) GetOldestBlock() (uint32, error)
- func (m *Metrics) LookbackWindow() uint32
- func (m *Metrics) OpenWebsocket() error
- func (m *Metrics) StartServer() error
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 ¶
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 ¶
CloseWebsocket closes the websocket connection
func (*Metrics) DeleteBlockRecords ¶
DeleteBlockRecords deletes all records from the blocks table in the database
func (*Metrics) FillBlockGaps ¶
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 ¶
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 ¶
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 ¶
GetOldestBlock returns the oldest block height from the DB
func (*Metrics) LookbackWindow ¶
LookbackWindow returns the configured lookback window
func (*Metrics) OpenWebsocket ¶
OpenWebsocket sets up the RPC client and subscribes to relevant topics
func (*Metrics) StartServer ¶
StartServer starts the metrics server