aleo-setup icon indicating copy to clipboard operation
aleo-setup copied to clipboard

Refactor round storage methods to return actions

Open kellpossible opened this issue 4 years ago • 1 comments

The new Round::reset() introduced in #288 returns storage actions rather than directly mutating the storage. This easier to test and reason about. There are other methods in Round which could be refactored to work the same way, and have more unit tests written for them:

  • new()
  • remove_contributor_unsafe (introduced during #288 to combine removed_locks_unsafe and remove_chunk_contributions_unsafe)
  • remove_locks_unsafe
  • remove_chunk_contributions_unsafe
  • try_lock_chunk

The following methods depend on an immutable reference to Storage, perhaps they could be decoupled:

  • current_contribution_locator
  • next_contribution_locator
  • next_contribution_file_signature_locator

kellpossible avatar Jul 13 '21 18:07 kellpossible

Something that came up during discussions with @ibaryshnikov was the need for transactional changes to the files on disk (#372 ), the ability to roll back if there is a problem during one of the changes in a transaction. There are probably many ways to achieve this that can be explored, this could be orthogonal to the changes being made for this issue, however one idea I did have is that a group of actions could be treated as a transaction, it would then be fairly simple to create a new Disk::process_actions function which provides the ability to reverse changes (by storing and applying opposite actions) when encountering an error (rather than simply aborting as it does now, leaving the file system in an incorrect state).

kellpossible avatar Sep 02 '21 03:09 kellpossible