Skip to content

fix: ShareRecorder shutdown-flush gap and permanent orphan misclassification - #12

Merged
colneech-dev merged 1 commit into
mainfrom
fix/sharerecorder-flush-and-orphan-debounce
Nov 24, 2026
Merged

colneech-dev merged 1 commit into
mainfrom
fix/sharerecorder-flush-and-orphan-debounce

Conversation

@colneech-dev

Copy link
Copy Markdown
Owner

Summary

  • ShareRecorder: the Rx Buffer(TimeSpan, count) pipeline had no way to flush its current incomplete window on shutdown, so a graceful stop could silently drop up to 5s/250 shares that were never routed through the recovery-file fallback. Replaced it with an explicit accumulator that flushes on a timer, on hitting the 250-share threshold, and once more in ExecuteAsync's finally block on the way out.
  • BitcoinPayoutHandler: a block was permanently classified Orphaned on a single gettransaction error -5, with no way back (pending-block polling never revisits a non-Pending block). A transient daemon hiccup returning -5 once therefore permanently forfeited that block's reward forever. Now requires 3 consecutive -5 results across polls before committing to Orphaned.

Test plan

  • dotnet build (Release, SkipNativeLibBuild=true) — 0 errors, only pre-existing warnings
  • Not yet exercised against a live pool restart or a real daemon resync scenario

🤖 Generated with Claude Code

…ication

ShareRecorder: Rx's Buffer(TimeSpan, count) has no way to flush its current
incomplete window on unsubscribe, so a graceful shutdown mid-window (up to
5s / 250 shares) silently dropped whatever had accumulated since the last
tick - without even routing them through the recovery-file fallback.
Replaced the Rx buffer pipeline with an explicit accumulator (list + lock)
flushed by a timer loop and, in ExecuteAsync's finally block, once more on
the way out, so a graceful stop (SIGTERM, host shutdown) persists or
recovery-files everything collected since the last tick instead of
dropping it. Concurrent flush callers (count-triggered vs timer-triggered)
are serialized with a semaphore, preserving the original Rx .Concat()
guarantee that persistence calls never overlap.

BitcoinPayoutHandler.ClassifyBlocksAsync: a block was permanently
classified Orphaned on a single gettransaction error -5, with no way
back - GetPendingBlocksForPoolAsync only ever looks at Pending blocks
again. A transient daemon hiccup (resyncing, briefly behind the tip,
-txindex rebuilding) returning -5 once therefore permanently forfeited
that block's reward. Added a per-block strike counter (keyed by
block.Id, static because handlers are resolved fresh per payout cycle)
requiring 3 consecutive -5 occurrences across polls before committing
to Orphaned; any other outcome in between resets the count.

Build-verified: dotnet build (Release, SkipNativeLibBuild=true), 0 errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@colneech-dev
colneech-dev merged commit c482f73 into main Nov 24, 2026
1 check passed
@colneech-dev
colneech-dev deleted the fix/sharerecorder-flush-and-orphan-debounce branch November 24, 2026 20:48
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