Skip to content

Commit

Permalink
Pings collector v1.0.5: supported worker versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiezzel committed Aug 19, 2024
1 parent e010c9e commit 4f98300
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/pings-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pings-collector"
version = "1.0.4"
version = "1.0.5"
edition = "2021"

[dependencies]
Expand All @@ -14,6 +14,7 @@ futures = "0.3"
lazy_static = "1"
log = "0.4"
parking_lot = "0.12"
semver = "1"
serde = { version = "1.0.188", features = ["derive"] }
serde_bytes = "0.11"
serde_json = "1"
Expand Down
10 changes: 10 additions & 0 deletions crates/pings-collector/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ use tokio::signal::unix::{signal, SignalKind};

use collector_utils::{PingRow, Storage};
use contract_client::Client as ContractClient;
use semver::VersionReq;
use subsquid_network_transport::util::{CancellationToken, TaskManager};
use subsquid_network_transport::{PeerId, Ping, PingsCollectorTransportHandle};

lazy_static! {
static ref BINCODE_CONFIG: bincode::config::Configuration = Default::default();
pub static ref SUPPORTED_WORKER_VERSIONS: VersionReq =
std::env::var("SUPPORTED_WORKER_VERSIONS")
.unwrap_or(">=1.1.0-rc3".to_string())
.parse()
.expect("Invalid SUPPORTED_WORKER_VERSIONS");
}

const PINGS_BATCH_SIZE: usize = 10000;
Expand Down Expand Up @@ -132,6 +138,10 @@ impl Collector {
log::warn!("Ping from unregistered worker {peer_id}: {ping:?}");
return Ok(());
}
if ping.version_matches(&SUPPORTED_WORKER_VERSIONS) {
log::debug!("Unsupported worker version {peer_id}: {:?}", ping.version);
return Ok(());
}
log::debug!("Collecting ping from {peer_id}");
log::trace!("Ping collected: {ping:?}");
let ping_row: PingRow = ping.try_into().map_err(|e: &str| anyhow::format_err!(e))?;
Expand Down

0 comments on commit 4f98300

Please sign in to comment.