Merge pull request #192 from uqbar-dao/hf/remove-almost-all-compiler-warnings

remove almost all compiler warnings
This commit is contained in:
nick.kino 2024-01-22 21:48:19 -08:00 committed by GitHub
commit 49675eed4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 16 deletions

View File

@ -42,6 +42,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
/// This can and should be an environment variable / setting. It configures networking /// This can and should be an environment variable / setting. It configures networking
/// such that indirect nodes always use routers, even when target is a direct node, /// such that indirect nodes always use routers, even when target is a direct node,
/// such that only their routers can ever see their physical networking details. /// such that only their routers can ever see their physical networking details.
#[cfg(not(feature = "simulation-mode"))]
const REVEAL_IP: bool = true; const REVEAL_IP: bool = true;
async fn serve_register_fe( async fn serve_register_fe(
@ -449,6 +450,7 @@ async fn main() {
our.name.clone(), our.name.clone(),
kernel_message_sender.clone(), kernel_message_sender.clone(),
net_message_receiver, net_message_receiver,
network_error_sender,
)); ));
tasks.spawn(state::state_sender( tasks.spawn(state::state_sender(
our.name.clone(), our.name.clone(),
@ -503,6 +505,16 @@ async fn main() {
eth_provider_receiver, eth_provider_receiver,
print_sender.clone(), print_sender.clone(),
)); ));
#[cfg(feature = "simulation-mode")]
if let Some(rpc_url) = rpc_url {
tasks.spawn(eth::provider::provider(
our.name.clone(),
rpc_url.clone(),
kernel_message_sender.clone(),
eth_provider_receiver,
print_sender.clone(),
));
}
tasks.spawn(vfs::vfs( tasks.spawn(vfs::vfs(
our.name.clone(), our.name.clone(),
kernel_message_sender.clone(), kernel_message_sender.clone(),

View File

@ -1,12 +1,9 @@
use futures::{SinkExt, StreamExt}; use futures::{SinkExt, StreamExt};
use tokio::net::TcpStream;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use tokio_tungstenite::{ use tokio_tungstenite::{
connect_async, connect_async,
tungstenite::protocol::Message::{Binary, Text}, tungstenite::protocol::Message::{Binary, Text},
WebSocketStream,
}; };
use url::Url;
use crate::types; use crate::types;
@ -18,6 +15,7 @@ pub async fn mock_client(
node_identity: types::NodeId, node_identity: types::NodeId,
send_to_loop: Sender, send_to_loop: Sender,
mut recv_from_loop: Receiver, mut recv_from_loop: Receiver,
_network_error_sender: types::NetworkErrorSender,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let url = format!("ws://127.0.0.1:{}", port); let url = format!("ws://127.0.0.1:{}", port);

View File

@ -1,20 +1,27 @@
use crate::net::{types::*, utils::*}; #[cfg(not(feature = "simulation-mode"))]
use crate::types::*; use {
use anyhow::{anyhow, Result}; anyhow::{anyhow, Result},
use dashmap::DashMap; dashmap::DashMap,
use futures::{SinkExt, StreamExt}; futures::{SinkExt, StreamExt},
use rand::seq::SliceRandom; rand::seq::SliceRandom,
use ring::signature::Ed25519KeyPair; ring::signature::Ed25519KeyPair,
use std::{collections::HashMap, sync::Arc}; std::{collections::HashMap, sync::Arc},
use tokio::net::TcpListener; tokio::net::TcpListener,
use tokio::task::JoinSet; tokio::task::JoinSet,
use tokio::time; tokio::time,
use tokio_tungstenite::{ tokio_tungstenite::{
accept_async, connect_async, tungstenite, MaybeTlsStream, WebSocketStream, accept_async, connect_async, tungstenite, MaybeTlsStream, WebSocketStream,
},
}; };
#[cfg(not(feature = "simulation-mode"))]
mod types; mod types;
#[cfg(not(feature = "simulation-mode"))]
mod utils; mod utils;
#[cfg(not(feature = "simulation-mode"))]
use crate::net::{types::*, utils::*};
#[cfg(not(feature = "simulation-mode"))]
use crate::types::*;
// Re-export for testing. // Re-export for testing.
#[cfg(feature = "simulation-mode")] #[cfg(feature = "simulation-mode")]
@ -23,13 +30,16 @@ mod mock;
pub use mock::mock_client; pub use mock::mock_client;
// only used in connection initialization, otherwise, nacks and Responses are only used for "timeouts" // only used in connection initialization, otherwise, nacks and Responses are only used for "timeouts"
#[cfg(not(feature = "simulation-mode"))]
const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5); const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5);
/// 10 MB -- TODO analyze as desired, apps can always chunk data into many messages /// 10 MB -- TODO analyze as desired, apps can always chunk data into many messages
/// note that this only applies to cross-network messages, not local ones. /// note that this only applies to cross-network messages, not local ones.
#[cfg(not(feature = "simulation-mode"))]
const MESSAGE_MAX_SIZE: u32 = 10_485_800; const MESSAGE_MAX_SIZE: u32 = 10_485_800;
/// Entry point from the main kernel task. Runs forever, spawns listener and sender tasks. /// Entry point from the main kernel task. Runs forever, spawns listener and sender tasks.
#[cfg(not(feature = "simulation-mode"))]
pub async fn networking( pub async fn networking(
our: Identity, our: Identity,
our_ip: String, our_ip: String,
@ -107,6 +117,7 @@ pub async fn networking(
} }
} }
#[cfg(not(feature = "simulation-mode"))]
async fn indirect_networking( async fn indirect_networking(
our: Identity, our: Identity,
our_ip: String, our_ip: String,
@ -232,6 +243,7 @@ async fn indirect_networking(
} }
} }
#[cfg(not(feature = "simulation-mode"))]
async fn connect_to_routers( async fn connect_to_routers(
our: Identity, our: Identity,
our_ip: String, our_ip: String,
@ -278,6 +290,7 @@ async fn connect_to_routers(
Ok(()) Ok(())
} }
#[cfg(not(feature = "simulation-mode"))]
async fn direct_networking( async fn direct_networking(
our: Identity, our: Identity,
our_ip: String, our_ip: String,
@ -460,6 +473,7 @@ async fn direct_networking(
} }
} }
#[cfg(not(feature = "simulation-mode"))]
async fn establish_new_peer_connection( async fn establish_new_peer_connection(
our: Identity, our: Identity,
our_ip: String, our_ip: String,
@ -559,6 +573,7 @@ async fn establish_new_peer_connection(
} }
} }
#[cfg(not(feature = "simulation-mode"))]
async fn init_connection_via_router( async fn init_connection_via_router(
our: &Identity, our: &Identity,
our_ip: &str, our_ip: &str,
@ -604,6 +619,7 @@ async fn init_connection_via_router(
false false
} }
#[cfg(not(feature = "simulation-mode"))]
async fn recv_connection( async fn recv_connection(
our: &Identity, our: &Identity,
our_ip: &str, our_ip: &str,
@ -684,6 +700,7 @@ async fn recv_connection(
)) ))
} }
#[cfg(not(feature = "simulation-mode"))]
async fn recv_connection_via_router( async fn recv_connection_via_router(
our: &Identity, our: &Identity,
our_ip: &str, our_ip: &str,
@ -762,6 +779,7 @@ async fn recv_connection_via_router(
)) ))
} }
#[cfg(not(feature = "simulation-mode"))]
async fn init_connection( async fn init_connection(
our: &Identity, our: &Identity,
our_ip: &str, our_ip: &str,
@ -848,6 +866,7 @@ async fn init_connection(
} }
/// net module only handles incoming local requests, will never return a response /// net module only handles incoming local requests, will never return a response
#[cfg(not(feature = "simulation-mode"))]
async fn handle_local_message( async fn handle_local_message(
our: &Identity, our: &Identity,
our_ip: &str, our_ip: &str,