forked from LBRYCommunity/lbry-sdk
response
This commit is contained in:
parent
6e3a25d255
commit
c2dae43965
1 changed files with 31 additions and 37 deletions
|
@ -107,42 +107,36 @@ class WalletComponent(Component):
|
||||||
return self.wallet_manager
|
return self.wallet_manager
|
||||||
|
|
||||||
async def get_status(self):
|
async def get_status(self):
|
||||||
if self.wallet_manager:
|
if self.wallet_manager is None:
|
||||||
sessions = self.wallet_manager.ledger.network.session_pool.sessions
|
return
|
||||||
if self.wallet_manager.ledger.network.remote_height:
|
session_pool = self.wallet_manager.ledger.network.session_pool
|
||||||
local_height = self.wallet_manager.ledger.local_height_including_downloaded_height
|
sessions = session_pool.sessions
|
||||||
remote_height = self.wallet_manager.ledger.network.remote_height
|
result = {
|
||||||
best_hash = self.wallet_manager.get_best_blockhash()
|
'servers': [
|
||||||
progress = min(max(math.ceil(float(local_height) / float(remote_height) * 100), 0), 100)
|
{
|
||||||
return {
|
'host': session.server[0],
|
||||||
'servers': [
|
'port': session.server[1],
|
||||||
{
|
'latency': session.connection_latency,
|
||||||
'host': session.server[0],
|
'availability': session.available,
|
||||||
'port': session.server[1],
|
} for session in sessions
|
||||||
'latency': round(session.connection_latency, 2) if session.connection_latency else None,
|
],
|
||||||
'availability': session.available,
|
'known_servers': len(sessions),
|
||||||
} for session in sessions
|
'available_servers': len(list(session_pool.available_sessions))
|
||||||
],
|
}
|
||||||
'headers_synchronization_progress': progress,
|
|
||||||
'blocks': max(local_height, 0),
|
if self.wallet_manager.ledger.network.remote_height:
|
||||||
'blocks_behind': max(remote_height - local_height, 0),
|
local_height = self.wallet_manager.ledger.local_height_including_downloaded_height
|
||||||
'best_blockhash': best_hash,
|
remote_height = self.wallet_manager.ledger.network.remote_height
|
||||||
'known_servers': len(sessions),
|
best_hash = self.wallet_manager.get_best_blockhash()
|
||||||
'available_servers': sum(s.available is True for s in sessions)
|
progress = min(max(math.ceil(float(local_height) / float(remote_height) * 100), 0), 100)
|
||||||
}
|
result.update({
|
||||||
else:
|
'headers_synchronization_progress': progress,
|
||||||
return {
|
'blocks': max(local_height, 0),
|
||||||
'servers': [
|
'blocks_behind': max(remote_height - local_height, 0),
|
||||||
{
|
'best_blockhash': best_hash,
|
||||||
'host': session.server[0],
|
})
|
||||||
'port': session.server[1],
|
|
||||||
'latency': round(session.connection_latency, 2) if session.connection_latency else None,
|
return result
|
||||||
'availability': session.available,
|
|
||||||
} for session in sessions
|
|
||||||
],
|
|
||||||
'known_servers': len(sessions),
|
|
||||||
'available_servers': sum(s.available is True for s in sessions)
|
|
||||||
}
|
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
log.info("Starting torba wallet")
|
log.info("Starting torba wallet")
|
||||||
|
@ -305,7 +299,7 @@ class StreamManagerComponent(Component):
|
||||||
blob_manager = self.component_manager.get_component(BLOB_COMPONENT)
|
blob_manager = self.component_manager.get_component(BLOB_COMPONENT)
|
||||||
storage = self.component_manager.get_component(DATABASE_COMPONENT)
|
storage = self.component_manager.get_component(DATABASE_COMPONENT)
|
||||||
wallet = self.component_manager.get_component(WALLET_COMPONENT)
|
wallet = self.component_manager.get_component(WALLET_COMPONENT)
|
||||||
node = self.component_manager.get_component(DHT_COMPONENT)\
|
node = self.component_manager.get_component(DHT_COMPONENT) \
|
||||||
if self.component_manager.has_component(DHT_COMPONENT) else None
|
if self.component_manager.has_component(DHT_COMPONENT) else None
|
||||||
log.info('Starting the file manager')
|
log.info('Starting the file manager')
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
Loading…
Reference in a new issue