fix duplicate inserts #154
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

TL;DR
Replaced ticker with sleep interval in committer and added empty data check for block insertions
What changed?
time.NewTickerwithtime.Sleepin the committer's main loopInsertBlockDataHow to test?
InsertBlockDatawith empty block data to ensure it handles the case gracefullyWhy make this change?
Ticker will trigger on the nearest configured time tick. Meaning that if the interval is 1 second and loop finishes at 0.999, then the next loop will start in 1 millisecond.
This can create cases where the next committer loop reads the DB to get the latest block, but it hasn't propagated to all distributed DB machines yet and thus returns an old block and the loop will commit the same data as the last loop.
Using sleep will fix this because it will always wait the configured interval after the previous commit is done