0g-storage-node/node/miner/src/monitor.rs
bruno-valante 7d73ccd1e1
Update with the most recent storage contract (#142)
* Update with the most recent storage contract

* fix nits
2024-07-24 13:01:30 +08:00

28 lines
577 B
Rust

use std::time::Duration;
use task_executor::TaskExecutor;
use tokio::time::sleep;
use super::metrics;
pub struct Monitor {
period: Duration,
}
impl Monitor {
pub fn spawn(executor: TaskExecutor, period: Duration) {
let monitor = Monitor { period };
executor.spawn(
async move { Box::pin(monitor.start()).await },
"pora_master",
);
}
async fn start(&self) {
loop {
info!("Mine iterations statistics: {}", metrics::report());
let _ = sleep(self.period).await;
}
}
}