improved communicator threading

This commit is contained in:
Kevin Froman 2018-05-04 21:07:43 -05:00
parent 72f104e447
commit d8b5127845
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 19 additions and 13 deletions

View File

@ -41,7 +41,8 @@ class OnionrCommunicate:
self.highFailureAmount = 7
self.communicatorThreads = []
self.communicatorThreads = 0
self.maxThreads = 75
self.blocksProcessing = [] # list of blocks currently processing, to avoid trying a block twice at once in 2 seperate threads
self.peerStatus = {} # network actions (active requests) for peers used mainly to prevent conflicting actions in threads
@ -63,7 +64,7 @@ class OnionrCommunicate:
highFailureRate = 10
heartBeatTimer = 0
heartBeatRate = 0
pexTimer = 25 # How often we should check for new peers
pexTimer = 120 # How often we should check for new peers
pexCount = 0
logger.debug('Communicator debugging enabled.')
torID = open('data/hs/hostname').read()
@ -108,14 +109,18 @@ class OnionrCommunicate:
pbT2 = threading.Thread(target=self.processBlocks, name='pbT2')
pbT3 = threading.Thread(target=self.processBlocks, name='pbT3')
pbT4 = threading.Thread(target=self.processBlocks, name='pbT4')
lT1.start()
lT2.start()
lT3.start()
lT4.start()
pbT1.start()
pbT2.start()
pbT3.start()
pbT4.start()
if (self.maxThreads - 8) >= threading.active_count():
lT1.start()
lT2.start()
lT3.start()
lT4.start()
pbT1.start()
pbT2.start()
pbT3.start()
pbT4.start()
else:
logger.debug(threading.active_count())
logger.debug('Too many threads.')
blockProcessTimer = 0
if command != False:
if command[0] == 'shutdown':
@ -385,7 +390,7 @@ class OnionrCommunicate:
Get new peers and ed25519 keys
'''
peersCheck = 5 # Amount of peers to ask for new peers + keys
peersCheck = 2 # Amount of peers to ask for new peers + keys
peersChecked = 0
peerList = list(self._core.listAdders()) # random ordered list of peers
newKeys = []
@ -512,7 +517,7 @@ class OnionrCommunicate:
for i in self._core.getBlockList(unsaved=True).split("\n"):
if i != "":
if i in self.blocksProcessing or i in self.ignoredHashes:
logger.debug('already processing ' + i)
#logger.debug('already processing ' + i)
continue
else:
self.blocksProcessing.append(i)

View File

@ -357,7 +357,8 @@ class OnionrUtils:
try:
message = self._core._crypto.pubKeyDecrypt(message, encodedData=True, anonymous=True)
except nacl.exceptions.CryptoError as e:
logger.error('Unable to decrypt ' + i, error=e)
pass
#logger.error('Unable to decrypt ' + i, error=e)
else:
try:
message = json.loads(message.decode())