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

EspressoSystems / marketplace-builder-core / 11961978007

21 Nov 2024 09:29PM UTC coverage: 68.045% (-21.7%) from 89.696%
11961978007

Pull #239

github

web-flow
Merge ef39de3b0 into 178a48f80
Pull Request #239: [WIP] [Refactor] 3: Switch legacy to coordinator

146 of 504 new or added lines in 13 files covered. (28.97%)

52 existing lines in 4 files now uncovered.

1761 of 2588 relevant lines covered (68.04%)

2189.37 hits per line

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

0.0
/crates/legacy/src/lib.rs
1
// Copyright (c) 2024 Espresso Systems (espressosys.com)
2
// This file is part of the HotShot Builder Protocol.
3
//
4

5
// Builder Phase 1
6
// It mainly provides three API services to hotshot proposers:
7
// 1. Serves a proposer(leader)'s request to provide blocks information
8
// 2. Serves a proposer(leader)'s request to provide the full blocks information
9
// 3. Serves a proposer(leader)'s request to provide the block header information
10

11
// It also provides one API services external users:
12
// 1. Serves a user's request to submit a private transaction
13

14
// Core interaction with the HotShot network
15
pub mod block_size_limits;
16
pub mod mutable_state;
17
pub mod service;
18

19
// tracking the testing
20
#[cfg(test)]
21
pub mod testing;
22

23
use std::{future::Future, sync::Arc};
24

25
use futures::{
26
    future::{RemoteHandle, Shared},
27
    FutureExt,
28
};
29
use tokio::{spawn, sync::Notify};
30

31
#[derive(derive_more::Debug, Clone)]
32
pub struct WaitAndKeep<T>
33
where
34
    T: Clone + Sync + Send + 'static,
35
{
36
    handle: Shared<RemoteHandle<T>>,
37
    notifier: Arc<Notify>,
38
}
39

40
impl<T> WaitAndKeep<T>
41
where
42
    T: Clone + Sync + Send + 'static,
43
{
44
    /// Creates a new [`WaitAndKeep`] wrapping the provided future.
45
    /// Future will be essentially paused until [`WaitAndKeep::start`] is called
NEW
46
    pub fn new<F: Future<Output = T> + Send + 'static>(fut: F) -> Self {
×
NEW
47
        let notifier = Arc::new(Notify::new());
×
NEW
48
        let (fut, handle) = {
×
NEW
49
            let notifier = Arc::clone(&notifier);
×
NEW
50
            async move {
×
NEW
51
                let _ = notifier.notified().await;
×
NEW
52
                fut.await
×
53
            }
×
NEW
54
            .remote_handle()
×
NEW
55
        };
×
NEW
56
        spawn(fut);
×
NEW
57
        Self {
×
NEW
58
            notifier,
×
NEW
59
            handle: handle.shared(),
×
60
        }
×
61
    }
×
62

63
    /// Signals the underlying future to start running
NEW
64
    pub fn start(&self) {
×
NEW
65
        self.notifier.notify_one();
×
UNCOV
66
    }
×
67

68
    /// Will consume self and return result of underlying future
NEW
69
    pub async fn resolve(self) -> T {
×
NEW
70
        self.handle.await
×
UNCOV
71
    }
×
72
}
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