MCPcopy Create free account
hub / github.com/base/base / sample

Method sample

acceptance/src/check.rs:76–88  ·  view source on GitHub ↗

Records a valid block or an explicit sampling gap without storing URLs.

(&mut self, endpoint: &str, block: Option<&ObservedBlock>)

Source from the content-addressed store, hash-verified

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) {

Callers 4

successMethod · 0.80
failureMethod · 0.80
open_windowMethod · 0.80
confirm_pre_forkMethod · 0.80

Calls 3

lenMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected