Skip to content

feat: PoW overhaul — background mining, persistent settings, reaction PoW#152

Merged
barrydeen merged 1 commit intomainfrom
feat/pow-overhaul
Mar 3, 2026
Merged

feat: PoW overhaul — background mining, persistent settings, reaction PoW#152
barrydeen merged 1 commit intomainfrom
feat/pow-overhaul

Conversation

@barrydeen
Copy link
Owner

Summary

  • Background mining: Note PoW now runs in a PowManager owned by FeedViewModel, so the compose screen navigates back immediately and mining progress shows in the bottom status pill with a cancel button
  • Persistent settings: PoW enable/difficulty for notes and reactions stored in SharedPreferences via PowPreferences, with a new settings screen accessible from the drawer
  • Reaction PoW: SocialActionManager.toggleReaction() now mines inline PoW (default 12 bits, sub-second) before signing reactions when enabled

New files

  • repo/PowPreferences.kt — SharedPreferences-backed PoW settings (note/reaction enable + difficulty, clamped 8-32)
  • viewmodel/PowManager.kt — Background mining manager with PowStatus sealed class (Idle/Mining/Done/Failed)
  • ui/screen/PowSettingsScreen.kt — Settings screen with enable switches and difficulty steppers

Modified files

  • FeedViewModel — owns PowPreferences and PowManager, passes powPrefs to SocialActionManager
  • ComposeViewModel — removes old blocking PoW mining, hands off to PowManager.submitNote() for background mining
  • SocialActionManager — adds inline reaction PoW via Nip13.mine() when enabled
  • ComposeScreen — removes difficulty adjuster and mining progress UI, shows "mined in background" banner
  • FeedScreen/BroadcastStatusBar — extended to show PowStatus (mining progress + cancel, done, failed states)
  • Navigation.kt — adds POW_SETTINGS route, passes powManager/powPrefs to compose screen, wires status pill
  • WispDrawerContent — adds "Proof of Work" entry under Settings

Test plan

  • Compose a note with PoW on — verify immediate navigation back, mining pill appears, note publishes after mining
  • Start a high-difficulty note, tap cancel on pill — verify mining stops, no note published
  • React to a post with reaction PoW enabled — verify the reaction event has a nonce tag
  • Toggle PoW off in settings, close/reopen app — verify it's still off
  • Start mining a note, try to compose another — verify Post button is disabled
  • Compose with PoW disabled — verify immediate publish (no mining phase)

Move note PoW mining to a background PowManager so compose screen
navigates back immediately. Persist PoW settings (note/reaction
enable + difficulty) in SharedPreferences. Add inline reaction PoW
via Nip13.mine() in SocialActionManager. Show mining progress in
the existing broadcast status pill with cancel support. Add PoW
settings screen accessible from the drawer.
@barrydeen barrydeen merged commit 63257ce into main Mar 3, 2026
@barrydeen barrydeen deleted the feat/pow-overhaul branch March 4, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant