fix: 🚑 exit when a client disconnects

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-06-05 23:52:19 +03:00
parent 2f4051d751
commit a244fb2e6d
2 changed files with 5 additions and 5 deletions

View file

@ -19,7 +19,8 @@ async fn main() {
},
None => return,
};
todo!("Limbo Block: Not in chain, but processing by others or none. Sync it also")
//todo!("Limbo Block: Not in chain, but processing by others or none. Sync it also");
//todo!("Consensus should be notified for new block, should forget old blocks");
}
async fn server() {
@ -29,13 +30,13 @@ async fn server() {
};
let blockchain = BlockChain::new(server_config.difficulty.into());
let blockhain_thread_safe = Arc::new(Mutex::new(blockchain));
let blockchain_thread_safe = Arc::new(Mutex::new(blockchain));
let block_data_channel_sender = broadcast::channel(1).0;
server_network::start_network(
server_config,
blockhain_thread_safe,
blockchain_thread_safe,
block_data_channel_sender.subscribe(),
)
.await;

View file

@ -35,12 +35,11 @@ pub async fn start_network(
blockchain_thread_safe.clone(),
consensus_data_channels.clone(),
));
//todo!("Consensus should be notified for new block, should forget old blocks");
loop {
if let Ok(connection) = listener_socket.accept().await {
let ws_stream = match accept_async(connection.0).await {
Ok(ws_stream) => ws_stream,
Err(_) => return,
Err(_) => continue,
};
let (ws_stream_sender, ws_stream_receiver) = ws_stream.split();
let blockchain_thread_safe = blockchain_thread_safe.clone();