File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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) .
211211pub 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
You can’t perform that action at this time.
0 commit comments