Skip persisting signed data for data feed with existing timestamp #91
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.
Closes #90
Background
In #34 we changed how signed API accepts data from pusher. In particular, it no longer checks whether the signed data updates the timestamp. This is by design because we may need the older data for delayed endpoints. This also improves throughput, because we don't need to reject full batch when a single signed data fails the check.
Change
Because the pusher does not keep track of what data it sent to particular signed API it can attempt to send the same beacon data multiple times, increasing the storage requirements for signed API.
This change does not persists signed data for a data feed for which we already have a signed data value with the same timestamp. This assumes that the signed data with same timestamp is the same, but even if not - there is no way to pick "the correct one" so we can choose which one to skip.
The benefit of not keeping state in pusher is that it can re-push the data to the signed API in case it is redeployed (and loses all previously pushed data). The alternative to this would be to persist the timestamps of successfully pushed signed datas to avoid pushing them again.