Open
Conversation
…pter with new types
…e analysis, including MiningReward, PoolWorkerStats, PoolStats, and PayoutSchedule
…, authentication, and response errors
…hance documentation for pool statistics and worker stats
…g performance analysis
…tions with validation and serialization methods
…an configurations
…ce tracker adapters
… performance trackers factories
…ionServiceInterface
…nd remove HashRate
…r enhanced mining performance tracking
…th mining_performance
…ce tracker_current_hashrate references
…ormance tracking with caching and backoff
…te-limiting for API calls
…iting for API calls
…nds and API router
…esponse structure and payout policy
…payments and remove threshold configuration
This was referenced Apr 20, 2026
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.
This PR delivers the new Mining Performance Analysis domain for Edge Mining and fixes the issue #33
Why this change
Edge Mining's rule engine already knows about energy state and miner state, but it has no visibility into how the mining pool is actually doing. As a result, useful rules like "don't switch miners off right before a payout" or "pause mining if worker shares have dried up for an hour" are impossible to write today.
This PR adds live pool-side data to the decisional context, through a new domain and two concrete pool integrations (Ocean and Braiins), with a rate-limit aware HTTP client under the hood.
What's new at a glance
1. Mining Performance domain
A new
MiningPerformanceTrackerPortthat any mining pool can implement. Value objects capture the data that actually matters to decisions:PoolStats— current hashrate, 24h/7d averages, unpaid balance, estimated next payout, worker list.PoolWorkerStats— per-worker hashrate, last share timestamp, valid/stale/rejected shares when the pool exposes them.PayoutSchedule— how the pool pays out (per-block / hourly / daily / threshold), with optional threshold and next-payout hint.MiningReward— individual reward entries for the recent history.MiningPerformanceSnapshot— a consolidated snapshot grouping the three live fields above under one timestamp, so the rule engine can consume them as a coherent unit.2. Two pool adapters
Pool-Auth-Tokenheader), aligned to the current post-FPPS API schema (the pool rewrote its public API in November 2023, removing threshold-based payouts in favour of daily FPPS).Both adapters are wired through a matching factory, a config class, and full registration in the adapter service — so adding a third pool in the future is just "plug another adapter in".
3. Integration with the decisional context
DecisionalContextnow carries amining_performancefield. Rules can reference things likemining_performance.current_hashrate.value,mining_performance.pool_stats.estimated_next_payout, ormining_performance.payout_schedule.frequency.data/examples/rules/start/anddata/examples/rules/stop/, covering pre-payout pushes, hashrate-drop detection against the 24h average, unprofitable weekly trends, and stale pool data.4. Rate-limit aware pool clients
Public pool APIs throttle. The two new adapters share a small base class that:
Retry-Afterwhen the pool sends it.HTTP 429+Retry-After, CLI prints a human-friendly message.5. REST API and interactive CLI
/api/v1/mining-performance-trackerscovering tracker CRUD, adapter-type and config-schema discovery, connectivity test, and live data (stats, workers, rewards history, payout schedule).How to try it
python -m edge_mining→ "Manage Mining Performance Trackers" → "Add" → pick Ocean or Braiins and fill in the config.POST /api/v1/mining-performance-trackers/with the adapter-specific config.GET /.../{id}/testor CLI "Test reachability".data/examples/rules/start/mining_performance_start_rules.yamland.../stop/mining_performance_stop_rules.yamlfor ready-to-adapt examples.Notes
DecisionalContext: the singletracker_current_hashrate: Optional[HashRate]field was replaced with a richermining_performance: Optional[MiningPerformanceSnapshot]. Existing rules referencingtracker_current_hashrateneed to migrate tomining_performance.current_hashrate.value. The rule engine's built-in operator examples have been updated accordingly.unconfirmed_reward,hash_rate_1h, threshold-based payouts). The final code follows the current documented schema —current_balancefor the unpaid balance,hash_rate_60mfor the one-hour hashrate, andPayoutFrequency.DAILYwith no threshold/next-payout (FPPS pays daily automatically).Test coverage
Retry-After), the cache + backoff base class (cache hit/miss within and past TTL, backoff progression, stale-while-error fallback), the configuration service, the REST router, and the CLI interactions.ruffandmypyare clean on all files touched by this PR.