I presume Solidity events are fired the moment the block that includes its transaction is mined -- please correct me if I'm wrong.
I need to sync the transaction status locally but wish to only save them to database after X number of confirmations.
I'm not sure if there's a native way to listen for events in web3.js (1.0.0-beta) while specifying the number of confirmed blocks I'd like to wait.
The only approach I can think of is save the event in local database when it's heard, recording its block number and mark it as notConfirmed. Then have an auxiliary process to keep polling for the latest block number and mark all notConfirmed entries when lastestBlockNumber - eventBlockNumber > requiredConfirmation. The problem with this design is it involves constantly sweeping the database, which will become heavier as the event table grows.
The question is: How do you think of my design? Is there a better approach to listen for confirmed events?