• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / catalyst-libs / 16054905839

03 Jul 2025 03:45PM UTC coverage: 65.701% (+0.02%) from 65.683%
16054905839

Pull #405

github

web-flow
Merge 30c505c79 into 31f00a4a8
Pull Request #405: fix(rust/rbac-registration): Fix `validate_txn_inputs_hash` error message

0 of 1 new or added line in 1 file covered. (0.0%)

6 existing lines in 2 files now uncovered.

10972 of 16700 relevant lines covered (65.7%)

2614.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/rust/cardano-chain-follower/src/mithril_snapshot_data.rs
1
//! Data about the current Mithril Snapshot
2
use std::{default, sync::LazyLock};
3

4
use cardano_blockchain_types::Network;
5
use dashmap::DashMap;
6

7
use crate::snapshot_id::SnapshotId;
8

9
/// Current Mithril Snapshot Data for a network.
10
#[derive(Debug, Clone)]
11
pub(crate) struct SnapshotData {
12
    /// Snapshot ID the data represents
13
    id: SnapshotId,
14
}
15

16
impl SnapshotData {
17
    /// Create a new Snapshot Data.
18
    pub(crate) fn new(id: SnapshotId) -> Self {
×
19
        SnapshotData { id }
×
20
    }
×
21

22
    /// Get the snapshot ID of this Snapshot Data.
23
    pub(crate) fn id(&self) -> &SnapshotId {
×
24
        &self.id
×
25
    }
×
26
}
27

28
impl default::Default for SnapshotData {
29
    /// The default snapshot data represents, there is no latest snapshot.
30
    fn default() -> Self {
×
31
        SnapshotData {
×
32
            id: SnapshotId::default(),
×
33
        }
×
34
    }
×
35
}
36

37
/// Current Mithril Snapshot for a network.
38
static CURRENT_MITHRIL_SNAPSHOT: LazyLock<DashMap<Network, SnapshotData>> =
39
    LazyLock::new(DashMap::new);
40

41
/// Get the current latest snapshot data we have recorded.
42
pub(crate) fn latest_mithril_snapshot_data(chain: Network) -> SnapshotData {
×
43
    // There should ALWAYS be a snapshot for the chain if this is called.
×
44
    match CURRENT_MITHRIL_SNAPSHOT.get(&chain) {
×
45
        Some(snapshot_data) => snapshot_data.value().clone(),
×
46
        None => SnapshotData::default(),
×
47
    }
48
}
×
49

50
/// Get the latest Mithril Snapshot for a network.
51
pub(crate) fn latest_mithril_snapshot_id(chain: Network) -> SnapshotId {
×
52
    // There should ALWAYS be a snapshot for the chain if this is called.
×
53
    latest_mithril_snapshot_data(chain).id
×
54
}
×
55

56
/// Update the latest snapshot data.
57
pub(crate) fn update_latest_mithril_snapshot(chain: Network, snapshot_id: SnapshotId) {
×
58
    let snapshot_data = SnapshotData::new(snapshot_id);
×
59

×
60
    // Save the current snapshot
×
61
    CURRENT_MITHRIL_SNAPSHOT.insert(chain, snapshot_data);
×
62
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc