From ff6fb4becfd055b59701b16603ae3cb85d41feda Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Fri, 3 May 2024 20:57:32 +0200 Subject: [PATCH] skip empty routing events in routing tab --- network/models/routingevent.go | 11 ++++++++++- pubsub/pubsub.go | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/network/models/routingevent.go b/network/models/routingevent.go index c5fff3a..c39295a 100644 --- a/network/models/routingevent.go +++ b/network/models/routingevent.go @@ -34,7 +34,10 @@ type RoutingEvent struct { } func (u *RoutingEvent) Equals(other *RoutingEvent) bool { - return u.IncomingChannelId == other.IncomingChannelId && u.IncomingHtlcId == other.IncomingHtlcId && u.OutgoingChannelId == other.OutgoingChannelId && u.OutgoingHtlcId == other.OutgoingHtlcId + return u.IncomingChannelId == other.IncomingChannelId && + u.IncomingHtlcId == other.IncomingHtlcId && + u.OutgoingChannelId == other.OutgoingChannelId && + u.OutgoingHtlcId == other.OutgoingHtlcId } func (u *RoutingEvent) Update(newer *RoutingEvent) { @@ -43,3 +46,9 @@ func (u *RoutingEvent) Update(newer *RoutingEvent) { u.FailureCode = newer.FailureCode u.FailureDetail = newer.FailureDetail } + +func (u *RoutingEvent) IsEmpty() bool { + return u.OutgoingChannelId == 0 && + u.FeeMsat == 0 && + u.AmountMsat == 0 +} diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index 5364183..8aac8ee 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -96,7 +96,9 @@ func (p *PubSub) routingUpdates(ctx context.Context, sub chan *events.Event) { go func() { for hu := range routingUpdates { p.logger.Debug("receive htlcUpdate") - sub <- events.NewWithData(events.RoutingEventUpdated, hu) + if !hu.IsEmpty() { + sub <- events.NewWithData(events.RoutingEventUpdated, hu) + } } p.wg.Done() }()