1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Entropy beacon — the external randomness that seeds each block.
//!
//! The live beacon ([`sample_live`]) is [drand](https://drand.love)'s public
//! `quicknet` randomness network — a threshold-BLS beacon run by independent
//! operators (the League of Entropy), publishing a fresh, unbiasable, publicly
//! verifiable random value every 3 seconds. No single party (including us) can
//! predict or influence it. [`sample`] is the deterministic offline fallback: used
//! in tests, and live if drand is unreachable, so the chain keeps running instead of
//! stalling.
use Deserialize;
/// drand's `quicknet` chain — 3s rounds, matches Entropa's own block cadence.
const DRAND_QUICKNET_URL: &str =
"https://api.drand.sh/52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971/public/latest";
/// Fetch the current round from drand's public `quicknet` beacon. Returns `None` on
/// any failure (network, bad status, malformed JSON) — the caller falls back to
/// [`sample`].
pub async
/// Deterministic offline fallback — derives a value from the round number. Used in
/// tests (no network dependency) and if [`sample_live`] can't reach drand. Prefixed
/// differently from [`sample_live`]'s output so it's visible on-chain which mode
/// produced a given block's beacon.