[electrum] write compact JSON for unencrypted wallet files
Summary:
Most users don't read the content of the wallet files, and for debugging it is easy to convert the format to pretty JSON:
cat wallet_file | python -c'import fileinput, json; print(json.dumps(json.loads("".join(fileinput.input())), sort_keys=True, indent=4))'
The gain is a 20% reduction in file size for unencrypted wallets, and a 100+% speed improvement when writing the wallet to disk.
Before:
$ ls -lrth ../.electrum-abc_bck_2023-07-07/wallets/ -rw------- 1 pierre pierre 15K juil. 7 09:30 default_wallet -rw-r--r-- 1 pierre pierre 2,0M juil. 7 09:30 test_wallet -rw-r--r-- 1 pierre pierre 986K juil. 7 09:30 default_encr -rw------- 1 pierre pierre 110M juil. 7 09:30 ifp_addr $ ./electrum-abc -v | 14.088| |04| [profiler] WalletStorage.write 0.9765 | 15.629| |04| [profiler] WalletStorage.write 0.9118 | 34.379| |00| [profiler] WalletStorage.write 0.9347
After:
$ ./electrum-abc -v | 14.503| |04| [profiler] WalletStorage.write 0.4619 | 15.696| |04| [profiler] WalletStorage.write 0.3535 | 35.000| |00| [profiler] WalletStorage.write 0.3855 | 35.838| |00| [profiler] WalletStorage.write 0.3627 $ ls -lrth wallets -rw-r--r-- 1 pierre pierre 959K juil. 9 09:53 default_encr -rw-r--r-- 1 pierre pierre 1,6M juil. 9 09:54 test_wallet -rw------- 1 pierre pierre 14K juil. 9 09:54 default_wallet -rw------- 1 pierre pierre 90M juil. 9 09:55 ifp_addr
Encrypted wallet files already used compact JSON, so this is a very minor improvement by removing spaces from delimiters.
Test Plan:
python test_runner.py
Profiling (see Summary) and testing the application.
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14234