This function is only used by TransactionTableModel constructor which, for big wallets, causes a delay/hang on startup. This is even noticeable in #10102.
There's two simple changes to improve this:
- defer
getWalletTxsto when the transactions view is opened - call in a background thread to not block Qt event loop, like wallet loading
However the following issues would still be present:
- doesn't reduce IPC traffic
- keeps a huge lock on
cs_wallet - loads the whole wallet in the transaction model unnecessarily (the view only shows a subset)
Considering the above, one way to improve is to paginate getWalletTxs.
However, TransactionTableModel can decomposes each transaction in multiple records, so it's not possible to know beforehand the row count and also because each page of transactions results in an indeterminate number of rows.
I have 2 different approaches to improve:
a) manage wallet records on CWallet and expose them with interfaces::Wallet::getRecords that supports pagination
b) instead of table model, make records children of a row for each txid - this would allow to reopen #12578.
I'd love to know other's thoughts on this matter. Are the 2 simple changes 1. and 2. enough for the moment?