From 05f601baa34cc8690738da6409d74552234774ff Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 28 Jan 2025 16:27:00 +0100 Subject: [PATCH] server+tapchannel: move IsCustomHTLC method The Server struct needs to implement all the interfaces for litd. --- server.go | 12 ++++++++++++ tapchannel/aux_traffic_shaper.go | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server.go b/server.go index 76951a2b2..bede71108 100644 --- a/server.go +++ b/server.go @@ -19,6 +19,7 @@ import ( "github.com/lightninglabs/taproot-assets/fn" "github.com/lightninglabs/taproot-assets/monitoring" "github.com/lightninglabs/taproot-assets/perms" + "github.com/lightninglabs/taproot-assets/rfqmsg" "github.com/lightninglabs/taproot-assets/rpcperms" "github.com/lightninglabs/taproot-assets/tapchannel" cmsg "github.com/lightninglabs/taproot-assets/tapchannelmsg" @@ -1052,6 +1053,17 @@ func (s *Server) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi, ) } +// IsCustomHTLC returns true if the HTLC carries the set of relevant custom +// records to put it under the purview of the traffic shaper, meaning that it's +// from a custom channel. +// +// NOTE: This method is part of the routing.TlvTrafficShaper interface. +func (s *Server) IsCustomHTLC(htlcRecords lnwire.CustomRecords) bool { + // We don't need to wait for server ready here since this operation can + // be done completely stateless. + return rfqmsg.HasAssetHTLCCustomRecords(htlcRecords) +} + // AuxCloseOutputs returns the set of close outputs to use for this co-op close // attempt. We'll add some extra outputs to the co-op close transaction, and // also give the caller a custom sorting routine. diff --git a/tapchannel/aux_traffic_shaper.go b/tapchannel/aux_traffic_shaper.go index 9c1d9b137..1c5e9eab9 100644 --- a/tapchannel/aux_traffic_shaper.go +++ b/tapchannel/aux_traffic_shaper.go @@ -12,7 +12,6 @@ import ( "github.com/lightninglabs/taproot-assets/rfqmsg" cmsg "github.com/lightninglabs/taproot-assets/tapchannelmsg" lfn "github.com/lightningnetwork/lnd/fn" - "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/tlv" ) @@ -72,10 +71,6 @@ func (s *AuxTrafficShaper) Stop() error { return stopErr } -// A compile-time check to ensure that AuxTrafficShaper fully implements the -// htlcswitch.AuxTrafficShaper interface. -var _ htlcswitch.AuxTrafficShaper = (*AuxTrafficShaper)(nil) - // ShouldHandleTraffic is called in order to check if the channel identified by // the provided channel ID is handled by the traffic shaper implementation. If // it is handled by the traffic shaper, then the normal bandwidth calculation @@ -326,10 +321,3 @@ func (s *AuxTrafficShaper) ProduceHtlcExtraData(totalAmount lnwire.MilliSatoshi, return htlcAmountMSat, updatedRecords, nil } - -// IsCustomHTLC returns true if the HTLC carries the set of relevant custom -// records to put it under the purview of the traffic shaper, meaning that it's -// from a custom channel. -func (s *AuxTrafficShaper) IsCustomHTLC(htlcRecords lnwire.CustomRecords) bool { - return rfqmsg.HasAssetHTLCCustomRecords(htlcRecords) -}