dev@locazia: fix indexation
This commit is contained in:
1 parent
b4b7a878f4
commit
cc8b830260
2 files changed
+11
-3
No files matched your search
@@ -5,6 +5,7 @@ from datetime import datetime
|
||||
from base58 import b58encode, b58decode
|
||||
from sanic import response
|
||||
|
||||
from app.core.models.node_storage import StoredContent
|
||||
from app.core._blockchain.ton.platform import platform
|
||||
from app.core._crypto.signer import Signer
|
||||
from app.core._secrets import hot_pubkey, service_wallet, hot_seed
|
||||
@@ -18,11 +19,16 @@ def get_git_info():
|
||||
|
||||
|
||||
async def s_api_v1_node(request): # /api/v1/node
|
||||
last_known_index = request.ctx.db_session.query(StoredContent).filter(
|
||||
StoredContent.type == "onchain/content"
|
||||
).order_by(StoredContent.onchain_index.desc()).first()
|
||||
last_known_index = last_known_index.onchain_index if last_known_index else 0
|
||||
last_known_index = max(last_known_index, 0)
|
||||
return response.json({
|
||||
'id': b58encode(hot_pubkey).decode(),
|
||||
'node_address': service_wallet.address.to_string(1, 1, 1),
|
||||
'master_address': platform.address.to_string(1, 1, 1),
|
||||
'indexer_height': 0,
|
||||
'indexer_height': last_known_index,
|
||||
'services': {
|
||||
service_key: {
|
||||
'status': (service['status'] if (service['timestamp'] and (datetime.now() - service['timestamp']).total_seconds() < 30) else 'not working: timeout'),
|
||||
|
||||
Reference in new issue
Block a user