feat(analytics): consider expiring and locked outputs #1335
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.
Description
This PR tracks expiring and locked outputs in the address balance analytics, so that when the milestone is eventually handled those amounts will properly be transferred or added to the appropriate address. Each output with an expiration or timelock will create a record in the maps.
However!! this has potentially serious performance implications, primarily due to the memory usage of these tracking structures, which have no bounds!.
Alternatives
Conceptually, the same process could be instead applied to the database using a tracking table, something like this:
The usage of this table would be much the same as the
HashMap
s in this PR, and we could instead pass in the records for the current milestone for each balance analytic call. Additionally, this would allow chronicle to update the owning address for records inOutputCollection
andLedgerUpdateCollection
per milestone, potentially dramatically improving the functionality and performance of the explorer endpoints.Conclusion
Due to the performance concerns, I don't want to merge this PR as-is, but rather keep it as a proof-of-concept for now.