funding: fix bug that double counts "pending channels" in GetInfo
This commit fixes a bug that double counts the number of pending channels in GetInfo. Previously we weren’t yet storing the pending channels on disk, we are now but comparing both the disk channel and the channels within memory leads us to double count channels. To fix this, we now only count the database channels. Note that this NumPendingChannels method can now be removed as it’s no longer needed.
This commit is contained in:
parent
17c5deb369
commit
20bbe1e12d
@ -406,11 +406,7 @@ func (f *fundingManager) reservationCoordinator() {
|
|||||||
|
|
||||||
// handleNumPending handles a request for the total number of pending channels.
|
// handleNumPending handles a request for the total number of pending channels.
|
||||||
func (f *fundingManager) handleNumPending(msg *numPendingReq) {
|
func (f *fundingManager) handleNumPending(msg *numPendingReq) {
|
||||||
var numPending uint32
|
// TODO(roasbeef): remove this method?
|
||||||
for _, peerChannels := range f.activeReservations {
|
|
||||||
numPending += uint32(len(peerChannels))
|
|
||||||
}
|
|
||||||
|
|
||||||
dbPendingChannels, err := f.cfg.Wallet.ChannelDB.FetchPendingChannels()
|
dbPendingChannels, err := f.cfg.Wallet.ChannelDB.FetchPendingChannels()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
close(msg.resp)
|
close(msg.resp)
|
||||||
@ -418,9 +414,7 @@ func (f *fundingManager) handleNumPending(msg *numPendingReq) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
numPending = numPending + uint32(len(dbPendingChannels))
|
msg.resp <- uint32(len(dbPendingChannels))
|
||||||
|
|
||||||
msg.resp <- numPending
|
|
||||||
msg.err <- nil
|
msg.err <- nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user