Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

91 lines
2.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package metrics
import (
"errors"
"github.com/luxfi/metric"
"github.com/luxfi/node/vms/xvm/block"
"github.com/luxfi/node/vms/xvm/txs"
)
var _ Metrics = (*metricsImpl)(nil)
type Metrics interface {
IncTxRefreshes()
IncTxRefreshHits()
IncTxRefreshMisses()
// MarkBlockAccepted updates all metrics relating to the acceptance of a
// block, including the underlying acceptance of the contained transactions.
MarkBlockAccepted(b block.Block) error
// MarkTxAccepted updates all metrics relating to the acceptance of a
// transaction.
//
// Note: This is not intended to be called during the acceptance of a block,
// as MarkBlockAccepted already handles updating transaction related
// metric.
MarkTxAccepted(tx *txs.Tx) error
}
type metricsImpl struct {
txMetrics *txMetrics
numTxRefreshes, numTxRefreshHits, numTxRefreshMisses metric.Counter
}
func (m *metricsImpl) IncTxRefreshes() {
m.numTxRefreshes.Inc()
}
func (m *metricsImpl) IncTxRefreshHits() {
m.numTxRefreshHits.Inc()
}
func (m *metricsImpl) IncTxRefreshMisses() {
m.numTxRefreshMisses.Inc()
}
func (m *metricsImpl) MarkBlockAccepted(b block.Block) error {
for _, tx := range b.Txs() {
if err := tx.Unsigned.Visit(m.txMetrics); err != nil {
return err
}
}
return nil
}
func (m *metricsImpl) MarkTxAccepted(tx *txs.Tx) error {
return tx.Unsigned.Visit(m.txMetrics)
}
func New(registerer metric.Registerer) (Metrics, error) {
registry, ok := registerer.(metric.Registry)
if !ok {
return nil, errors.New("registerer must implement metric.Registry")
}
txMetrics, err := newTxMetrics(registry)
errs := []error{err}
m := &metricsImpl{txMetrics: txMetrics}
m.numTxRefreshes = metric.NewCounter(metric.CounterOpts{
Name: "tx_refreshes",
Help: "Number of times unique txs have been refreshed",
})
m.numTxRefreshHits = metric.NewCounter(metric.CounterOpts{
Name: "tx_refresh_hits",
Help: "Number of times unique txs have not been unique, but were cached",
})
m.numTxRefreshMisses = metric.NewCounter(metric.CounterOpts{
Name: "tx_refresh_misses",
Help: "Number of times unique txs have not been unique and weren't cached",
})
// Metrics are self-registering when created with NewCounter etc.
return m, errors.Join(errs...)
}