dev@locazia: many fixes

This commit is contained in:
user committed 2024-03-06 13:19:36 +03:00
1 parent dda25a71f4
commit cad723925c
3 files changed
+26 -10

No files matched your search

+24 -9
View File
@@ -1,10 +1,11 @@
from tonsdk.boc import begin_cell
from app.core.logger import make_log
from app.core._config import MY_FUND_ADDRESS
from app.core._config import MY_FUND_ADDRESS, MY_PLATFORM_CONTRACT
from app.core.storage import db_session
from app.core._secrets import service_wallet
from app.core._blockchain.ton.toncenter import toncenter
from app.core._utils.send_status import send_status
from tonsdk.utils import Address
import asyncio
import os, sys
@@ -37,7 +38,7 @@ async def main_fn():
)['message'].to_boc(False)
)
await asyncio.sleep(5)
return await main()
return await main_fn()
if os.getenv("TON_BEGIN_COMMAND_WITHDRAW"):
await toncenter.send_boc(
@@ -53,17 +54,31 @@ async def main_fn():
make_log("TON", "Withdraw command sent", level="info")
await asyncio.sleep(10)
platform_state = await toncenter.get_account(MY_PLATFORM_CONTRACT)
if not platform_state.get('code'):
make_log("TON", "Platform contract is not deployed, shutdown service..", level="info")
await send_status("ton_daemon", "Platform contract is not deployed, not working")
while True:
await asyncio.sleep(100)
while True:
sw_seqno_value = await get_sw_seqno()
make_log("TON", f"Service running ({sw_seqno_value})", level="debug")
# with db_session() as session:
# for stored_content in session.query(StoredContent).filter(StoredContent.uploaded == False).all():
# pass
try:
sw_seqno_value = await get_sw_seqno()
make_log("TON", f"Service running ({sw_seqno_value})", level="debug")
await asyncio.sleep(5)
await send_status("ton", f"working (seqno={sw_seqno_value})")
# with db_session() as session:
# for stored_content in session.query(StoredContent).filter(StoredContent.uploaded == False).all():
# pass
await asyncio.sleep(5)
await send_status("ton_daemon", f"working (seqno={sw_seqno_value})")
except BaseException as e:
make_log("TON", f"Error: {e}", level="error")
await asyncio.sleep(3)
# if __name__ == '__main__':
# loop = asyncio.get_event_loop()
# loop.run_until_complete(main())