Ok, all done. But it is slow af. Wonder what I'm doing wrong. Just growing a 2d vector to hold the data should be blazing fast.
Discussion
It's about the same speed now as writing to the file. Kind of sad that it is not faster, but at the same this means Bitcoin Core is already doing a decent job at it.