Fixed the consensus about expired domains.

This commit is contained in:
Revertron
2022-09-05 19:12:46 +02:00
parent beb09ed01c
commit a612f73649
9 changed files with 121 additions and 101 deletions
+9 -2
View File
@@ -460,7 +460,7 @@ impl Network {
let my_id = self.peers.get_my_id().to_owned();
let answer = match message {
Message::Hand { app_version, origin, version, public, rand_id } => {
if app_version.starts_with("0.6") {
if !version_compatible(&app_version) {
info!("Banning peer with version {}", &app_version);
return State::Banned;
}
@@ -495,7 +495,7 @@ impl Network {
if self.peers.is_tween_connect(&rand_id) {
return State::Twin;
}
if app_version.starts_with("0.6") {
if !version_compatible(&app_version) {
info!("Banning peer with version {}", &app_version);
return State::Banned;
}
@@ -916,4 +916,11 @@ fn would_block(err: &io::Error) -> bool {
fn interrupted(err: &io::Error) -> bool {
err.kind() == io::ErrorKind::Interrupted
}
fn version_compatible(version: &str) -> bool {
let my_version = env!("CARGO_PKG_VERSION");
let parts = my_version.split('.').collect::<Vec<&str>>();
let major = format!("{}.{}", parts[0], parts[1]);
version.starts_with(&major)
}