|  |  | @ -124,7 +124,17 @@ class LokiMessageAPI { | 
			
		
	
		
		
			
				
					
					|  |  |  |       promises.push(this.openSendConnection(params)); |  |  |  |       promises.push(this.openSendConnection(params)); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     const results = await Promise.all(promises); |  |  |  |     let results; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     try { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       results = await Promise.all(promises); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } catch (e) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       if (e instanceof textsecure.WrongDifficultyError) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         // Force nonce recalculation
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         this.sendMessage(pubKey, data, messageTimeStamp, ttl, options); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       throw e; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |     delete this.sendingSwarmNodes[timestamp]; |  |  |  |     delete this.sendingSwarmNodes[timestamp]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (results.every(value => value === false)) { |  |  |  |     if (results.every(value => value === false)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       throw new window.textsecure.EmptySwarmError( |  |  |  |       throw new window.textsecure.EmptySwarmError( | 
			
		
	
	
		
		
			
				
					|  |  | @ -155,15 +165,17 @@ class LokiMessageAPI { | 
			
		
	
		
		
			
				
					
					|  |  |  |     while (successiveFailures < 3) { |  |  |  |     while (successiveFailures < 3) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       await sleepFor(successiveFailures * 500); |  |  |  |       await sleepFor(successiveFailures * 500); | 
			
		
	
		
		
			
				
					
					|  |  |  |       try { |  |  |  |       try { | 
			
		
	
		
		
			
				
					
					|  |  |  |         const result = await rpc(`http://${url}`, this.snodeServerPort, 'store', params); |  |  |  |         const result = await rpc( | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           `http://${url}`, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           this.snodeServerPort, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           'store', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           params | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         // Make sure we aren't doing too much PoW
 |  |  |  |         // Make sure we aren't doing too much PoW
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         const currentDifficulty = window.storage.get('PoWDifficulty', null); |  |  |  |         const currentDifficulty = window.storage.get('PoWDifficulty', null); | 
			
		
	
		
		
			
				
					
					|  |  |  |         const newDifficulty = result.difficulty; |  |  |  |         const newDifficulty = result.difficulty; | 
			
		
	
		
		
			
				
					
					|  |  |  |         if ( |  |  |  |         if (newDifficulty != null && newDifficulty !== currentDifficulty) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           !Number.isNaN(newDifficulty) && |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           newDifficulty !== currentDifficulty |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |           window.storage.put('PoWDifficulty', newDifficulty); |  |  |  |           window.storage.put('PoWDifficulty', newDifficulty); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         return true; |  |  |  |         return true; | 
			
		
	
	
		
		
			
				
					|  |  | @ -179,6 +191,7 @@ class LokiMessageAPI { | 
			
		
	
		
		
			
				
					
					|  |  |  |           if (!Number.isNaN(newDifficulty)) { |  |  |  |           if (!Number.isNaN(newDifficulty)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             window.storage.put('PoWDifficulty', newDifficulty); |  |  |  |             window.storage.put('PoWDifficulty', newDifficulty); | 
			
		
	
		
		
			
				
					
					|  |  |  |           } |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           throw e; | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else if (e instanceof textsecure.NotFoundError) { |  |  |  |         } else if (e instanceof textsecure.NotFoundError) { | 
			
		
	
		
		
			
				
					
					|  |  |  |           // TODO: Handle resolution error
 |  |  |  |           // TODO: Handle resolution error
 | 
			
		
	
		
		
			
				
					
					|  |  |  |           successiveFailures += 1; |  |  |  |           successiveFailures += 1; | 
			
		
	
	
		
		
			
				
					|  |  | 
 |