From 909034432911ccd040dd3f83951e920aba585e5d Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 30 May 2018 12:16:37 +0200 Subject: [PATCH] fundingmanager: simplify handleErrorMsg --- fundingmanager.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 443e81d3..27b48d79 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -2679,13 +2679,13 @@ func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) { peerKey := fmsg.peerAddress.IdentityKey chanID := fmsg.err.ChanID - // First, we'll attempt to retrieve the funding workflow that this - // error was tied to. If we're unable to do so, then we'll exit early - // as this was an unwarranted error. - resCtx, err := f.getReservationCtx(peerKey, chanID) + // First, we'll attempt to retrieve and cancel the funding workflow + // that this error was tied to. If we're unable to do so, then we'll + // exit early as this was an unwarranted error. + resCtx, err := f.cancelReservationCtx(peerKey, chanID) if err != nil { fndgLog.Warnf("Received error for non-existent funding "+ - "flow: %v", spew.Sdump(protocolErr)) + "flow: %v (%v)", err, spew.Sdump(protocolErr)) return } @@ -2699,21 +2699,17 @@ func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) { // If this isn't a simple error code, then we'll display the entire // thing. if len(protocolErr.Data) > 1 { - resCtx.err <- grpc.Errorf( + err = grpc.Errorf( lnErr.ToGrpcCode(), string(protocolErr.Data), ) } else { // Otherwise, we'll attempt to display just the error code // itself. - resCtx.err <- grpc.Errorf( + err = grpc.Errorf( lnErr.ToGrpcCode(), lnErr.String(), ) } - - if _, err := f.cancelReservationCtx(peerKey, chanID); err != nil { - fndgLog.Warnf("unable to delete reservation: %v", err) - return - } + resCtx.err <- err } // pruneZombieReservations loops through all pending reservations and fails the