Skip to content

Refactor status updates by PoST Initializer #78

@fasmat

Description

@fasmat

Based on the discussion in these two comments:

At the moment the Initializer type is overly complex in its usage. It is designed to be re-used, when it doesn't need to be and over-uses channels and go routines. The type can be simplified in the following manner:

  • Simplify Initializer by making it non-reusable; besides tests the type isn't used in this manner anyway
  • Remove Reset(): it is only used in tests and the directory used by Initializer is known to the caller. In tests the caller can delete the directory itself. In Production this shouldn't be done anyway; switching identities should instead use a different datadir for PoST.
  • Remove SessionNumLabelsWrittenChan(); there is no need for this method when SessionNumLabelsWritten() returns the same information in a synchronous way. Callers interested in updates should rely on the values returned by the second method and the status from Started(), Completed(), isInitializing() or even a new single method that combines the purpose of all 3.
  • Initialize() should take a context as parameter and instead of Stop() callers should just cancel the context they passed in.

Refactorings of types using Initializer in go-spacemesh:

  • PostSetupManager:
    • StatusChan() should just call SessionNumLabelsWritten() and return the status directly instead of via a channel
  • SmesherService:
    • PostStetupStatusStream() should instead of relying on receiving values in regular intervals via the channel, call the (new) synchronous method in PostSetupManager in regular intervals.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions