currencyrate: don't sleep for as long in background task.
What changed, and why it matters
This commit adjusts how often a background currency-rate updater checks exchange-rate sources. Previously, the updater slept a fixed amount between runs; now it sleeps less when there are more sources, so each source gets queried about once per hour on average. This is a performance and freshness tuning change, not a security fix.
No security action required; review as normal code-quality/performance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In plugins/currencyrate-plugin/src/oracle.rs, the background loop’s sleep interval is changed from SERVE_TTL.saturating_sub(2 * SOURCE_TIMEOUT_SECS).max(1s) to (SERVE_TTL / (num_sources + 1)).saturating_sub(2 * SOURCE_TIMEOUT_SECS).max(1s). The intent is to ensure each price source is hit roughly once per SERVE_TTL period in steady state, since at least one stale entry is processed per iteration. No input validation, cryptographic, network-trust, or resource-exhaustion security boundary is altered.
Changed components
plugins/currencyrate-plugin/src/oracle.rsInspect captured patch +3 / −1
diff --git a/plugins/currencyrate-plugin/src/oracle.rs b/plugins/currencyrate-plugin/src/oracle.rs
index 5712cfd7..7c24a847 100644
--- a/plugins/currencyrate-plugin/src/oracle.rs
+++ b/plugins/currencyrate-plugin/src/oracle.rs
@@ -512,9 +512,11 @@ impl BtcPriceOracle {
break;
}
+ let num_sources = inner.sources.len() as u32;
drop(inner);
- let interval = SERVE_TTL
+ // We want to hit each server on average SERVE_TTL seconds, in steady state.
+ let interval = (SERVE_TTL / (num_sources + 1))
.saturating_sub(2 * SOURCE_TIMEOUT_SECS)
.max(Duration::from_secs(1));
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.