improved communicator threading
parent
72f104e447
commit
d8b5127845
|
@ -41,7 +41,8 @@ class OnionrCommunicate:
|
||||||
|
|
||||||
self.highFailureAmount = 7
|
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.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
|
self.peerStatus = {} # network actions (active requests) for peers used mainly to prevent conflicting actions in threads
|
||||||
|
@ -63,7 +64,7 @@ class OnionrCommunicate:
|
||||||
highFailureRate = 10
|
highFailureRate = 10
|
||||||
heartBeatTimer = 0
|
heartBeatTimer = 0
|
||||||
heartBeatRate = 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
|
pexCount = 0
|
||||||
logger.debug('Communicator debugging enabled.')
|
logger.debug('Communicator debugging enabled.')
|
||||||
torID = open('data/hs/hostname').read()
|
torID = open('data/hs/hostname').read()
|
||||||
|
@ -108,14 +109,18 @@ class OnionrCommunicate:
|
||||||
pbT2 = threading.Thread(target=self.processBlocks, name='pbT2')
|
pbT2 = threading.Thread(target=self.processBlocks, name='pbT2')
|
||||||
pbT3 = threading.Thread(target=self.processBlocks, name='pbT3')
|
pbT3 = threading.Thread(target=self.processBlocks, name='pbT3')
|
||||||
pbT4 = threading.Thread(target=self.processBlocks, name='pbT4')
|
pbT4 = threading.Thread(target=self.processBlocks, name='pbT4')
|
||||||
lT1.start()
|
if (self.maxThreads - 8) >= threading.active_count():
|
||||||
lT2.start()
|
lT1.start()
|
||||||
lT3.start()
|
lT2.start()
|
||||||
lT4.start()
|
lT3.start()
|
||||||
pbT1.start()
|
lT4.start()
|
||||||
pbT2.start()
|
pbT1.start()
|
||||||
pbT3.start()
|
pbT2.start()
|
||||||
pbT4.start()
|
pbT3.start()
|
||||||
|
pbT4.start()
|
||||||
|
else:
|
||||||
|
logger.debug(threading.active_count())
|
||||||
|
logger.debug('Too many threads.')
|
||||||
blockProcessTimer = 0
|
blockProcessTimer = 0
|
||||||
if command != False:
|
if command != False:
|
||||||
if command[0] == 'shutdown':
|
if command[0] == 'shutdown':
|
||||||
|
@ -385,7 +390,7 @@ class OnionrCommunicate:
|
||||||
Get new peers and ed25519 keys
|
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
|
peersChecked = 0
|
||||||
peerList = list(self._core.listAdders()) # random ordered list of peers
|
peerList = list(self._core.listAdders()) # random ordered list of peers
|
||||||
newKeys = []
|
newKeys = []
|
||||||
|
@ -512,7 +517,7 @@ class OnionrCommunicate:
|
||||||
for i in self._core.getBlockList(unsaved=True).split("\n"):
|
for i in self._core.getBlockList(unsaved=True).split("\n"):
|
||||||
if i != "":
|
if i != "":
|
||||||
if i in self.blocksProcessing or i in self.ignoredHashes:
|
if i in self.blocksProcessing or i in self.ignoredHashes:
|
||||||
logger.debug('already processing ' + i)
|
#logger.debug('already processing ' + i)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.blocksProcessing.append(i)
|
self.blocksProcessing.append(i)
|
||||||
|
|
|
@ -357,7 +357,8 @@ class OnionrUtils:
|
||||||
try:
|
try:
|
||||||
message = self._core._crypto.pubKeyDecrypt(message, encodedData=True, anonymous=True)
|
message = self._core._crypto.pubKeyDecrypt(message, encodedData=True, anonymous=True)
|
||||||
except nacl.exceptions.CryptoError as e:
|
except nacl.exceptions.CryptoError as e:
|
||||||
logger.error('Unable to decrypt ' + i, error=e)
|
pass
|
||||||
|
#logger.error('Unable to decrypt ' + i, error=e)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
message = json.loads(message.decode())
|
message = json.loads(message.decode())
|
||||||
|
|
Loading…
Reference in New Issue