Records a valid block or an explicit sampling gap without storing URLs.
(&mut self, endpoint: &str, block: Option<&ObservedBlock>)
| 74 | |
| 75 | /// Records a valid block or an explicit sampling gap without storing URLs. |
| 76 | pub fn sample(&mut self, endpoint: &str, block: Option<&ObservedBlock>) { |
| 77 | if self.samples.len() >= SAMPLE_LIMIT { |
| 78 | self.samples_truncated = true; |
| 79 | return; |
| 80 | } |
| 81 | self.samples.push(HeadSample { |
| 82 | endpoint: endpoint.into(), |
| 83 | elapsed_ms: self.origin.elapsed().as_millis() as u64, |
| 84 | number: block.map(|value| value.number), |
| 85 | timestamp: block.map(|value| value.timestamp), |
| 86 | hash: block.map(|value| value.hash.clone()), |
| 87 | }); |
| 88 | } |
| 89 | |
| 90 | /// Records a successful block observation. |
| 91 | pub fn success(&mut self, endpoint: &str, block: &ObservedBlock) { |
no test coverage detected