Skip to content

Commit cc32091

Browse files
committed
fix: use timestamp throttle for GitHub fetch instead of block height (block was stuck at 0)
1 parent be08228 commit cc32091

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

bounty_challenge.wasm

-170 Bytes
Binary file not shown.

src/scoring.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,20 @@ pub fn rebuild_leaderboard() -> Vec<LeaderboardEntry> {
207207

208208
/// Called every ~12s on the persistent WASM instance.
209209
/// Recount balances and rebuild leaderboard on every tick.
210-
/// Every 100 blocks (~20 min), also fetch fresh issues from GitHub.
210+
/// Every ~20 min, fetch fresh issues from GitHub (throttled by timestamp).
211211
pub fn background_tick() {
212-
let block = platform_challenge_sdk_wasm::host_functions::host_consensus_get_block_height();
212+
const GITHUB_FETCH_INTERVAL_MS: i64 = 20 * 60 * 1000;
213213

214-
if block > 0 && block % 100 == 0 {
214+
let now = platform_challenge_sdk_wasm::host_functions::host_get_timestamp();
215+
let last = storage::get_last_refreshed();
216+
217+
if last == 0 || (now - last) >= GITHUB_FETCH_INTERVAL_MS {
215218
crate::github_sync::fetch_and_process_issues();
216219
}
217220

218221
storage::recount_all_balances();
219222
rebuild_leaderboard();
220223

221-
let now = platform_challenge_sdk_wasm::host_functions::host_get_timestamp();
222224
storage::store_last_refreshed(now);
223225
}
224226

0 commit comments

Comments
 (0)