From 20bbe1e12d118c49ee92477e92ffff4dad8d886b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 4 May 2017 15:56:43 -0700 Subject: [PATCH] funding: fix bug that double counts "pending channels" in GetInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- fundingmanager.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 8298b9f47..4c89c2dfa 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -406,11 +406,7 @@ func (f *fundingManager) reservationCoordinator() { // handleNumPending handles a request for the total number of pending channels. func (f *fundingManager) handleNumPending(msg *numPendingReq) { - var numPending uint32 - for _, peerChannels := range f.activeReservations { - numPending += uint32(len(peerChannels)) - } - + // TODO(roasbeef): remove this method? dbPendingChannels, err := f.cfg.Wallet.ChannelDB.FetchPendingChannels() if err != nil { close(msg.resp) @@ -418,9 +414,7 @@ func (f *fundingManager) handleNumPending(msg *numPendingReq) { return } - numPending = numPending + uint32(len(dbPendingChannels)) - - msg.resp <- numPending + msg.resp <- uint32(len(dbPendingChannels)) msg.err <- nil }