Remove non-asyncore network code (partial)
This commit is contained in:
parent
0b07b1c89a
commit
6c695c8ac7
|
@ -864,11 +864,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
objectType, toStreamNumber, encryptedPayload, int(time.time()) + TTL,'')
|
||||
with shared.printLock:
|
||||
print 'Broadcasting inv for msg(API disseminatePreEncryptedMsg command):', hexlify(inventoryHash)
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
toStreamNumber, 'advertiseobject', inventoryHash))
|
||||
|
||||
def HandleTrashSentMessageByAckDAta(self, params):
|
||||
# This API method should only be used when msgid is not available
|
||||
|
@ -914,11 +910,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
objectType, pubkeyStreamNumber, payload, int(time.time()) + TTL,'')
|
||||
with shared.printLock:
|
||||
print 'broadcasting inv within API command disseminatePubkey with hash:', hexlify(inventoryHash)
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((pubkeyStreamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
pubkeyStreamNumber, 'advertiseobject', inventoryHash))
|
||||
|
||||
def HandleGetMessageDataByDestinationHash(self, params):
|
||||
# Method will eventually be used by a particular Android app to
|
||||
|
|
|
@ -92,13 +92,7 @@ def connectToStream(streamNumber):
|
|||
if streamNumber*2+1 not in knownnodes.knownNodes:
|
||||
knownnodes.knownNodes[streamNumber*2+1] = {}
|
||||
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
BMConnectionPool().connectToStream(streamNumber)
|
||||
else:
|
||||
for i in range(state.maximumNumberOfHalfOpenConnections):
|
||||
a = outgoingSynSender()
|
||||
a.setup(streamNumber, selfInitiatedConnections)
|
||||
a.start()
|
||||
|
||||
def _fixSocket():
|
||||
if sys.platform.startswith('linux'):
|
||||
|
@ -281,7 +275,6 @@ class Main:
|
|||
singleAPIThread.daemon = True # close the main program even if there are threads left
|
||||
singleAPIThread.start()
|
||||
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
BMConnectionPool()
|
||||
asyncoreThread = BMNetworkThread()
|
||||
asyncoreThread.daemon = True
|
||||
|
@ -305,12 +298,6 @@ class Main:
|
|||
|
||||
connectToStream(1)
|
||||
|
||||
if not BMConfigParser().get("network", "asyncore"):
|
||||
singleListenerThread = singleListener()
|
||||
singleListenerThread.setup(selfInitiatedConnections)
|
||||
singleListenerThread.daemon = True # close the main program even if there are threads left
|
||||
singleListenerThread.start()
|
||||
|
||||
if BMConfigParser().safeGetBoolean('bitmessagesettings','upnp'):
|
||||
import upnp
|
||||
upnpThread = upnp.uPnPThread()
|
||||
|
|
|
@ -19,7 +19,6 @@ BMConfigDefaults = {
|
|||
"receive": 3,
|
||||
},
|
||||
"network": {
|
||||
"asyncore": True,
|
||||
"bind": '',
|
||||
},
|
||||
"inventory": {
|
||||
|
|
|
@ -192,11 +192,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
|
||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((streamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
streamNumber, 'advertiseobject', inventoryHash))
|
||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||
try:
|
||||
BMConfigParser().set(
|
||||
|
@ -286,11 +282,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
|
||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((streamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
streamNumber, 'advertiseobject', inventoryHash))
|
||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||
try:
|
||||
BMConfigParser().set(
|
||||
|
@ -380,11 +372,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
|
||||
logger.info('broadcasting inv with hash: ' + hexlify(inventoryHash))
|
||||
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((streamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
streamNumber, 'advertiseobject', inventoryHash))
|
||||
queues.UISignalQueue.put(('updateStatusBar', ''))
|
||||
try:
|
||||
BMConfigParser().set(
|
||||
|
@ -513,11 +501,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
objectType, streamNumber, payload, embeddedTime, tag)
|
||||
PendingUpload().add(inventoryHash)
|
||||
logger.info('sending inv (within sendBroadcast function) for object: ' + hexlify(inventoryHash))
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((streamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
streamNumber, 'advertiseobject', inventoryHash))
|
||||
|
||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr._translate("MainWindow", "Broadcast sent on %1").arg(l10n.formatTimestamp()))))
|
||||
|
||||
|
@ -846,11 +830,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
# not sending to a chan or one of my addresses
|
||||
queues.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr._translate("MainWindow", "Message sent. Waiting for acknowledgement. Sent on %1").arg(l10n.formatTimestamp()))))
|
||||
logger.info('Broadcasting inv for my msg(within sendmsg function):' + hexlify(inventoryHash))
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((toStreamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
toStreamNumber, 'advertiseobject', inventoryHash))
|
||||
|
||||
# Update the sent message in the sent table with the necessary information.
|
||||
if BMConfigParser().has_section(toaddress) or not protocol.checkBitfield(behaviorBitfield, protocol.BITFIELD_DOESACK):
|
||||
|
@ -952,11 +932,7 @@ class singleWorker(threading.Thread, StoppableThread):
|
|||
objectType, streamNumber, payload, embeddedTime, '')
|
||||
PendingUpload().add(inventoryHash)
|
||||
logger.info('sending inv (for the getpubkey message)')
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
queues.invQueue.put((streamNumber, inventoryHash))
|
||||
else:
|
||||
protocol.broadcastToSendDataQueues((
|
||||
streamNumber, 'advertiseobject', inventoryHash))
|
||||
|
||||
# wait 10% past expiration
|
||||
sleeptill = int(time.time() + TTL * 1.1)
|
||||
|
|
|
@ -15,7 +15,6 @@ lastSentBytes = 0
|
|||
currentSentSpeed = 0
|
||||
|
||||
def connectedHostsList():
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
retval = []
|
||||
for i in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||
if not i.fullyEstablished:
|
||||
|
@ -25,16 +24,12 @@ def connectedHostsList():
|
|||
except AttributeError:
|
||||
pass
|
||||
return retval
|
||||
return shared.connectedHostsList.items()
|
||||
|
||||
def sentBytes():
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
return asyncore.sentBytes
|
||||
return throttle.SendThrottle().total
|
||||
|
||||
def uploadSpeed():
|
||||
global lastSentTimestamp, lastSentBytes, currentSentSpeed
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
currentTimestamp = time.time()
|
||||
if int(lastSentTimestamp) < int(currentTimestamp):
|
||||
currentSentBytes = asyncore.sentBytes
|
||||
|
@ -42,16 +37,12 @@ def uploadSpeed():
|
|||
lastSentBytes = currentSentBytes
|
||||
lastSentTimestamp = currentTimestamp
|
||||
return currentSentSpeed
|
||||
return throttle.sendThrottle().getSpeed()
|
||||
|
||||
def receivedBytes():
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
return asyncore.receivedBytes
|
||||
return throttle.ReceiveThrottle().total
|
||||
|
||||
def downloadSpeed():
|
||||
global lastReceivedTimestamp, lastReceivedBytes, currentReceivedSpeed
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
currentTimestamp = time.time()
|
||||
if int(lastReceivedTimestamp) < int(currentTimestamp):
|
||||
currentReceivedBytes = asyncore.receivedBytes
|
||||
|
@ -59,23 +50,18 @@ def downloadSpeed():
|
|||
lastReceivedBytes = currentReceivedBytes
|
||||
lastReceivedTimestamp = currentTimestamp
|
||||
return currentReceivedSpeed
|
||||
return throttle.ReceiveThrottle().getSpeed()
|
||||
|
||||
def pendingDownload():
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
tmp = {}
|
||||
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||
for k in connection.objectsNewToMe.keys():
|
||||
tmp[k] = True
|
||||
return len(tmp)
|
||||
return PendingDownloadQueue.totalSize()
|
||||
|
||||
def pendingUpload():
|
||||
if BMConfigParser().get("network", "asyncore"):
|
||||
return 0
|
||||
tmp = {}
|
||||
for connection in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values():
|
||||
for k in connection.objectsNewToThem.keys():
|
||||
tmp[k] = True
|
||||
return len(tmp)
|
||||
return PendingUpload().len()
|
||||
|
|
Loading…
Reference in New Issue
Block a user