funding: exit if pending channel doesn't exist for max pending error
This commit is contained in:
parent
afae7aad2a
commit
bb7f41933f
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -13,8 +14,6 @@ import (
|
|||||||
"github.com/roasbeef/btcd/wire"
|
"github.com/roasbeef/btcd/wire"
|
||||||
"github.com/roasbeef/btcutil"
|
"github.com/roasbeef/btcutil"
|
||||||
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/BitfuryLightning/tools/rt"
|
"github.com/BitfuryLightning/tools/rt"
|
||||||
"github.com/BitfuryLightning/tools/rt/graph"
|
"github.com/BitfuryLightning/tools/rt/graph"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -806,25 +805,24 @@ func (f *fundingManager) handleErrorGenericMsg(fmsg *fundingErrorMsg) {
|
|||||||
resCtx, ok := f.activeReservations[peerID][chanID]
|
resCtx, ok := f.activeReservations[peerID][chanID]
|
||||||
f.resMtx.RUnlock()
|
f.resMtx.RUnlock()
|
||||||
|
|
||||||
// TODO(roasbeef): comment
|
|
||||||
if !ok {
|
if !ok {
|
||||||
resCtx.err <- fmt.Errorf("ErrorGeneric error "+
|
fndgLog.Warnf("ErrorGeneric error was returned from " +
|
||||||
"was returned from remote peer for channel "+
|
"remote peer for unknown channel (id: %v)")
|
||||||
"(id: %v), but it can't be found and thereby "+
|
return
|
||||||
"can't be canceled.", chanID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := resCtx.reservation.Cancel(); err != nil {
|
if err := resCtx.reservation.Cancel(); err != nil {
|
||||||
resCtx.err <- fmt.Errorf("Remote peer responded "+
|
resCtx.err <- fmt.Errorf("max pending channels "+
|
||||||
"with: Number of pending channels exceed "+
|
"exceeded -- unable to cancel reservation: %v",
|
||||||
"maximum, but we can't cancel the reservation "+
|
err)
|
||||||
"- %v", err)
|
|
||||||
} else {
|
} else {
|
||||||
resCtx.err <- grpc.Errorf(OpenChannelFundingError,
|
resCtx.err <- grpc.Errorf(OpenChannelFundingError,
|
||||||
"Remote peer responded with: Number of "+
|
"unable to create channel, max number of "+
|
||||||
"pending channels exceed maximum")
|
"pending channels exceeded.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(roasbeef): possibly cancel funding barrier in peer's
|
||||||
|
// channelManager?
|
||||||
f.resMtx.Lock()
|
f.resMtx.Lock()
|
||||||
delete(f.activeReservations[peerID], chanID)
|
delete(f.activeReservations[peerID], chanID)
|
||||||
f.resMtx.Unlock()
|
f.resMtx.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user