dsfb_densor_runtime/
index.rs1use crate::receipt::RuntimeReceiptV1;
8use std::collections::BTreeSet;
9
10#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct RuntimeIndex {
13 pub pipeline_id: String,
14 pub stage_ids: Vec<String>,
15 pub authorities: Vec<String>,
16 pub receipt_hash: String,
17}
18
19impl RuntimeIndex {
20 pub fn of(receipt: &RuntimeReceiptV1) -> Self {
22 let stage_ids = receipt.stages.iter().map(|s| s.stage_id.clone()).collect();
23 let mut auth: BTreeSet<String> = BTreeSet::new();
24 for s in &receipt.stages {
25 for a in &s.authority_hashes {
26 auth.insert(a.name.clone());
27 }
28 }
29 RuntimeIndex {
30 pipeline_id: receipt.pipeline_id.clone(),
31 stage_ids,
32 authorities: auth.into_iter().collect(),
33 receipt_hash: receipt.receipt_hash.clone(),
34 }
35 }
36
37 pub fn summary_line(&self) -> String {
39 format!(
40 "{}: {} stage(s) [{}] over authorities [{}] -> {}",
41 self.pipeline_id,
42 self.stage_ids.len(),
43 self.stage_ids.join(", "),
44 self.authorities.join(", "),
45 &self.receipt_hash[..self.receipt_hash.len().min(12)],
46 )
47 }
48}