Skip to content

Extract history logic to HistoryBuffer #385

@elementbound

Description

@elementbound

Background

Currently, both state and input are stored in dictionaries that associate ticks with a second dictionary of property entry strings to values.

This history dictionary exists and is managed entirely in RollbackSynchronizer, by either directly manipulating the dictionary, or using _get_history().

To reduce the responsibilities of RollbackSynchronizer as described in #358, the point of this ticket is to extract the history management aspect of RollbackSynchronizer.

Done criteria

  1. HistoryBuffer is implemented
    1. Tracks arbitrary data associated to ticks
    2. set(tick, data) to associate data with a given tick
    3. has(tick) to check if there is known data about the given tick
    4. find_closest_tick(tick) to find the closest known tick ( the way _get_history() does )
    5. get_closest(tick, default = null) to get the data associated with the closest tick
    6. trim(tick) to delete data before the specified tick. Should default to rollback history start.
  2. PropertyHistoryBuffer is implemented
    1. Extends HistoryBuffer, manages property entry dictionaries
    2. merge(tick, data) to merge incoming and known data
  3. RollbackSynchronizer manages state and input using PropertyHistoryBuffers
  4. Unit tests are added using vest

Notes

  1. Getters and setters should not declare types in HistoryBuffer, so that PropertyHistoryBuffer can declare them without getting errors about differing signatures
  2. Consider using ring buffers instead of dictionaries for storing data. Ideal would be to benchmark.
  3. Extracting states ( dictionary of property entry strings to values ) into its own class could also make sense, but possibly in a different issue. Open for discussion though.
  4. Include RollbackFreshnessStore in the refactor, as it also stores tick-related data in the form of booleans.

Metadata

Metadata

Assignees

Labels

refactorSame functionality with improved code quality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions