Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server+tapchannel: move IsCustomHTLC method #1336

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 0 additions & 12 deletions tapchannel/aux_traffic_shaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Loading