I am working on a Blockchain.info-like block explorer, and I have some questions regarding best practice for data retrieval. Bitcoin Core stores and serves all blocks and, if txindex is set to 1, all transactions too. It doesn't, however, have an option where you can tell it to maintain an index of all addresses.
I wrote a script that iterates through all blocks and inserts the address/txId key pairs into a MySQL table indexed on address. It maintains the index by polling for new blocks. The program doesn't yet take into account unconfirmed transactions, and chain reorganizations can result in invalid data. Is there a better way to do it?