2
0
mirror of https://github.com/Revertron/Alfis synced 2024-11-11 01:10:36 +00:00

Fixed block requests.

This commit is contained in:
Revertron 2021-05-05 14:53:51 +02:00
parent 610c7d8b7b
commit acf73ce968

View File

@ -453,7 +453,7 @@ fn handle_message(context: Arc<Mutex<Context>>, message: Message, peers: &mut Pe
let mut context = context.lock().unwrap(); let mut context = context.lock().unwrap();
context.chain.update_max_height(height); context.chain.update_max_height(height);
info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip()); info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip());
State::message(Message::GetBlock { index: height }) State::message(Message::GetBlock { index: my_height + 1 })
} else if my_height == height && hash.ne(&my_hash) { } else if my_height == height && hash.ne(&my_hash) {
info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip()); info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip());
info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash); info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash);
@ -471,7 +471,7 @@ fn handle_message(context: Arc<Mutex<Context>>, message: Message, peers: &mut Pe
let mut context = context.lock().unwrap(); let mut context = context.lock().unwrap();
context.chain.update_max_height(height); context.chain.update_max_height(height);
info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip()); info!("Peer is higher, requesting block {} from {}", height, peer.get_addr().ip());
State::message(Message::GetBlock { index: height }) State::message(Message::GetBlock { index: my_height + 1 })
} else if my_height == height && hash.ne(&my_hash) { } else if my_height == height && hash.ne(&my_hash) {
info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip()); info!("Hashes are different, requesting block {} from {}", my_height, peer.get_addr().ip());
info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash); info!("My hash: {:?}, their hash: {:?}", &my_hash, &hash);