new to ethers/web3 : How to handle reorgs?
I'm listening to events of a random contract through a websocket, and i'm getting transactions as soon as they happen on the chain then inserting them into a db.
In case of a blockchain re-org where old blocks are replaced with the blocks in the new consensus, whats the best way to handle new transactions and delete the old ones?
the best way i can think of is listening to new blocks and on each new block call getPastEvents between the latest block – 12 blocks and latest blocks – 24 block to reconcile the events. But i dont think thats very clean(?) and is there a standard of blocks to wait for? i just chose 12 randomly
submitted by /u/External-Peach8286
[link] [comments]