Skip to content

Commit b744ce5

Browse files
committed
chore: fmt
1 parent 2209fcd commit b744ce5

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

native/helios_nif/src/core/light_client.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use alloy::eips::BlockId;
22
use anyhow::Error;
3-
use hyper::{
4-
Body, Method, Request, Response, StatusCode,};
3+
use hyper::{Body, Method, Request, Response, StatusCode};
54
use serde_json::{Value, json};
65
use std::convert::Infallible;
76
use std::sync::{Arc, Mutex};
87
use tracing::{error, info};
98

10-
use crate::core::types::{JsonRpcRequest, JsonRpcError, JsonRpcErrorResponse, JsonRpcResponse, ServerState};
11-
use crate::core::utils::{parse_address, parse_b256, parse_block_id, parse_bytes, parse_u256};
129
use crate::core::server::create_error_response;
13-
10+
use crate::core::types::{
11+
JsonRpcError, JsonRpcErrorResponse, JsonRpcRequest, JsonRpcResponse, ServerState,
12+
};
13+
use crate::core::utils::{parse_address, parse_b256, parse_block_id, parse_bytes, parse_u256};
1414

1515
pub async fn handle_request(
1616
req: Request<Body>,
@@ -311,4 +311,3 @@ pub async fn handle_request(
311311

312312
Ok(response)
313313
}
314-

native/helios_nif/src/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pub mod light_client;
2+
pub mod server;
23
pub mod types;
34
pub mod utils;
4-
pub mod server;

native/helios_nif/src/core/server.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ use tracing::{error, info};
1515
use tracing_subscriber::FmtSubscriber;
1616
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
1717

18-
use crate::core::types::{JsonRpcError, JsonRpcErrorResponse, ServerState};
1918
use crate::core::light_client::handle_request;
20-
19+
use crate::core::types::{JsonRpcError, JsonRpcErrorResponse, ServerState};
2120

2221
pub fn create_error_response(
2322
code: i32,
@@ -89,7 +88,7 @@ pub fn start_server(
8988

9089
runtime.spawn(async move {
9190
info!(target: "helios::server", "Starting HTTP server on {}", address);
92-
91+
9392
let make_svc = make_service_fn(move |_conn| {
9493
let state = state_clone.clone();
9594
async move {
@@ -98,19 +97,18 @@ pub fn start_server(
9897
}))
9998
}
10099
});
101-
100+
102101
let server = Server::bind(&address).serve(make_svc);
103-
104102
let shutdown_signal = {
105103
let mut state = state.lock().unwrap();
106104
state.shutdown_signal.take().unwrap()
107105
};
108-
106+
109107
let server = server.with_graceful_shutdown(async {
110108
shutdown_signal.await.ok();
111109
info!(target: "helios::server", "Server shutting down gracefully");
112110
});
113-
111+
114112
info!(target: "helios::server", "HTTP server running at {}", address);
115113
if let Err(e) = server.await {
116114
error!(target: "helios::server", "Server error: {}", e);

native/helios_nif/src/core/types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use serde::{Deserialize, Serialize};
12
use serde_json::Value;
2-
use serde::{Serialize, Deserialize};
3-
use tokio::sync::oneshot;
43
use std::sync::Arc;
4+
use tokio::sync::oneshot;
55

66
#[derive(Deserialize, Debug)]
77
pub struct JsonRpcRequest {
@@ -34,4 +34,4 @@ pub struct JsonRpcError {
3434
pub struct ServerState {
3535
pub client: Arc<helios::ethereum::EthereumClient>,
3636
pub shutdown_signal: Option<oneshot::Receiver<()>>,
37-
}
37+
}

native/helios_nif/src/core/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use alloy::{
22
eips::BlockId,
3-
primitives::{Address, B256, Bytes, U256}
3+
primitives::{Address, B256, Bytes, U256},
44
};
55
use anyhow::Error;
66
use serde_json::Value;
77
use std::str::FromStr;
88

9-
109
pub fn parse_block_id(value: &Value) -> Result<BlockId, Error> {
1110
match value {
1211
Value::String(s) => {
@@ -92,4 +91,4 @@ pub fn parse_bytes(value: &Value) -> Result<Bytes, Error> {
9291
}
9392
_ => Err(Error::msg("Invalid bytes format")),
9493
}
95-
}
94+
}

0 commit comments

Comments
 (0)