Repository navigation
fix: ShareRecorder shutdown-flush gap and permanent orphan misclassification - #12
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 inExecuteAsync'sfinallyblock on the way out.Orphanedon a singlegettransactionerror-5, with no way back (pending-block polling never revisits a non-Pending block). A transient daemon hiccup returning-5once therefore permanently forfeited that block's reward forever. Now requires 3 consecutive-5results across polls before committing toOrphaned.Test plan
dotnet build(Release, SkipNativeLibBuild=true) — 0 errors, only pre-existing warnings🤖 Generated with Claude Code