From 640e2a06195fce640052ca9beba6a909f351f965 Mon Sep 17 00:00:00 2001 From: Revertron Date: Fri, 23 Apr 2021 21:22:22 +0200 Subject: [PATCH] Fixed ping processing. Changed the limit of active connections from 10 to 15. --- Cargo.toml | 2 +- src/commons/constants.rs | 2 +- src/p2p/network.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2579a42..0a541c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "alfis" -version = "0.4.25" +version = "0.4.26" authors = ["Revertron "] edition = "2018" build = "build.rs" diff --git a/src/commons/constants.rs b/src/commons/constants.rs index 4e03a59..ab7ca42 100644 --- a/src/commons/constants.rs +++ b/src/commons/constants.rs @@ -44,4 +44,4 @@ pub const LOG_REFRESH_DELAY_SEC: u64 = 60; pub const POLL_TIMEOUT: Option = Some(Duration::from_millis(250)); pub const MAX_PACKET_SIZE: usize = 1 * 1024 * 1024; // 1 Mb pub const MAX_READ_BLOCK_TIME: u128 = 500; -pub const MAX_NODES: usize = 10; +pub const MAX_NODES: usize = 15; diff --git a/src/p2p/network.rs b/src/p2p/network.rs index dcf1ee9..bef17c0 100644 --- a/src/p2p/network.rs +++ b/src/p2p/network.rs @@ -441,8 +441,9 @@ fn handle_message(context: Arc>, message: Message, peers: &mut Pe if peer.is_higher(my_height) { let mut context = context.lock().unwrap(); context.chain.update_max_height(height); - } - if my_height == height && hash.ne(&my_hash) { + info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip()); + State::message(Message::GetBlock { index: height }) + } else if my_height == height && hash.ne(&my_hash) { info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip()); info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash); State::message(Message::GetBlock { index: my_height }) @@ -458,8 +459,9 @@ fn handle_message(context: Arc>, message: Message, peers: &mut Pe if peer.is_higher(my_height) { let mut context = context.lock().unwrap(); context.chain.update_max_height(height); - } - if my_height == height && hash.ne(&my_hash) { + info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip()); + State::message(Message::GetBlock { index: height }) + } else if my_height == height && hash.ne(&my_hash) { info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip()); info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash); State::message(Message::GetBlock { index: my_height })