header component now shows header synchronization progress

This commit is contained in:
Victor Shyba 2019-10-16 10:30:07 -03:00 committed by Lex Berezhny
parent 36031c9d0f
commit 6fcb4d93c9

View file

@ -1,3 +1,4 @@
import math
import os import os
import asyncio import asyncio
import logging import logging
@ -110,6 +111,7 @@ class WalletComponent(Component):
local_height = self.wallet_manager.ledger.local_height_including_downloaded_height local_height = self.wallet_manager.ledger.local_height_including_downloaded_height
remote_height = self.wallet_manager.ledger.network.remote_height remote_height = self.wallet_manager.ledger.network.remote_height
best_hash = self.wallet_manager.get_best_blockhash() best_hash = self.wallet_manager.get_best_blockhash()
progress = min(max(math.ceil(float(local_height) / float(remote_height) * 100), 0), 100)
return { return {
'connected_servers': [ 'connected_servers': [
{ {
@ -119,6 +121,7 @@ class WalletComponent(Component):
} for session in self.wallet_manager.ledger.network.session_pool.sessions } for session in self.wallet_manager.ledger.network.session_pool.sessions
if session and session.available if session and session.available
], ],
'headers_synchronization_progress': progress,
'blocks': max(local_height, 0), 'blocks': max(local_height, 0),
'blocks_behind': max(remote_height - local_height, 0), 'blocks_behind': max(remote_height - local_height, 0),
'best_blockhash': best_hash, 'best_blockhash': best_hash,