Currently, `prepare_indexed_txs` is still one of the slowest parts of the indexer due to the disk access, even when using batched queries.
In this diff, we add a `TxNumCache`, which simply stores the last `depth_blocks` worth of tx nums in a VecDeque of HashMaps. The oldest block of txids is dropped off at the end, and the new block is added at the beginning.
The required memory will be 40B per TxId (32-byte txid + 8-byte TxNum, +small HashMap overhead), so a 2000 tx block will require 80kB; meaning a 10 deep cache would require around 800kB, 100 deep 8MB, and 1000 deep 80MB.
Benchmarks show there's a speedup of about 1,69 when syncing the first 300000ish blocks with depth 100:
| bench | 300k total time [s] | 300k time prepare [s] | 400k total time [s] |
| no prepare | 1066.85 | 0 | |
| old, before D15571 | 4375.39 | 3308.54 | |
| D15571 | 3148.51 | 2081.66 | |
| this diff, depth = 10 | 2749.21 | 1682.36 | 8595.97 |
| this diff, depth = 100 | 2297.97 | 1231.12 | 7214.19 |
| this diff, depth = 1000 | 2969.34 | 1902.49 | |