Peter Surda
f8b4b427fc
- bugfixes - UDP socket for local peer discovery - new function assembleAddr to unify creating address command - open port checker functionality (inactive) - sendBigInv is done in a thread separate from the network IO thread
20 lines
534 B
Python
20 lines
534 B
Python
from queues import Queue
|
|
import random
|
|
|
|
from bmconfigparser import BMConfigParser
|
|
import knownnodes
|
|
from queues import portCheckerQueue, peerDiscoveryQueue
|
|
import state
|
|
|
|
def chooseConnection(stream):
|
|
if state.trustedPeer:
|
|
return state.trustedPeer
|
|
else:
|
|
try:
|
|
return portCheckerQueue.get(False)
|
|
except Queue.Empty:
|
|
try:
|
|
return peerDiscoveryQueue.get(False)
|
|
except Queue.Empty:
|
|
return random.choice(knownnodes.knownNodes[stream].keys())
|