Implement deduplicating channels
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from twisted.internet.threads import deferToThread
|
||||
|
||||
import main
|
||||
from utils.logging.debug import trace
|
||||
from modules import chankeep
|
||||
from utils.logging.debug import debug, trace
|
||||
from utils.logging.log import warn
|
||||
from utils.parsing import parsen
|
||||
|
||||
@@ -289,5 +290,15 @@ def _delChannels(net, channels):
|
||||
|
||||
def delChannels(net, channels): # we have left a channel
|
||||
trace("Purging channel %s for %s" % (", ".join(channels), net))
|
||||
deferToThread(_delChannels, net, channels)
|
||||
dupes = chankeep.getDuplicateChannels(net, total=True)
|
||||
print("dupes: %s" % dupes)
|
||||
if not dupes:
|
||||
deferToThread(_delChannels, net, channels)
|
||||
else:
|
||||
for channel in channels:
|
||||
if channel in dupes[net]:
|
||||
if dupes[net][channel] != 0:
|
||||
channels.remove(channel)
|
||||
debug(f"Not removing channel {channel} as {net} has {dupes[net][channel]} other relays covering it")
|
||||
deferToThread(_delChannels, net, channels)
|
||||
# d.addCallback(testCallback)
|
||||
|
||||
Reference in New Issue
Block a user