netfox icon indicating copy to clipboard operation
netfox copied to clipboard

Refactor RollbackSynchronizer

Open elementbound opened this issue 1 year ago • 2 comments

:sparkles: Description

Over time, RollbackSynchronizer has received many features, and it has slowly become a God class.

Goals

  • [x] #385
    • History should be represented by a separate class
    • Limit defaults to history limit
    • Implements get, set, and trim
  • [x] Extract data transmission approaches
    • Extract redundant transmission
    • Extract full state transmission
    • Extract diff state transmission
  • [ ] StateSynchronizer to support diff states
  • [x] #159
  • [ ] Attach version tags to property indexes

Notes

  • RollbackSynchronizer uses three methods of transmission. Each is to be extracted in a reusable way.
    • ~~This can be internal nodes that are added with the node itself, and handle their own RPCs~~

elementbound avatar Dec 24 '24 19:12 elementbound

Instead of (or in addition to) extracting transmission logic, what about separation of the three core features into their own nodes:

  • InputRecorder for input gathering
  • StateRecorder for state gathering
  • RollbackParticipant handles _rollback_tick logic

If desired, RollbackSynchronizer can remain as a single node encapsulation of the above for convenience/compatibility.

Independent state gathering is useful for objects that don't need input, and independent rollback participation solves #374 and possibly #312 where state and input aren't needed, so there's a clear use case beyond refactoring.

DustieDog avatar Jan 20 '25 13:01 DustieDog

There's also the possibility of further simplifying input and state gathering into a single node as they're substantially similar, but felt that was beyond the scope of this issue.

DustieDog avatar Jan 20 '25 13:01 DustieDog