fixed hide blocks being broken in some cases
This commit is contained in:
		
							parent
							
								
									8649231860
								
							
						
					
					
						commit
						d0bdeca7c4
					
				
					 4 changed files with 20 additions and 5 deletions
				
			
		|  | @ -3,6 +3,9 @@ | |||
| Upload blocks in the upload queue to peers from the communicator | ||||
| """ | ||||
| from typing import TYPE_CHECKING | ||||
| from time import sleep | ||||
| from threading import Thread | ||||
| 
 | ||||
| from . import sessionmanager | ||||
| 
 | ||||
| from onionrtypes import UserID | ||||
|  | @ -45,6 +48,14 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): | |||
|     comm_inst.blocksToUpload = onionrcrypto.cryptoutils.random_shuffle( | ||||
|         comm_inst.blocksToUpload) | ||||
| 
 | ||||
|     def remove_from_hidden(bl): | ||||
|         sleep(60) | ||||
|         try: | ||||
|             comm_inst.shared_state.get_by_string( | ||||
|                 'PublicAPI').hideBlocks.remove(bl) | ||||
|         except ValueError: | ||||
|             pass | ||||
| 
 | ||||
|     if len(comm_inst.blocksToUpload) != 0: | ||||
|         for bl in comm_inst.blocksToUpload: | ||||
|             if not stringvalidators.validate_hash(bl): | ||||
|  | @ -84,6 +95,8 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): | |||
|                     content_type='application/octet-stream') | ||||
|                 if resp is not False: | ||||
|                     if resp == 'success': | ||||
|                         Thread(target=remove_from_hidden, | ||||
|                                args=[bl], daemon=True).start() | ||||
|                         session.success() | ||||
|                         session.peer_exists[peer] = True | ||||
|                     elif resp == 'exists': | ||||
|  | @ -102,6 +115,10 @@ def upload_blocks_from_communicator(comm_inst: 'OnionrCommunicatorDaemon'): | |||
|     for x in finishedUploads: | ||||
|         try: | ||||
|             comm_inst.blocksToUpload.remove(x) | ||||
| 
 | ||||
|             comm_inst.shared_state.get_by_string( | ||||
|                 'PublicAPI').hideBlocks.remove(x) | ||||
| 
 | ||||
|         except ValueError: | ||||
|             pass | ||||
|     comm_inst.decrementThreadCount(TIMER_NAME) | ||||
|  |  | |||
|  | @ -7,7 +7,6 @@ if TYPE_CHECKING: | |||
|     from session import UploadSession | ||||
| 
 | ||||
| from onionrutils import bytesconverter | ||||
| from onionrutils import localcommand | ||||
| from etc import onionrvalues | ||||
| from utils import reconstructhash | ||||
| 
 | ||||
|  | @ -122,4 +121,3 @@ class BlockUploadSessionManager: | |||
|                 comm_inst.blocksToUpload.remove(sess.block_hash) | ||||
|             except ValueError: | ||||
|                 pass | ||||
|             localcommand.local_command(f'waitforshare/{sess.block_hash}') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue