liana/gui/src/utils/mod.rs
jp1ac4 36cf85d849
gui: add option to use internal bitcoind
During installation, the user may choose for Liana to configure and start bitcoind for them.

This internal bitcoind uses as its data directory the `bitcoind_datadir` folder within the
Liana data directory.

If the internal bitcoind option has been selected for a network, it will be automatically
started when the user returns to Liana and stopped when Liana is closed.
2023-08-23 16:43:55 +01:00

22 lines
552 B
Rust

use std::path::Path;
#[cfg(test)]
pub mod sandbox;
#[cfg(test)]
pub mod mock;
/// Polls for a file's existence at given interval up to a maximum number of polls.
/// Returns `true` once file exists and otherwise `false`.
pub fn poll_for_file(path: &Path, interval_millis: u64, max_polls: u16) -> bool {
for i in 0..max_polls {
if path.exists() {
return true;
}
if i < max_polls.saturating_sub(1) {
std::thread::sleep(std::time::Duration::from_millis(interval_millis));
}
}
false
}