@@ -149,7 +149,7 @@ async def _update_avg_ips(self, challenge_hash, iterations_needed, ip):
149149 new_avg_ips = int ((prev_avg_ips * trials + ips ) / (trials + 1 ))
150150 self .avg_ips [ip ] = (new_avg_ips , trials + 1 )
151151 log .info (f"New estimate: { new_avg_ips } " )
152- # self.pending_iters[challenge_hash].remove(iterations_needed)
152+ self .pending_iters [challenge_hash ].remove (iterations_needed )
153153 else :
154154 log .info (
155155 f"Finished PoT chall:{ challenge_hash [:10 ].hex ()} .. { iterations_needed } "
@@ -180,7 +180,7 @@ async def _update_proofs_count(self, challenge_weight):
180180 del self .active_discriminants_start_time [active_disc ]
181181 self .done_discriminants .append (active_disc )
182182
183- async def send_iterations (self , challenge_hash , writer ):
183+ async def _send_iterations (self , challenge_hash , writer ):
184184 alive_discriminant = True
185185 while (alive_discriminant ):
186186 async with self .lock :
@@ -244,7 +244,7 @@ async def _do_process_communication(
244244 self .active_discriminants [challenge_hash ] = (writer , challenge_weight , ip )
245245 self .active_discriminants_start_time [challenge_hash ] = time .time ()
246246
247- asyncio .create_task (self .send_iterations (challenge_hash , writer ))
247+ asyncio .create_task (self ._send_iterations (challenge_hash , writer ))
248248
249249 # Listen to the server until "STOP" is received.
250250 while True :
@@ -332,9 +332,25 @@ async def _manage_discriminant_queue(self):
332332 )
333333 self .discriminant_queue .clear ()
334334 else :
335- disc = next (
335+ max_weight_disc = [
336336 d for d , h in self .discriminant_queue if h == max_weight
337- )
337+ ]
338+ with_iters = [
339+ d for d in max_weight_disc
340+ if d in self .pending_iters
341+ and len (self .pending_iters [d ]) != 0
342+ ]
343+ if (len (with_iters ) == 0 ):
344+ disc = max_weight_disc [0 ]
345+ else :
346+ min_iter = min ([
347+ min (self .pending_iters [d ])
348+ for d in with_iters
349+ ])
350+ disc = next (
351+ d for d in with_iters
352+ if min (self .pending_iters [d ]) == min_iter
353+ )
338354 if len (self .free_servers ) != 0 :
339355 ip , port = self .free_servers [0 ]
340356 self .free_servers = self .free_servers [1 :]
@@ -406,10 +422,14 @@ async def proof_of_space_info(
406422
407423 if proof_of_space_info .challenge_hash not in self .pending_iters :
408424 self .pending_iters [proof_of_space_info .challenge_hash ] = []
425+ if proof_of_space_info .challenge_hash not in self .submitted_iters :
426+ self .submitted_iters [proof_of_space_info .challenge_hash ] = []
409427
410428 if (
411429 proof_of_space_info .iterations_needed
412430 not in self .pending_iters [proof_of_space_info .challenge_hash ]
431+ and proof_of_space_info .iterations_needed
432+ not in self .submitted_iters [proof_of_space_info .challenge_hash ]
413433 ):
414434 log .info (
415435 f"proof_of_space_info { proof_of_space_info .challenge_hash } adding "
0 commit comments