peer: fix panic bug in watiForChanToClose
This commit fixes a panic bug in the watiForChanToClose method caused by a logic error leading to the return value of the function at times being a nil pointer in the case that an error occurred. We now avoid such an error by _always_ returning from the function if there’s an error, but conditionally (in a diff if-clause) sending an error over the error channel.
This commit is contained in:
parent
40a7523b8f
commit
620695542c
4
peer.go
4
peer.go
@ -1069,8 +1069,10 @@ func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
|
|||||||
// TODO(roasbeef): add param for num needed confs
|
// TODO(roasbeef): add param for num needed confs
|
||||||
confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1,
|
confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1,
|
||||||
bestHeight)
|
bestHeight)
|
||||||
if err != nil && errChan != nil {
|
if err != nil {
|
||||||
|
if errChan != nil {
|
||||||
errChan <- err
|
errChan <- err
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user