HomePhabricator

[electrum] refactor make_unsigned_transaction to not generate the unspent coins…

Description

[electrum] refactor make_unsigned_transaction to not generate the unspent coins every call

Summary:
On wallets with many coins for few addresses, add_input_info is called a lot for the same addresses. Avoid costly and unnecessary get_address_unspent calls by caching the result for each addreess.

Remove the same optimization done for the coin consolidation tool and use the newly optimized wallet.add_input_info

Profiling:

Annotate AbstractWallet.make_unsigned_transaction with @profiler, run the application in verbose mode (./electrum-abc -v), open the IFP address wallet, select 500 coins and choose "Spend" in the dropdown menu, go to the send tab and type something in the Amount widget

Before:

[profiler] AbstractWallet.make_unsigned_transaction 33.5602
[profiler] AbstractWallet.make_unsigned_transaction 33.5048

After:

[profiler] AbstractWallet.make_unsigned_transaction 0.0926
[profiler] AbstractWallet.make_unsigned_transaction 0.0909

Depends on D14248

Test Plan:
python test_runner.py

Test the coin consolidation tool, check that the output is the same before and after this diff.

Check that the gui freezing is much less severe on a wallet with thousands of inputs for a single address.

Enable cashfusion

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14249

Details

Provenance
PiRKAuthored on Jul 11 2023, 10:39
PiRKPushed on Jul 12 2023, 20:49
Reviewer
Restricted Project
Differential Revision
D14249: [electrum] refactor make_unsigned_transaction to not generate the unspent coins every call
Parents
rABCb59a28904aac: [electrum] split get_addr_io into get_address_unspent and get_address_spent
Branches
Unknown
Tags
Unknown