2017-05-25 14:59:18 +02:00
|
|
|
from queues import Queue
|
2017-05-24 16:51:49 +02:00
|
|
|
import random
|
|
|
|
|
|
|
|
from bmconfigparser import BMConfigParser
|
|
|
|
import knownnodes
|
2017-05-25 14:59:18 +02:00
|
|
|
from queues import portCheckerQueue
|
2017-05-24 16:51:49 +02:00
|
|
|
import state
|
|
|
|
|
|
|
|
def chooseConnection(stream):
|
|
|
|
if state.trustedPeer:
|
|
|
|
return state.trustedPeer
|
|
|
|
else:
|
2017-05-25 14:59:18 +02:00
|
|
|
try:
|
|
|
|
return portCheckerQueue.get(False)
|
|
|
|
except Queue.Empty:
|
|
|
|
return random.choice(knownnodes.knownNodes[stream].keys())
|