From 5a5aed0f24bf911d868de06dacee542a447f4a01 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Fri, 3 May 2024 19:00:09 +0200 Subject: [PATCH] tmp --- network/backend/lnd/lnd.go | 7 ++++++- network/models/routingevent.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/network/backend/lnd/lnd.go b/network/backend/lnd/lnd.go index 672d06fd..8f0c3a34 100644 --- a/network/backend/lnd/lnd.go +++ b/network/backend/lnd/lnd.go @@ -251,7 +251,12 @@ func (l Backend) SubscribeRoutingEvents(ctx context.Context, channelEvents chan return err } - channelEvents <- protoToRoutingEvent(event) + routingEvent := protoToRoutingEvent(event) + if !routingEvent.IsEmpty() { + channelEvents <- routingEvent + } else { + l.logger.Debug("receive htlcUpdate", logging.Object("routing_event", routingEvent)) + } } } } diff --git a/network/models/routingevent.go b/network/models/routingevent.go index c5fff3a5..c908b9ee 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,6 +34,24 @@ 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 } @@ -43,3 +62,7 @@ func (u *RoutingEvent) Update(newer *RoutingEvent) { u.FailureCode = newer.FailureCode u.FailureDetail = newer.FailureDetail } + +func (u *RoutingEvent) IsEmpty() bool { + return u.Equals(&RoutingEvent{}) +}