From d1540ccb5b5d15a9050667d6d1a3410fdaa4929d Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:22:41 +0100 Subject: [PATCH] wallet: add batch size setting (#431) --- 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 6a58eeb..a7d126e 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 605ef24..b2010b8 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)