Subtract allocated channel slots from total

This commit is contained in:
Mark Veidemanis 2022-08-12 22:31:12 +01:00
parent 0b370fc155
commit 14967f662c
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 13 additions and 1 deletions

View File

@ -60,6 +60,14 @@ def getChanFree(net, new):
return False
return (chanfree, chanlimits.pop())
def getTotalChans(net):
total = 0
for i in getActiveRelays(net):
name = net + str(i)
if name in main.IRCPool.keys():
total += len(main.IRCPool[name].channels)
return total
def emptyChanAllocate(net, flist, new):
chanfree = getChanFree(net, new)
@ -161,7 +169,11 @@ def keepChannels(net, listinfo, mean, sigrelay, relay, chanlimit):
error("Network %s is too big to cover: %i relays required" % (net, sigrelay))
return
num_instances = len(getActiveRelays(net))
max_chans = chanlimit * num_instances
debug(f"keepChannels() {net} instances:{num_instances} chanlimit:{chanlimit}")
chan_slots_used = getTotalChans(net)
debug(f"keepChannels() slots_used:{chan_slots_used}")
max_chans = (chanlimit * num_instances) - chan_slots_used
debug(f"keepChannels() max_chans:{max_chans}")
if coverAll:
needed = relay - len(getActiveRelays(net))
debug(f"keepChannels() coverAll asking to provision {needed} relays for {net} relay:{relay}")