organize logic for when its downloading

This commit is contained in:
Victor Shyba 2019-12-18 19:09:33 -03:00
parent c85127d76b
commit 91846939f6

View file

@ -128,14 +128,13 @@ class WalletComponent(Component):
if self.wallet_manager.ledger.network.remote_height:
local_height = self.wallet_manager.ledger.local_height_including_downloaded_height
disk_height = len(self.wallet_manager.ledger.headers)
download_height = local_height - disk_height if disk_height != local_height else local_height
remote_height = self.wallet_manager.ledger.network.remote_height
target_height = remote_height - disk_height if disk_height != local_height else remote_height
best_hash = self.wallet_manager.get_best_blockhash()
if not target_height:
progress = 100
if disk_height != local_height != remote_height:
download_height, target_height = local_height - disk_height, remote_height - disk_height
else:
progress = min(max(math.ceil(float(download_height) / float(target_height) * 100), 0), 100)
download_height, target_height = local_height, remote_height
progress = min(max(math.ceil(float(download_height) / float(target_height) * 100), 0), 100)
best_hash = self.wallet_manager.get_best_blockhash()
result.update({
'headers_synchronization_progress': progress,
'blocks': max(local_height, 0),