diff --git a/components/dashboard_metrics/component.go b/components/dashboard_metrics/component.go index 741c084f0..4bfdde070 100644 --- a/components/dashboard_metrics/component.go +++ b/components/dashboard_metrics/component.go @@ -58,7 +58,7 @@ type dependencies struct { Protocol *protocol.Protocol RestRouteManager *restapipkg.RestRouteManager AppInfo *app.Info - P2PMetrics *p2p.P2PMetrics + P2PMetrics *p2p.Metrics } func configure() error { @@ -67,7 +67,7 @@ func configure() error { deps.P2PMetrics.IncomingBlocks.Add(1) }) - deps.Protocol.Events.Engine.BlockRetainer.BlockRetained.Hook(func(block *blocks.Block) { + deps.Protocol.Events.Engine.BlockRetainer.BlockRetained.Hook(func(_ *blocks.Block) { deps.P2PMetrics.IncomingNewBlocks.Add(1) }) diff --git a/components/p2p/component.go b/components/p2p/component.go index d31c43835..eb586d140 100644 --- a/components/p2p/component.go +++ b/components/p2p/component.go @@ -245,8 +245,8 @@ func provide(c *dig.Container) error { Component.LogPanic(err.Error()) } - if err := c.Provide(func() *p2p.P2PMetrics { - return &p2p.P2PMetrics{} + if err := c.Provide(func() *p2p.Metrics { + return &p2p.Metrics{} }); err != nil { Component.LogPanic(err.Error()) } @@ -255,7 +255,7 @@ func provide(c *dig.Container) error { dig.In Host host.Host PeerDB *network.DB - P2PMetrics *p2p.P2PMetrics + P2PMetrics *p2p.Metrics } return c.Provide(func(inDeps p2pManagerDeps) network.Manager { diff --git a/components/prometheus/component.go b/components/prometheus/component.go index d7f718b73..0a052a0a7 100644 --- a/components/prometheus/component.go +++ b/components/prometheus/component.go @@ -120,9 +120,7 @@ func run() error { } func provide(c *dig.Container) error { - return c.Provide(func() *collector.Collector { - return collector.New() - }) + return c.Provide(collector.New) } func registerMetrics() { diff --git a/pkg/network/p2p/metrics.go b/pkg/network/p2p/metrics.go index 97f55f4cf..05ed18f3c 100644 --- a/pkg/network/p2p/metrics.go +++ b/pkg/network/p2p/metrics.go @@ -4,8 +4,8 @@ import ( "sync/atomic" ) -// P2PMetrics defines P2P metrics over the entire runtime of the node. -type P2PMetrics struct { +// Metrics defines P2P metrics over the entire runtime of the node. +type Metrics struct { // The number of total received blocks. IncomingBlocks atomic.Uint32 // The number of received blocks which are new. diff --git a/pkg/network/p2p/neighbor.go b/pkg/network/p2p/neighbor.go index f869f6969..56511270d 100644 --- a/pkg/network/p2p/neighbor.go +++ b/pkg/network/p2p/neighbor.go @@ -167,6 +167,7 @@ func (n *neighbor) writeLoop() { } if n.onBlockSentCallback != nil { + //nolint:forcetypeassert // we know that the packet is a nwmodels.Packet if block := sendPacket.packet.(*nwmodels.Packet).GetBlock(); block != nil { n.onBlockSentCallback() }