htlcswitch: let failAliasUpdate return lnwire.ChannelUpdate

This commit is contained in:
Elle Mouton 2023-11-07 12:00:28 +02:00
parent 40981dfdab
commit e749a44d7e
No known key found for this signature in database
GPG Key ID: D7D916376026F177
5 changed files with 16 additions and 15 deletions

View File

@ -85,7 +85,7 @@ type scidAliasHandler interface {
// HTLCs on option_scid_alias channels.
attachFailAliasUpdate(failClosure func(
sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate1)
incoming bool) lnwire.ChannelUpdate)
// getAliases fetches the link's underlying aliases. This is used by
// the Switch to determine whether to forward an HTLC and where to

View File

@ -262,7 +262,7 @@ type ChannelLinkConfig struct {
// FailAliasUpdate is a function used to fail an HTLC for an
// option_scid_alias channel.
FailAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate1
incoming bool) lnwire.ChannelUpdate
// GetAliases is used by the link and switch to fetch the set of
// aliases for a given link.
@ -764,7 +764,7 @@ func shouldAdjustCommitFee(netFee, chanFee,
}
// failCb is used to cut down on the argument verbosity.
type failCb func(update *lnwire.ChannelUpdate1) lnwire.FailureMessage
type failCb func(update lnwire.ChannelUpdate) lnwire.FailureMessage
// createFailureWithUpdate creates a ChannelUpdate when failing an incoming or
// outgoing HTLC. It may return a FailureMessage that references a channel's
@ -2962,7 +2962,7 @@ func (l *channelLink) getAliases() []lnwire.ShortChannelID {
//
// Part of the scidAliasHandler interface.
func (l *channelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
sid lnwire.ShortChannelID, incoming bool) lnwire.ChannelUpdate) {
l.Lock()
l.cfg.FailAliasUpdate = closure
@ -3054,7 +3054,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewFeeInsufficient(amtToForward, upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3082,7 +3082,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// Grab the latest routing policy so the sending node is up to
// date with our current policy.
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewIncorrectCltvExpiry(
incomingTimeout, upd,
)
@ -3131,7 +3131,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewAmountBelowMinimum(amt, upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3146,7 +3146,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up-to-date data.
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3161,7 +3161,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
"outgoing_expiry=%v, best_height=%v", payHash[:],
timeout, heightNow)
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewExpiryTooSoon(upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3181,7 +3181,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
if amt > l.Bandwidth() {
l.log.Warnf("insufficient bandwidth to route htlc: %v is "+
"larger than %v", amt, l.Bandwidth())
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@ -3694,7 +3694,8 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
l.log.Errorf("unable to encode the "+
"remaining route %v", err)
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage { //nolint:lll
//nolint:lll
cb := func(upd lnwire.ChannelUpdate) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd)
}

View File

@ -6172,7 +6172,7 @@ func TestCheckHtlcForward(t *testing.T) {
}
failAliasUpdate := func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate1 {
incoming bool) lnwire.ChannelUpdate {
return nil
}

View File

@ -743,7 +743,7 @@ type mockChannelLink struct {
checkHtlcForwardResult *LinkError
failAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate1
incoming bool) lnwire.ChannelUpdate
confirmedZC bool
}
@ -878,7 +878,7 @@ func (f *mockChannelLink) AttachMailBox(mailBox MailBox) {
}
func (f *mockChannelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
sid lnwire.ShortChannelID, incoming bool) lnwire.ChannelUpdate) {
f.failAliasUpdate = closure
}

View File

@ -2614,7 +2614,7 @@ func (s *Switch) failMailboxUpdate(outgoingScid,
// and the caller is expected to handle this properly. In this case, a return
// to the original non-alias behavior is expected.
func (s *Switch) failAliasUpdate(scid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate1 {
incoming bool) lnwire.ChannelUpdate {
// This function does not defer the unlocking because of the database
// lookups for ChannelUpdate.