Dandelion fixes
- more exception handling - only use outbound connections for stems (thanks to @amillter for info) - don't create stems if config disabled - addresses #1049
This commit is contained in:
parent
1abdc14807
commit
333170b172
|
@ -55,8 +55,7 @@ class BMConnectionPool(object):
|
|||
# Choose 2 peers randomly
|
||||
# TODO: handle streams
|
||||
peers = []
|
||||
connections = self.inboundConnections.values() + \
|
||||
self.outboundConnections.values()
|
||||
connections = self.outboundConnections.values()
|
||||
random.shuffle(connections)
|
||||
for i in connections:
|
||||
if i == node:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from random import choice
|
||||
from threading import RLock
|
||||
from time import time
|
||||
|
||||
from bmconfigparser import BMConfigParser
|
||||
from singleton import Singleton
|
||||
|
||||
# randomise routes after 600 seconds
|
||||
|
@ -16,10 +18,15 @@ class DandelionStems():
|
|||
self.lock = RLock()
|
||||
|
||||
def add(self, hashId, source, stems):
|
||||
if BMConfigParser().safeGetInt('network', 'dandelion') == 0:
|
||||
return
|
||||
with self.lock:
|
||||
try:
|
||||
self.stem[hashId] = choice(stems)
|
||||
except IndexError:
|
||||
self.stem = None
|
||||
self.source[hashId] = source
|
||||
self.timeouts[hashId] = time.time()
|
||||
self.timeouts[hashId] = time()
|
||||
|
||||
def remove(self, hashId):
|
||||
with self.lock:
|
||||
|
|
Reference in New Issue
Block a user