Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Nov 30, 2023
1 parent 1bfc080 commit 51d0494
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.72"
msrv = "1.74"
6 changes: 3 additions & 3 deletions crates/anvil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) {
let mut servers = Vec::with_capacity(config.host.len());
let mut addresses = Vec::with_capacity(config.host.len());

for addr in config.host.iter() {
let sock_addr = SocketAddr::new(addr.to_owned(), port);
for addr in &config.host {
let sock_addr = SocketAddr::new(*addr, port);
addresses.push(sock_addr);

// spawn the server on a new task
let srv = server::serve(sock_addr, api.clone(), server_config.clone()).await;
let srv = server::serve(sock_addr, api.clone(), server_config.clone()).await.unwrap();
servers.push(tokio::task::spawn(srv.map_err(Into::into)));
}

Expand Down
14 changes: 6 additions & 8 deletions crates/anvil/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ mod handler;
///
/// The returned future creates a new server, binding it to the given address, which returns another
/// future that runs it.
pub fn serve(
pub async fn serve(
addr: SocketAddr,
api: EthApi,
config: ServerConfig,
) -> impl Future<Output = impl Future<Output = io::Result<()>>> {
async move {
let router = router(api, config);
let tcp_listener = tokio::net::TcpListener::bind(addr).await.unwrap();
axum::serve(tcp_listener, router.into_make_service()).into_future()
}
) -> io::Result<impl Future<Output = io::Result<()>>> {
tokio::net::TcpListener::bind(addr).await.map(|tcp_listener| {
axum::serve(tcp_listener, router(api, config).into_make_service()).into_future()
})
}

/// Configures an [`axum::Router`] that handles [`EthApi`] related JSON-RPC calls via HTTP and WS.
Expand All @@ -43,13 +41,13 @@ pub fn router(api: EthApi, config: ServerConfig) -> Router {
/// # Panics
///
/// Panics if setting up the IPC connection was unsuccessful.
#[track_caller]
pub fn spawn_ipc(api: EthApi, path: String) -> JoinHandle<io::Result<()>> {
try_spawn_ipc(api, path).expect("failed to establish ipc connection")
}

/// Launches an ipc server at the given path in a new task.
pub fn try_spawn_ipc(api: EthApi, path: String) -> io::Result<JoinHandle<io::Result<()>>> {
let path = path.into();
let handler = PubSubEthRpcHandler::new(api);
let ipc = IpcEndpoint::new(handler, path);
let incoming = ipc.incoming()?;
Expand Down

0 comments on commit 51d0494

Please sign in to comment.