From abbfdcffdd003af5a20e3f500df7e3abb854892a Mon Sep 17 00:00:00 2001 From: Luis Herasme Date: Sat, 20 Jul 2024 08:28:34 -0400 Subject: [PATCH] Removes health check server --- ghost-crab/src/indexer.rs | 4 ---- ghost-crab/src/lib.rs | 1 - ghost-crab/src/server.rs | 48 --------------------------------------- 3 files changed, 53 deletions(-) delete mode 100644 ghost-crab/src/server.rs diff --git a/ghost-crab/src/indexer.rs b/ghost-crab/src/indexer.rs index 39924b5..c2205fa 100644 --- a/ghost-crab/src/indexer.rs +++ b/ghost-crab/src/indexer.rs @@ -1,7 +1,6 @@ use crate::block_handler::{process_logs_block, BlockConfig, BlockHandlerInstance}; use crate::handler::{HandleInstance, HandlerConfig}; use crate::process_logs::process_logs; -use crate::server::Server; use alloy::primitives::Address; use tokio::sync::mpsc::error::SendError; use tokio::sync::mpsc::{self, Receiver, Sender}; @@ -48,9 +47,6 @@ impl Indexer { pub fn new() -> Indexer { let (tx, rx) = mpsc::channel::(1); - let server = Server::new(3000); - server.start(); - Indexer { handlers: Vec::new(), block_handlers: Vec::new(), diff --git a/ghost-crab/src/lib.rs b/ghost-crab/src/lib.rs index f017d64..6e7ad93 100644 --- a/ghost-crab/src/lib.rs +++ b/ghost-crab/src/lib.rs @@ -5,7 +5,6 @@ pub mod indexer; pub mod latest_block_manager; pub mod prelude; pub mod process_logs; -mod server; pub use indexer::Indexer; pub use ghost_crab_common::config; diff --git a/ghost-crab/src/server.rs b/ghost-crab/src/server.rs deleted file mode 100644 index 5bf0d8d..0000000 --- a/ghost-crab/src/server.rs +++ /dev/null @@ -1,48 +0,0 @@ -use bytes::Bytes; -use http_body_util::Full; -use hyper::server::conn::http1; -use hyper::service::service_fn; -use hyper::Response; -use hyper_util::rt::TokioIo; -use hyper_util::rt::TokioTimer; -use std::convert::Infallible; -use std::net::SocketAddr; -use tokio::net::TcpListener; - -pub struct Server { - port: u16, -} - -impl Server { - pub fn new(port: u16) -> Self { - Self { port } - } - - pub fn start(&self) { - let port = self.port; - - tokio::spawn(async move { - let addr: SocketAddr = ([127, 0, 0, 1], port).into(); - let listener = TcpListener::bind(addr).await.unwrap(); - - loop { - let (tcp, _) = listener.accept().await.unwrap(); - let io = TokioIo::new(tcp); - - tokio::task::spawn(async move { - if let Err(err) = http1::Builder::new() - .timer(TokioTimer::new()) - .serve_connection(io, service_fn(|_| handler())) - .await - { - println!("Error serving connection: {:?}", err); - } - }); - } - }); - } -} - -async fn handler() -> Result>, Infallible> { - Ok(Response::new(Full::new(Bytes::from("Hello world")))) -}