diff --git a/network/models/routingevent.go b/network/models/routingevent.go index c5fff3a..0a5cf32 100644 --- a/network/models/routingevent.go +++ b/network/models/routingevent.go @@ -1,6 +1,7 @@ package models import ( + "go.uber.org/zap/zapcore" "time" ) @@ -33,8 +34,29 @@ type RoutingEvent struct { FailureDetail string } +func (u *RoutingEvent) MarshalLogObject(enc zapcore.ObjectEncoder) error { + enc.AddUint64("incoming_channel_id", u.IncomingChannelId) + enc.AddUint64("outgoing_channel_id", u.OutgoingChannelId) + enc.AddUint64("incoming_htlc_id", u.IncomingHtlcId) + enc.AddUint64("outgoing_htlc_id", u.OutgoingHtlcId) + enc.AddTime("last_update", u.LastUpdate) + enc.AddInt("direction", u.Direction) + enc.AddInt("status", u.Status) + enc.AddUint32("incoming_timelock", u.IncomingTimelock) + enc.AddUint32("outgoing_timelock", u.OutgoingTimelock) + enc.AddUint64("amount_msat", u.AmountMsat) + enc.AddUint64("fee_msat", u.FeeMsat) + enc.AddInt32("failure_code", u.FailureCode) + enc.AddString("failure_detail", u.FailureDetail) + + return nil +} + 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 +65,15 @@ func (u *RoutingEvent) Update(newer *RoutingEvent) { u.FailureCode = newer.FailureCode u.FailureDetail = newer.FailureDetail } + +func (u *RoutingEvent) IsEmpty() bool { + return u.IncomingChannelId == 0 && + u.OutgoingChannelId == 0 && + u.IncomingHtlcId == 0 && + u.OutgoingHtlcId == 0 && + u.IncomingTimelock == 0 && + u.OutgoingTimelock == 0 && + u.AmountMsat == 0 && + u.FeeMsat == 0 && + u.FailureCode == 0 +} diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index 5364183..a05111b 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -96,7 +96,12 @@ 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() { + p.logger.Debug("EMPTY BANG BANG") + sub <- events.NewWithData(events.RoutingEventUpdated, hu) + } else { + p.logger.Debug("NOT EMPTY BANG BANG") + } } p.wg.Done() }()