From 3af531aacd6e8c8a9b9e2f1b6020d033e9d475bf Mon Sep 17 00:00:00 2001 From: Shroominic Date: Thu, 21 Aug 2025 15:36:51 -0300 Subject: [PATCH] improve latency by 3s --- routstr/wallet.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/routstr/wallet.py b/routstr/wallet.py index 78ce0a1e..717539bd 100644 --- a/routstr/wallet.py +++ b/routstr/wallet.py @@ -30,8 +30,8 @@ async def recieve_token( if len(token_obj.keysets) > 1: raise ValueError("Multiple keysets per token currently not supported") - wallet = await get_wallet(token_obj.mint, token_obj.unit) - await wallet.load_mint(token_obj.keysets[0]) + wallet = await get_wallet(token_obj.mint, token_obj.unit, load=False) + wallet.keyset_id = token_obj.keysets[0] if token_obj.mint not in TRUSTED_MINTS: return await swap_to_primary_mint(token_obj, wallet) @@ -147,7 +147,7 @@ async def credit_balance( _wallets: dict[str, Wallet] = {} -async def get_wallet(mint_url: str, unit: str = "sat") -> Wallet: +async def get_wallet(mint_url: str, unit: str = "sat", load: bool = True) -> Wallet: global _wallets id = f"{mint_url}_{unit}" if id not in _wallets: @@ -155,8 +155,9 @@ async def get_wallet(mint_url: str, unit: str = "sat") -> Wallet: mint_url, db=".wallet", load_all_keysets=True, unit=unit ) - await _wallets[id].load_mint() - await _wallets[id].load_proofs(reload=True) + if load: + await _wallets[id].load_mint() + await _wallets[id].load_proofs(reload=True) return _wallets[id] @@ -297,7 +298,7 @@ async def periodic_payout() -> None: logger.error("RECEIVE_LN_ADDRESS is not set, skipping payout") return while True: - await asyncio.sleep(6) + await asyncio.sleep(60 * 5) try: async with db.create_session() as session: for mint_url in TRUSTED_MINTS: