fundingmanager+peer: modify fundingErrorMsg to use peer key
This commit is contained in:
parent
6b1982f50f
commit
6504a9cfa8
@ -199,7 +199,7 @@ type fundingLockedMsg struct {
|
|||||||
// message. This allows the funding manager to properly process the error.
|
// message. This allows the funding manager to properly process the error.
|
||||||
type fundingErrorMsg struct {
|
type fundingErrorMsg struct {
|
||||||
err *lnwire.Error
|
err *lnwire.Error
|
||||||
peerAddress *lnwire.NetAddress
|
peerKey *btcec.PublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// pendingChannels is a map instantiated per-peer which tracks all active
|
// pendingChannels is a map instantiated per-peer which tracks all active
|
||||||
@ -2690,10 +2690,10 @@ func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID) {
|
|||||||
// processFundingError sends a message to the fundingManager allowing it to
|
// processFundingError sends a message to the fundingManager allowing it to
|
||||||
// process the occurred generic error.
|
// process the occurred generic error.
|
||||||
func (f *fundingManager) processFundingError(err *lnwire.Error,
|
func (f *fundingManager) processFundingError(err *lnwire.Error,
|
||||||
peerAddress *lnwire.NetAddress) {
|
peerKey *btcec.PublicKey) {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case f.fundingMsgs <- &fundingErrorMsg{err, peerAddress}:
|
case f.fundingMsgs <- &fundingErrorMsg{err, peerKey}:
|
||||||
case <-f.quit:
|
case <-f.quit:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2705,13 +2705,12 @@ func (f *fundingManager) processFundingError(err *lnwire.Error,
|
|||||||
func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) {
|
func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) {
|
||||||
protocolErr := fmsg.err
|
protocolErr := fmsg.err
|
||||||
|
|
||||||
peerKey := fmsg.peerAddress.IdentityKey
|
|
||||||
chanID := fmsg.err.ChanID
|
chanID := fmsg.err.ChanID
|
||||||
|
|
||||||
// First, we'll attempt to retrieve and cancel the funding workflow
|
// 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
|
// that this error was tied to. If we're unable to do so, then we'll
|
||||||
// exit early as this was an unwarranted error.
|
// exit early as this was an unwarranted error.
|
||||||
resCtx, err := f.cancelReservationCtx(peerKey, chanID)
|
resCtx, err := f.cancelReservationCtx(fmsg.peerKey, chanID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fndgLog.Warnf("Received error for non-existent funding "+
|
fndgLog.Warnf("Received error for non-existent funding "+
|
||||||
"flow: %v (%v)", err, spew.Sdump(protocolErr))
|
"flow: %v (%v)", err, spew.Sdump(protocolErr))
|
||||||
@ -2722,7 +2721,7 @@ func (f *fundingManager) handleErrorMsg(fmsg *fundingErrorMsg) {
|
|||||||
// error back to the caller (if any), and cancel the workflow itself.
|
// error back to the caller (if any), and cancel the workflow itself.
|
||||||
lnErr := lnwire.ErrorCode(protocolErr.Data[0])
|
lnErr := lnwire.ErrorCode(protocolErr.Data[0])
|
||||||
fndgLog.Errorf("Received funding error from %x: %v",
|
fndgLog.Errorf("Received funding error from %x: %v",
|
||||||
peerKey.SerializeCompressed(), string(protocolErr.Data),
|
fmsg.peerKey.SerializeCompressed(), string(protocolErr.Data),
|
||||||
)
|
)
|
||||||
|
|
||||||
// If this isn't a simple error code, then we'll display the entire
|
// If this isn't a simple error code, then we'll display the entire
|
||||||
@ -2858,9 +2857,9 @@ func (f *fundingManager) getReservationCtx(peerKey *btcec.PublicKey,
|
|||||||
// channel will receive a new, permanent channel ID, and will no longer be
|
// channel will receive a new, permanent channel ID, and will no longer be
|
||||||
// considered pending.
|
// considered pending.
|
||||||
func (f *fundingManager) IsPendingChannel(pendingChanID [32]byte,
|
func (f *fundingManager) IsPendingChannel(pendingChanID [32]byte,
|
||||||
peerAddress *lnwire.NetAddress) bool {
|
peerKey *btcec.PublicKey) bool {
|
||||||
|
|
||||||
peerIDKey := newSerializedKey(peerAddress.IdentityKey)
|
peerIDKey := newSerializedKey(peerKey)
|
||||||
f.resMtx.RLock()
|
f.resMtx.RLock()
|
||||||
_, ok := f.activeReservations[peerIDKey][pendingChanID]
|
_, ok := f.activeReservations[peerIDKey][pendingChanID]
|
||||||
f.resMtx.RUnlock()
|
f.resMtx.RUnlock()
|
||||||
|
7
peer.go
7
peer.go
@ -935,8 +935,9 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case *lnwire.Error:
|
case *lnwire.Error:
|
||||||
switch {
|
key := p.addr.IdentityKey
|
||||||
|
|
||||||
|
switch {
|
||||||
// In the case of an all-zero channel ID we want to
|
// In the case of an all-zero channel ID we want to
|
||||||
// forward the error to all channels with this peer.
|
// forward the error to all channels with this peer.
|
||||||
case msg.ChanID == lnwire.ConnectionWideID:
|
case msg.ChanID == lnwire.ConnectionWideID:
|
||||||
@ -952,8 +953,8 @@ out:
|
|||||||
// If the channel ID for the error message corresponds
|
// If the channel ID for the error message corresponds
|
||||||
// to a pending channel, then the funding manager will
|
// to a pending channel, then the funding manager will
|
||||||
// handle the error.
|
// handle the error.
|
||||||
case p.server.fundingMgr.IsPendingChannel(msg.ChanID, p.addr):
|
case p.server.fundingMgr.IsPendingChannel(msg.ChanID, key):
|
||||||
p.server.fundingMgr.processFundingError(msg, p.addr)
|
p.server.fundingMgr.processFundingError(msg, key)
|
||||||
|
|
||||||
// If not we hand the error to the channel link for
|
// If not we hand the error to the channel link for
|
||||||
// this channel.
|
// this channel.
|
||||||
|
Loading…
Reference in New Issue
Block a user