fundingmanager: delete empty peer in deleteReservationCtx
This commit is contained in:
parent
6ee58ec1b0
commit
ccf9cd47ef
@ -2777,8 +2777,20 @@ func (f *fundingManager) deleteReservationCtx(peerKey *btcec.PublicKey,
|
|||||||
// channelManager?
|
// channelManager?
|
||||||
peerIDKey := newSerializedKey(peerKey)
|
peerIDKey := newSerializedKey(peerKey)
|
||||||
f.resMtx.Lock()
|
f.resMtx.Lock()
|
||||||
delete(f.activeReservations[peerIDKey], pendingChanID)
|
defer f.resMtx.Unlock()
|
||||||
f.resMtx.Unlock()
|
|
||||||
|
nodeReservations, ok := f.activeReservations[peerIDKey]
|
||||||
|
if !ok {
|
||||||
|
// No reservations for this node.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete(nodeReservations, pendingChanID)
|
||||||
|
|
||||||
|
// If this was the last active reservation for this peer, delete the
|
||||||
|
// peer's entry altogether.
|
||||||
|
if len(nodeReservations) == 0 {
|
||||||
|
delete(f.activeReservations, peerIDKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getReservationCtx returns the reservation context for a particular pending
|
// getReservationCtx returns the reservation context for a particular pending
|
||||||
|
Loading…
Reference in New Issue
Block a user