Merge branch 'uploadwait2' into 'master'

Merge Uploadwait2

See merge request beardog/Onionr!13
This commit is contained in:
Kevin 2018-11-16 22:34:54 +00:00
commit 7f0365c66d
2 changed files with 9 additions and 4 deletions

View File

@ -403,7 +403,7 @@ class OnionrCommunicatorDaemon:
'''Perform a get request to a peer''' '''Perform a get request to a peer'''
if len(peer) == 0: if len(peer) == 0:
return False return False
logger.info('Performing ' + action + ' with ' + peer + ' on port ' + str(self.proxyPort)) #logger.debug('Performing ' + action + ' with ' + peer + ' on port ' + str(self.proxyPort))
url = 'http://' + peer + '/public/?action=' + action url = 'http://' + peer + '/public/?action=' + action
if len(data) > 0: if len(data) > 0:
url += '&data=' + data url += '&data=' + data
@ -493,6 +493,7 @@ class OnionrCommunicatorDaemon:
for bl in self.blocksToUpload: for bl in self.blocksToUpload:
if not self._core._utils.validateHash(bl): if not self._core._utils.validateHash(bl):
logger.warn('Requested to upload invalid block') logger.warn('Requested to upload invalid block')
self.decrementThreadCount('uploadBlock')
return return
for i in range(max(len(self.onlinePeers), 2)): for i in range(max(len(self.onlinePeers), 2)):
peer = self.pickOnlinePeer() peer = self.pickOnlinePeer()
@ -506,12 +507,16 @@ class OnionrCommunicatorDaemon:
proxyType = 'tor' proxyType = 'tor'
elif peer.endswith('.i2p'): elif peer.endswith('.i2p'):
proxyType = 'i2p' proxyType = 'i2p'
logger.info("Uploading block") logger.info("Uploading block to " + peer)
if not self._core._utils.doPostRequest(url, data=data, proxyType=proxyType) == False: if not self._core._utils.doPostRequest(url, data=data, proxyType=proxyType) == False:
self._core._utils.localCommand('waitForShare', data=bl) self._core._utils.localCommand('waitForShare', data=bl)
finishedUploads.append(bl) finishedUploads.append(bl)
break
for x in finishedUploads: for x in finishedUploads:
try:
self.blocksToUpload.remove(x) self.blocksToUpload.remove(x)
except ValueError:
pass
self.decrementThreadCount('uploadBlock') self.decrementThreadCount('uploadBlock')
def announce(self, peer): def announce(self, peer):

View File

@ -276,7 +276,7 @@ class OnionrUtils:
if myBlock.getMetadata('newFSKey') is not None: if myBlock.getMetadata('newFSKey') is not None:
onionrusers.OnionrUser(self._core, signer).addForwardKey(myBlock.getMetadata('newFSKey')) onionrusers.OnionrUser(self._core, signer).addForwardKey(myBlock.getMetadata('newFSKey'))
else: else:
logger.warn('FS not used for this encrypted block') logger.debug('FS not used for this block')
logger.info(myBlock.bmetadata) logger.info(myBlock.bmetadata)
try: try: