electrs 0.11.1

An efficient re-implementation of Electrum Server in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use anyhow::Result;

pub(crate) fn spawn<F>(name: &'static str, f: F) -> std::thread::JoinHandle<()>
where
    F: 'static + Send + FnOnce() -> Result<()>,
{
    std::thread::Builder::new()
        .name(name.to_owned())
        .spawn(move || {
            if let Err(e) = f() {
                warn!("{} thread failed: {}", name, e);
                e.chain().skip(1).for_each(|e| warn!("because: {}", e));
            }
        })
        .expect("failed to spawn a thread")
}