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

oasisprotocol / oasis-core / #5141

24 Jul 2024 09:54AM UTC coverage: 45.22% (-0.3%) from 45.494%
#5141

Pull #5784

peternose
keymanager/src/churp: Serve key shares to lagging clients
Pull Request #5784: keymanager/src/churp: Serve key shares to lagging clients

2 of 367 new or added lines in 4 files covered. (0.54%)

19 existing lines in 1 file now uncovered.

3983 of 8808 relevant lines covered (45.22%)

1.01 hits per line

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

0.0
/keymanager/src/churp/state.rs
1
//! Verified consensus state for CHURP extension.
2
use std::sync::Arc;
3

4
use anyhow::Result;
5

6
use oasis_core_runtime::{
7
    common::namespace::Namespace,
8
    consensus::{
9
        keymanager::churp::Status, state::keymanager::churp::ImmutableState as ChurpState,
10
        verifier::Verifier as ConsensusVerifier,
11
    },
12
    future::block_on,
13
};
14

15
use super::Error;
16

17
/// Verified consensus state for CHURP extension.
18
pub struct State {
19
    consensus_verifier: Arc<dyn ConsensusVerifier>,
20
}
21

22
impl State {
23
    /// Creates a new CHURP state.
24
    pub fn new(consensus_verifier: Arc<dyn ConsensusVerifier>) -> Self {
×
25
        Self { consensus_verifier }
26
    }
27

28
    /// Returns the latest CHURP status.
29
    pub fn status(&self, runtime_id: Namespace, churp_id: u8) -> Result<Status> {
×
30
        let consensus_state = block_on(self.consensus_verifier.latest_state())?;
×
31
        let churp_state = ChurpState::new(&consensus_state);
×
32
        let status = churp_state
×
33
            .status(runtime_id, churp_id)?
×
34
            .ok_or(Error::StatusNotPublished)?;
×
35

36
        Ok(status)
×
37
    }
38

39
    /// Returns CHURP status before the given number of blocks.
NEW
40
    pub fn status_before(
×
41
        &self,
42
        runtime_id: Namespace,
43
        churp_id: u8,
44
        blocks: u64,
45
    ) -> Result<Status> {
NEW
46
        let height = block_on(self.consensus_verifier.latest_height())?;
×
NEW
47
        let height = height.saturating_sub(blocks).max(1);
×
NEW
48
        let consensus_state = block_on(self.consensus_verifier.state_at(height))?;
×
NEW
49
        let churp_state = ChurpState::new(&consensus_state);
×
NEW
50
        let status = churp_state
×
NEW
51
            .status(runtime_id, churp_id)?
×
NEW
52
            .ok_or(Error::StatusNotPublished)?;
×
53

NEW
54
        Ok(status)
×
55
    }
56
}
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