funding: add missing mutex around activeReservations

This commit is contained in:
Johan T. Halseth 2018-02-28 23:29:49 +01:00
parent 7ea9e7cf4c
commit 7252dbd934
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
1 changed files with 3 additions and 0 deletions

View File

@ -835,12 +835,15 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
// TODO(roasbeef): modify to only accept a _single_ pending channel per
// block unless white listed
f.resMtx.RLock()
if len(f.activeReservations[peerIDKey]) >= cfg.MaxPendingChannels {
f.resMtx.RUnlock()
f.failFundingFlow(
fmsg.peerAddress.IdentityKey, fmsg.msg.PendingChannelID,
lnwire.ErrMaxPendingChannels)
return
}
f.resMtx.RUnlock()
// We'll also reject any requests to create channels until we're fully
// synced to the network as we won't be able to properly validate the