From f638ed40ff101288422935f6a64b0a1c9cdfa9fb Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:18:54 +0100 Subject: [PATCH] wallet: add batch size setting --- cashu/core/settings.py | 1 + cashu/wallet/cli/cli.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cashu/core/settings.py b/cashu/core/settings.py index 6a58eeb4..a7d126e3 100644 --- a/cashu/core/settings.py +++ b/cashu/core/settings.py @@ -139,6 +139,7 @@ class WalletSettings(CashuSettings): ) locktime_delta_seconds: int = Field(default=86400) # 1 day + proofs_batch_size: int = Field(default=1000) class LndRestFundingSource(MintSettings): diff --git a/cashu/wallet/cli/cli.py b/cashu/wallet/cli/cli.py index 605ef240..b2010b86 100644 --- a/cashu/wallet/cli/cli.py +++ b/cashu/wallet/cli/cli.py @@ -576,8 +576,11 @@ async def burn(ctx: Context, token: str, all: bool, force: bool, delete: str): if delete: await wallet.invalidate(proofs) else: - # batch check proofs - for _proofs in [proofs[i : i + 100] for i in range(0, len(proofs), 100)]: + # invalidate proofs in batches + for _proofs in [ + proofs[i : i + settings.proofs_batch_size] + for i in range(0, len(proofs), settings.proofs_batch_size) + ]: await wallet.invalidate(_proofs, check_spendable=True) print_balance(ctx)