Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't restart p2pool on timeout #1350

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions src-tauri/src/p2pool_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use std::collections::HashMap;
use std::path::PathBuf;
use tari_common::configuration::Network;
use tari_shutdown::Shutdown;
use std::time::Duration;
use tokio::time::timeout;

use crate::p2pool;
use crate::p2pool::models::{Connections, Stats};
Expand Down Expand Up @@ -163,36 +165,26 @@ impl P2poolStatusMonitor {
#[async_trait]
impl StatusMonitor for P2poolStatusMonitor {
async fn check_health(&self) -> HealthStatus {
match self.stats_client.stats().await {
Ok(_stats) => {
// if stats
// .connection_info
// .network_info
// .connection_counters
// .established_outgoing
// + stats
// .connection_info
// .network_info
// .connection_counters
// .established_incoming
// < 1
// {
// warn!(target: LOG_TARGET, "P2pool has no connections, health check warning");
// return HealthStatus::Warning;
// }

// if EpochTime::now().as_u64() - stats.last_gossip_message.as_u64() > 60 {
// warn!(target: LOG_TARGET, "P2pool last gossip message was more than 60 seconds ago, health check warning");
// return HealthStatus::Warning;
// }

HealthStatus::Healthy
match timeout(Duration::from_secs(1), self.stats_client.stats()).await {
Ok(res) => {
match res {
Ok(_stats) => {
HealthStatus::Healthy
}
Err(e) => {
warn!(target: LOG_TARGET, "P2pool health check failed: {}", e);
HealthStatus::Unhealthy
}
}
}
Err(e) => {
warn!(target: LOG_TARGET, "P2pool health check failed: {}", e);
HealthStatus::Unhealthy
Err(_elapsed) => {
// Note: P2pool v0.17.4 is really slow to respond sometimes, but still is healthy, so
// we ignore timeouts
warn!(target: LOG_TARGET, "P2pool health check timed out, but will assume healthy");
HealthStatus::Healthy
}
}

}
}

Expand Down
Loading