Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
makemake-kbo committed Feb 26, 2024
1 parent 3e9d280 commit 6fb7ecb
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/admin/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::sync::{
use sled::Db;

use crate::{
log_info,
admin::accept::accept_admin_request,
log_info,
Rpc,
Settings,
};
Expand Down
6 changes: 3 additions & 3 deletions src/balancer/accept_http.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::{
log_info,
log_wrn,
log_err,
balancer::{
format::{
incoming_to_value,
Expand All @@ -15,6 +12,9 @@ use crate::{
selection::select::pick,
},
cache_error,
log_err,
log_info,
log_wrn,
no_rpc_available,
print_cache_error,
rpc::types::Rpc,
Expand Down
6 changes: 3 additions & 3 deletions src/config/cache_setup.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
config::system::{
TAGLINE,
VERSION_STR,
TAGLINE,
VERSION_STR,
},
log_info,
log_err,
log_info,
};
use sled::Db;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pub mod cache_setup;
pub mod cli_args;
pub mod error;
pub mod setup;
pub mod system;
pub mod types;
pub mod system;
4 changes: 2 additions & 2 deletions src/config/setup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
Rpc,
log_err,
config::error::ConfigError,
log_err,
Rpc,
};
use std::time::Instant;
use tokio::sync::mpsc;
Expand Down
8 changes: 3 additions & 5 deletions src/config/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
log_wrn,
log_info,
config::setup::sort_by_latency,
log_info,
log_wrn,
Rpc,
};
use clap::{
Expand Down Expand Up @@ -326,9 +326,7 @@ impl Settings {

if !is_ws {
log_wrn!("WebSocket endpoints not present for all nodes, or newHeads_ttl is 0.");
log_wrn!(
"Disabling WS only-features. Please check docs for more info."
)
log_wrn!("Disabling WS only-features. Please check docs for more info.")
}

// Admin namespace things
Expand Down
8 changes: 4 additions & 4 deletions src/health/check.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use crate::{
log_info,
IncomingResponse,
SubscriptionData,
log_wrn,
health::{
error::HealthError,
safe_block::{
get_safe_block,
NamedBlocknumbers,
},
},
log_info,
log_wrn,
websocket::{
subscription_manager::move_subscriptions,
types::{
WsChannelErr,
WsconnMessage,
},
},
IncomingResponse,
Rpc,
Settings,
SubscriptionData,
};
use tokio::sync::broadcast;

Expand Down
4 changes: 1 addition & 3 deletions src/health/head_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ pub async fn manage_cache(
// Check if finalized_stream has changed
if last_finalized != *finalized_rx.borrow() {
last_finalized = *finalized_rx.borrow();
log_info!(
"New finalized block!\nRemoving stale entries from the cache."
);
log_info!("New finalized block!\nRemoving stale entries from the cache.");
// Remove stale entries from the head_cache
remove_stale(head_cache, last_finalized)?;
}
Expand Down
8 changes: 4 additions & 4 deletions src/health/safe_block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
log_info,
log_wrn,
log_err,
balancer::processing::CacheArgs,
config::system::WS_HEALTH_CHECK_USER_ID,
log_err,
log_info,
log_wrn,
rpc::{
error::RpcError,
types::{
Expand Down Expand Up @@ -238,7 +238,7 @@ pub async fn subscribe_to_new_heads(
None => {
log_err!("Failed to get some failed node subscription IDs! Subscriptions might be silently dropped!");
continue;
},
}
};
match move_subscriptions(
&incoming_tx,
Expand Down
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
config_guard.health_check,
config_guard.admin.enabled,
config_guard.is_ws,
config_guard.expected_block_time
config_guard.expected_block_time,
)
};

Expand Down Expand Up @@ -202,11 +202,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio::task::spawn(async move {
tokio::task::spawn(async move {
let _ =
subscription_dispatcher(
outgoing_rx_ws,
incoming_tx_ws,
sub_dispatcher
).await;
subscription_dispatcher(outgoing_rx_ws, incoming_tx_ws, sub_dispatcher).await;
});

let _ = ws_conn_manager(
Expand Down
9 changes: 3 additions & 6 deletions src/websocket/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{
log_err,
log_info,
balancer::{
format::replace_block_tags,
processing::{
Expand All @@ -10,6 +8,8 @@ use crate::{
},
selection::select::pick,
},
log_err,
log_info,
rpc::types::Rpc,
websocket::{
error::WsError,
Expand Down Expand Up @@ -116,10 +116,7 @@ async fn handle_incoming_message(
log_err!("ws_conn_manager error: failed to send message");
}
} else {
log_err!(
"No WS connection at index {}",
rpc_position
);
log_err!("No WS connection at index {}", rpc_position);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/websocket/server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::sync::Arc;

use crate::{
log_info,
balancer::processing::CacheArgs,
log_info,
websocket::{
client::execute_ws_call,
error::WsError,
Expand Down Expand Up @@ -126,7 +126,8 @@ pub async fn serve_websocket(
if let Some(msg) = &msg {
log_info!(
"Received close message with code {} and message: {}",
msg.code, msg.reason
msg.code,
msg.reason
);
} else {
println!("Received close message");
Expand Down
7 changes: 2 additions & 5 deletions src/websocket/subscription_manager.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
log_err,
config::system::{
MAGIC,
WS_SUB_MANAGER_ID,
},
log_err,
websocket::{
error::WsError,
types::{
Expand Down Expand Up @@ -82,10 +82,7 @@ pub async fn subscription_dispatcher(
// False means tht we do not need to do anything
Ok(false) => {}
Err(e) => {
log_err!(
"Fatal error while trying to send subscriptions: {}",
e
)
log_err!("Fatal error while trying to send subscriptions: {}", e)
}
};
}
Expand Down
12 changes: 6 additions & 6 deletions src/websocket/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::{
};

use crate::{
websocket::error::WsError,
log_info,
log_wrn,
websocket::error::WsError,
};
use serde_json::Value;
use tokio::sync::mpsc;
Expand Down Expand Up @@ -161,10 +161,7 @@ impl SubscriptionData {

// TODO: pepega
let subscription = format!("{}", subscription["params"]);
log_info!(
"Subscribe_user finding: {}",
subscription
);
log_info!("Subscribe_user finding: {}", subscription);

self.raw_subscribe(user_id, &subscription)
}
Expand Down Expand Up @@ -381,7 +378,10 @@ impl SubscriptionData {
match user.send(message.clone()) {
Ok(_) => {}
Err(_) => {
log_wrn!("user_id {} unsubscribed without closing channel! Removing.", user_id);
log_wrn!(
"user_id {} unsubscribed without closing channel! Removing.",
user_id
);
let _ = &self.unsubscribe_user(user_id, subscription_id.to_string());
}
};
Expand Down

0 comments on commit 6fb7ecb

Please sign in to comment.