@@ -1154,10 +1154,11 @@ func (l *channelLink) htlcManager() {
11541154 // be updated when the close transaction is
11551155 // ready to avoid that we go down before
11561156 // storing the transaction in the db.
1157- l .fail (
1157+ l .failf (
1158+ //nolint:lll
11581159 LinkFailureError {
11591160 code : ErrSyncError ,
1160- FailureAction : LinkFailureForceClose , //nolint:lll
1161+ FailureAction : LinkFailureForceClose ,
11611162 },
11621163 "unable to synchronize channel " +
11631164 "states: %v" , err ,
@@ -1195,7 +1196,7 @@ func (l *channelLink) htlcManager() {
11951196 default :
11961197 }
11971198
1198- l .fail (
1199+ l .failf (
11991200 LinkFailureError {
12001201 code : ErrRecoveryError ,
12011202 FailureAction : LinkFailureForceNone ,
@@ -1259,14 +1260,14 @@ func (l *channelLink) htlcManager() {
12591260 // If the duplicate keystone error was encountered, we'll fail
12601261 // without sending an Error message to the peer.
12611262 case ErrDuplicateKeystone :
1262- l .fail (LinkFailureError {code : ErrCircuitError },
1263+ l .failf (LinkFailureError {code : ErrCircuitError },
12631264 "temporary circuit error: %v" , err )
12641265 return
12651266
12661267 // A non-nil error was encountered, send an Error message to
12671268 // the peer.
12681269 default :
1269- l .fail (LinkFailureError {code : ErrInternalError },
1270+ l .failf (LinkFailureError {code : ErrInternalError },
12701271 "unable to resolve fwd pkgs: %v" , err )
12711272 return
12721273 }
@@ -1405,7 +1406,7 @@ func (l *channelLink) htlcManager() {
14051406 }
14061407
14071408 case <- l .cfg .PendingCommitTicker .Ticks ():
1408- l .fail (
1409+ l .failf (
14091410 LinkFailureError {
14101411 code : ErrRemoteUnresponsive ,
14111412 FailureAction : LinkFailureDisconnect ,
@@ -1438,19 +1439,19 @@ func (l *channelLink) htlcManager() {
14381439 // If the duplicate keystone error was encountered,
14391440 // fail back gracefully.
14401441 case ErrDuplicateKeystone :
1441- l .fail (LinkFailureError {code : ErrCircuitError },
1442- fmt . Sprintf ( "process hodl queue: " +
1443- "temporary circuit error: %v" ,
1444- err ,
1445- ) ,
1442+ l .failf (LinkFailureError {
1443+ code : ErrCircuitError ,
1444+ }, "process hodl queue: " +
1445+ "temporary circuit error: %v" ,
1446+ err ,
14461447 )
14471448
14481449 // Send an Error message to the peer.
14491450 default :
1450- l .fail (LinkFailureError {code : ErrInternalError },
1451- fmt . Sprintf ( "process hodl queue: " +
1452- " unable to update commitment: "+
1453- " %v" , err ) ,
1451+ l .failf (LinkFailureError {
1452+ code : ErrInternalError ,
1453+ }, "process hodl queue: unable to update "+
1454+ "commitment: %v" , err ,
14541455 )
14551456 }
14561457
@@ -1960,7 +1961,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
19601961 // handle message ordering due to concurrency choices.
19611962 // An issue has been filed to address this here:
19621963 // https://github.com/lightningnetwork/lnd/issues/8393
1963- l .fail (
1964+ l .failf (
19641965 LinkFailureError {
19651966 code : ErrInvalidUpdate ,
19661967 FailureAction : LinkFailureDisconnect ,
@@ -1979,7 +1980,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
19791980 // where we are a relaying node (as the blinding point will
19801981 // be in the payload when we're the introduction node).
19811982 if msg .BlindingPoint .IsSome () && l .cfg .DisallowRouteBlinding {
1982- l .fail (LinkFailureError {code : ErrInvalidUpdate },
1983+ l .failf (LinkFailureError {code : ErrInvalidUpdate },
19831984 "blinding point included when route blinding " +
19841985 "is disabled" )
19851986
@@ -1991,7 +1992,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
19911992 // without sending a revoke. This would mean that the switch
19921993 // check would only occur later.
19931994 if l .isOverexposedWithHtlc (msg , true ) {
1994- l .fail (LinkFailureError {code : ErrInternalError },
1995+ l .failf (LinkFailureError {code : ErrInternalError },
19951996 "peer sent us an HTLC that exceeded our max " +
19961997 "fee exposure" )
19971998
@@ -2003,7 +2004,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
20032004 // "settle" list in the event that we know the preimage.
20042005 index , err := l .channel .ReceiveHTLC (msg )
20052006 if err != nil {
2006- l .fail (LinkFailureError {code : ErrInvalidUpdate },
2007+ l .failf (LinkFailureError {code : ErrInvalidUpdate },
20072008 "unable to handle upstream add HTLC: %v" , err )
20082009 return
20092010 }
@@ -2029,15 +2030,15 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
20292030 }
20302031
20312032 if ! lockedin {
2032- l .fail (
2033+ l .failf (
20332034 LinkFailureError {code : ErrInvalidUpdate },
20342035 "unable to handle upstream settle" ,
20352036 )
20362037 return
20372038 }
20382039
20392040 if err := l .channel .ReceiveHTLCSettle (pre , idx ); err != nil {
2040- l .fail (
2041+ l .failf (
20412042 LinkFailureError {
20422043 code : ErrInvalidUpdate ,
20432044 FailureAction : LinkFailureForceClose ,
@@ -2126,7 +2127,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
21262127 // message to the usual HTLC fail message.
21272128 err := l .channel .ReceiveFailHTLC (msg .ID , b .Bytes ())
21282129 if err != nil {
2129- l .fail (LinkFailureError {code : ErrInvalidUpdate },
2130+ l .failf (LinkFailureError {code : ErrInvalidUpdate },
21302131 "unable to handle upstream fail HTLC: %v" , err )
21312132 return
21322133 }
@@ -2164,7 +2165,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
21642165 idx := msg .ID
21652166 err := l .channel .ReceiveFailHTLC (idx , msg .Reason [:])
21662167 if err != nil {
2167- l .fail (LinkFailureError {code : ErrInvalidUpdate },
2168+ l .failf (LinkFailureError {code : ErrInvalidUpdate },
21682169 "unable to handle upstream fail HTLC: %v" , err )
21692170 return
21702171 }
@@ -2183,7 +2184,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
21832184 l .uncommittedPreimages ... ,
21842185 )
21852186 if err != nil {
2186- l .fail (
2187+ l .failf (
21872188 LinkFailureError {code : ErrInternalError },
21882189 "unable to add preimages=%v to cache: %v" ,
21892190 l .uncommittedPreimages , err ,
@@ -2219,7 +2220,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
22192220 case * lnwallet.InvalidHtlcSigError :
22202221 sendData = []byte (err .Error ())
22212222 }
2222- l .fail (
2223+ l .failf (
22232224 LinkFailureError {
22242225 code : ErrInvalidCommitment ,
22252226 FailureAction : LinkFailureForceClose ,
@@ -2248,7 +2249,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
22482249 // NOTE: We do not trigger a force close because this
22492250 // could resolve itself in case our db was just busy
22502251 // not accepting new transactions.
2251- l .fail (
2252+ l .failf (
22522253 LinkFailureError {
22532254 code : ErrInternalError ,
22542255 Warning : true ,
@@ -2336,7 +2337,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
23362337 ReceiveRevocation (msg )
23372338 if err != nil {
23382339 // TODO(halseth): force close?
2339- l .fail (
2340+ l .failf (
23402341 LinkFailureError {
23412342 code : ErrInvalidRevocation ,
23422343 FailureAction : LinkFailureDisconnect ,
@@ -2376,9 +2377,9 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
23762377 & chanID , state .RemoteCommitment .CommitHeight - 1 ,
23772378 )
23782379 if err != nil {
2379- l .fail (LinkFailureError {code : ErrInternalError },
2380- "unable to queue breach backup: %v" ,
2381- err )
2380+ l .failf (LinkFailureError {
2381+ code : ErrInternalError ,
2382+ }, "unable to queue breach backup: %v" , err )
23822383 return
23832384 }
23842385 }
@@ -2425,7 +2426,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
24252426 // indicates something is wrong with our channel state.
24262427 l .log .Errorf ("Unable to determine if fee threshold " +
24272428 "exceeded" )
2428- l .fail (LinkFailureError {code : ErrInternalError },
2429+ l .failf (LinkFailureError {code : ErrInternalError },
24292430 "error calculating fee exposure: %v" , err )
24302431
24312432 return
@@ -2434,15 +2435,15 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
24342435 if isDust {
24352436 // The proposed fee-rate makes us exceed the fee
24362437 // threshold.
2437- l .fail (LinkFailureError {code : ErrInternalError },
2438+ l .failf (LinkFailureError {code : ErrInternalError },
24382439 "fee threshold exceeded: %v" , err )
24392440 return
24402441 }
24412442
24422443 // We received fee update from peer. If we are the initiator we
24432444 // will fail the channel, if not we will apply the update.
24442445 if err := l .channel .ReceiveUpdateFee (fee ); err != nil {
2445- l .fail (LinkFailureError {code : ErrInvalidUpdate },
2446+ l .failf (LinkFailureError {code : ErrInvalidUpdate },
24462447 "error receiving fee update: %v" , err )
24472448 return
24482449 }
@@ -2461,7 +2462,7 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) {
24612462 // Error received from remote, MUST fail channel, but should
24622463 // only print the contents of the error message if all
24632464 // characters are printable ASCII.
2464- l .fail (
2465+ l .failf (
24652466 LinkFailureError {
24662467 code : ErrRemoteError ,
24672468
@@ -2550,14 +2551,14 @@ func (l *channelLink) updateCommitTxOrFail() bool {
25502551 // A duplicate keystone error should be resolved and is not fatal, so
25512552 // we won't send an Error message to the peer.
25522553 case ErrDuplicateKeystone :
2553- l .fail (LinkFailureError {code : ErrCircuitError },
2554+ l .failf (LinkFailureError {code : ErrCircuitError },
25542555 "temporary circuit error: %v" , err )
25552556 return false
25562557
25572558 // Any other error is treated results in an Error message being sent to
25582559 // the peer.
25592560 default :
2560- l .fail (LinkFailureError {code : ErrInternalError },
2561+ l .failf (LinkFailureError {code : ErrInternalError },
25612562 "unable to update commitment: %v" , err )
25622563 return false
25632564 }
@@ -3440,7 +3441,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
34403441 fwdPkg .ID (), decodeReqs ,
34413442 )
34423443 if sphinxErr != nil {
3443- l .fail (LinkFailureError {code : ErrInternalError },
3444+ l .failf (LinkFailureError {code : ErrInternalError },
34443445 "unable to decode hop iterators: %v" , sphinxErr )
34453446 return
34463447 }
@@ -3599,9 +3600,9 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
35993600 pd , obfuscator , fwdInfo , heightNow , pld ,
36003601 )
36013602 if err != nil {
3602- l .fail (LinkFailureError {code : ErrInternalError },
3603- err . Error () ,
3604- )
3603+ l .failf (LinkFailureError {
3604+ code : ErrInternalError ,
3605+ }, err . Error ()) //nolint
36053606
36063607 return
36073608 }
@@ -3745,7 +3746,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
37453746 if fwdPkg .State == channeldb .FwdStateLockedIn {
37463747 err := l .channel .SetFwdFilter (fwdPkg .Height , fwdPkg .FwdFilter )
37473748 if err != nil {
3748- l .fail (LinkFailureError {code : ErrInternalError },
3749+ l .failf (LinkFailureError {code : ErrInternalError },
37493750 "unable to set fwd filter: %v" , err )
37503751 return
37513752 }
@@ -4077,13 +4078,14 @@ func (l *channelLink) sendMalformedHTLCError(htlcIndex uint64,
40774078 })
40784079}
40794080
4080- // fail is a function which is used to encapsulate the action necessary for
4081+ // failf is a function which is used to encapsulate the action necessary for
40814082// properly failing the link. It takes a LinkFailureError, which will be passed
40824083// to the OnChannelFailure closure, in order for it to determine if we should
40834084// force close the channel, and if we should send an error message to the
40844085// remote peer.
4085- func (l * channelLink ) fail (linkErr LinkFailureError ,
4086- format string , a ... interface {}) {
4086+ func (l * channelLink ) failf (linkErr LinkFailureError , format string ,
4087+ a ... interface {}) {
4088+
40874089 reason := fmt .Errorf (format , a ... )
40884090
40894091 // Return if we have already notified about a failure.
0 commit comments