code wiki / _hdl_build / _cn_fetch.nx
_cn_fetch.nx source
↩ module page · 9 lines · 403 B
1// AUTHORED BY THE NISHI BUILDER (pattern: GOVERNOR) -- min-gap pacing + clamped exponential backoff
2import "nx_syscalls.nx"
3func _cn_fetch_allow(last_ms: i64, now_ms: i64) -> i64 { if now_ms - last_ms >= 1500 { return 1 } return 0 }
4func _cn_fetch_backoff(fails: i64) -> i64 {
5 var d: i64 = 500
6 var i: i64 = 0
7 while i < fails { d = d * 2; if d > 8000 { d = 8000 } i = i + 1 }
8 return d
9}