Open gregfromstl opened 7 months ago
what if we:
INSERT
queries to be upsert (INSERT ... ON CONFLICT ...
) instead start_block
as the minimum value of latest block of all event typesI think that would work, we would just have to make the transaction_hash
column unique in chain_events
to prevent duplicates there
i can take this
Right now, we're fetching the last indexed block by finding the max block number in
chain_events
. Because we insert log types sequentially, there's a chance the program crashes after inserting some log types for a stretch of blocks but not all, leaving the other log types absent when the sync restarts and fetches the latest block number.The easiest way to solve this is probably by getting the max block number in
chain_events
for each event type. However, this will make the log collection messier (we'd be fetching logs for different ranges for each event type, since we don't want any duplicate events), so I'm not 100% convinced this is the best approach.