Currently, `prepare_indexed_txs` is still one of the slowest parts of the indexer due to the disk access, even when using batched queries.
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 ??? when syncing the first 300000ish blocks with depth:
| bench | total time [s] | time prepare [s] |
| no prepare | 1066.85 | 0 |
| old, before D15571 | 4375.39 | 3308.54 |
| D15571 | 3148.51 | 2081.66 |
| this diff, depth = 10 | | |
| this diff, depth = 100 | | |
| this diff, depth = 1000 | | |