| 42 | /// Virtual time, so the cap costs only scheduler steps, not wall-clock. |
| 43 | const STATE_ROOT_POLL_INTERVAL: Duration = Duration::from_millis(500); |
| 44 | const STATE_ROOT_MAX_POLLS: usize = 600; // ~5 min of virtual time |
| 45 | |
| 46 | pub const GENESIS_HASH: &str = "0x683713729fcb72be6f3d8b88c8cda3e10569d73b9640d3bf6f5184d94bd97616"; |
| 47 | |
| 48 | pub async fn link_validators<E: Clock>( |
| 49 | oracle: &mut Oracle<PublicKey, E>, |
| 50 | validators: &[PublicKey], |
| 51 | link: Link, |
| 52 | restrict_to: Option<fn(usize, usize, usize) -> bool>, |
| 53 | ) { |
| 54 | for (i1, v1) in validators.iter().enumerate() { |
| 55 | for (i2, v2) in validators.iter().enumerate() { |
| 56 | // Ignore self |
| 57 | if v2 == v1 { |
| 58 | continue; |
| 59 | } |
| 60 | |
| 61 | // Restrict to certain connections |
| 62 | if let Some(f) = restrict_to { |
| 63 | if !f(validators.len(), i1, i2) { |
| 64 | continue; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Add link |
| 69 | oracle |
| 70 | .add_link(v1.clone(), v2.clone(), link.clone()) |
| 71 | .await |
| 72 | .unwrap(); |
| 73 | } |
| 74 | } |