Skip to content

Commit

Permalink
Refresh download/upload rates in farmer. (Chia-Network#6776)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchirica authored Jun 15, 2021
1 parent 79bc40f commit dace191
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions chia/farmer/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(
raise RuntimeError(error_str)

async def _start(self):
self.cache_clear_task = asyncio.create_task(self._periodically_clear_cache_task())
self.cache_clear_task = asyncio.create_task(self._periodically_clear_cache_and_refresh_task())

def _close(self):
self._shut_down = True
Expand Down Expand Up @@ -168,8 +168,9 @@ def set_reward_targets(self, farmer_target_encoded: Optional[str], pool_target_e
config["pool"]["xch_target_address"] = pool_target_encoded
save_config(self._root_path, "config.yaml", config)

async def _periodically_clear_cache_task(self):
async def _periodically_clear_cache_and_refresh_task(self):
time_slept: uint64 = uint64(0)
refresh_slept = 0
while not self._shut_down:
if time_slept > self.constants.SUB_SLOT_TIME_TARGET:
now = time.time()
Expand All @@ -189,4 +190,9 @@ async def _periodically_clear_cache_task(self):
f"{len(self.quality_str_to_identifiers)} {len(self.number_of_responses)}"
)
time_slept += 1
refresh_slept += 1
# Periodically refresh GUI to show the correct download/upload rate.
if refresh_slept >= 30:
self.state_changed("add_connection", {})
refresh_slept = 0
await asyncio.sleep(1)

0 comments on commit dace191

Please sign in to comment.