From d3c4bb3607158a9a023e81a84a8ad1b9882296bf Mon Sep 17 00:00:00 2001 From: idky137 Date: Tue, 26 Nov 2024 19:10:18 +0000 Subject: [PATCH] removed lightwalletd from zaino --- zaino-serve/src/rpc.rs | 5 +--- zaino-serve/src/rpc/service.rs | 48 +++++++++++++++--------------- zaino-serve/src/server/director.rs | 2 -- zaino-serve/src/server/worker.rs | 9 ++---- zaino-testutils/src/lib.rs | 2 -- zainod/src/config.rs | 5 ---- zainod/src/indexer.rs | 7 ----- zainod/zindexer.toml | 3 -- 8 files changed, 27 insertions(+), 54 deletions(-) diff --git a/zaino-serve/src/rpc.rs b/zaino-serve/src/rpc.rs index a9da92e..0a57091 100644 --- a/zaino-serve/src/rpc.rs +++ b/zaino-serve/src/rpc.rs @@ -7,11 +7,8 @@ pub mod service; #[derive(Debug, Clone)] /// Configuration data for gRPC server. pub struct GrpcClient { - /// Lightwalletd uri. - /// Used by grpc_passthrough to pass on unimplemented RPCs. - pub lightwalletd_uri: http::Uri, /// Zebrad uri. - pub zebrad_uri: http::Uri, + pub zebrad_rpc_uri: http::Uri, /// Represents the Online status of the gRPC server. pub online: Arc, } diff --git a/zaino-serve/src/rpc/service.rs b/zaino-serve/src/rpc/service.rs index 64a263b..5eeb35e 100644 --- a/zaino-serve/src/rpc/service.rs +++ b/zaino-serve/src/rpc/service.rs @@ -220,7 +220,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_latest_block."); Box::pin(async { let blockchain_info = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -263,7 +263,7 @@ impl CompactTxStreamer for GrpcClient { { println!("[TEST] Received call of get_block."); Box::pin(async { - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); let height: u32 = match request.into_inner().height.try_into() { Ok(height) => height, Err(_) => { @@ -276,7 +276,7 @@ impl CompactTxStreamer for GrpcClient { Ok(block) => Ok(tonic::Response::new(block)), Err(e) => { let chain_height = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -326,7 +326,7 @@ impl CompactTxStreamer for GrpcClient { { println!("[TEST] Received call of get_block_nullifiers."); Box::pin(async { - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); let height: u32 = match request.into_inner().height.try_into() { Ok(height) => height, Err(_) => { @@ -339,7 +339,7 @@ impl CompactTxStreamer for GrpcClient { Ok(block) => Ok(tonic::Response::new(block)), Err(e) => { let chain_height = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -396,7 +396,7 @@ impl CompactTxStreamer for GrpcClient { Self: 'async_trait, { println!("[TEST] Received call of get_block_range."); - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); Box::pin(async move { let blockrange = request.into_inner(); let mut start: u32 = match blockrange.start { @@ -436,7 +436,7 @@ impl CompactTxStreamer for GrpcClient { false }; let chain_height = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -541,7 +541,7 @@ impl CompactTxStreamer for GrpcClient { Self: 'async_trait, { println!("[TEST] Received call of get_block_range_nullifiers."); - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); Box::pin(async move { let blockrange = request.into_inner(); let mut start: u32 = match blockrange.start { @@ -581,7 +581,7 @@ impl CompactTxStreamer for GrpcClient { false }; let chain_height = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -681,7 +681,7 @@ impl CompactTxStreamer for GrpcClient { let reversed_hash = hash.iter().rev().copied().collect::>(); let hash_hex = hex::encode(reversed_hash); let tx = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -733,7 +733,7 @@ impl CompactTxStreamer for GrpcClient { Box::pin(async { let hex_tx = hex::encode(request.into_inner().data); let tx_output = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -775,7 +775,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_taddress_txids."); Box::pin(async move { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -903,7 +903,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_taddress_balance."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -949,7 +949,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_taddress_balance_stream."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1080,9 +1080,9 @@ impl CompactTxStreamer for GrpcClient { { println!("[TEST] Received call of get_mempool_tx."); Box::pin(async { - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1261,9 +1261,9 @@ impl CompactTxStreamer for GrpcClient { { println!("[TEST] Received call of get_mempool_stream."); Box::pin(async { - let zebrad_uri = self.zebrad_uri.clone(); + let zebrad_uri = self.zebrad_rpc_uri.clone(); let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1396,7 +1396,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_tree_state."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1470,7 +1470,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_latest_tree_state."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1529,7 +1529,7 @@ impl CompactTxStreamer for GrpcClient { { println!("[TEST] Received call of get_subtree_roots."); Box::pin(async move { - let zebrad_uri =self.zebrad_uri.clone(); + let zebrad_uri =self.zebrad_rpc_uri.clone(); let zebrad_client = JsonRpcConnector::new( zebrad_uri.clone(), Some("xxxxxx".to_string()), @@ -1684,7 +1684,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_address_utxos."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1772,7 +1772,7 @@ impl CompactTxStreamer for GrpcClient { println!("[TEST] Received call of get_address_utxos_stream."); Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) @@ -1877,7 +1877,7 @@ impl CompactTxStreamer for GrpcClient { // TODO: Add user and password as fields of GrpcClient and use here. Box::pin(async { let zebrad_client = JsonRpcConnector::new( - self.zebrad_uri.clone(), + self.zebrad_rpc_uri.clone(), Some("xxxxxx".to_string()), Some("xxxxxx".to_string()), ) diff --git a/zaino-serve/src/server/director.rs b/zaino-serve/src/server/director.rs index 6f5ccc0..e9a136c 100644 --- a/zaino-serve/src/server/director.rs +++ b/zaino-serve/src/server/director.rs @@ -69,7 +69,6 @@ impl Server { pub async fn spawn( tcp_active: bool, tcp_ingestor_listen_addr: Option, - lightwalletd_uri: Uri, zebrad_uri: Uri, max_queue_size: u16, max_worker_pool_size: u16, @@ -113,7 +112,6 @@ impl Server { idle_worker_pool_size, request_queue.rx().clone(), request_queue.tx().clone(), - lightwalletd_uri, zebrad_uri, status.workerpool_status.clone(), online.clone(), diff --git a/zaino-serve/src/server/worker.rs b/zaino-serve/src/server/worker.rs index 4c6db84..51e079d 100644 --- a/zaino-serve/src/server/worker.rs +++ b/zaino-serve/src/server/worker.rs @@ -47,14 +47,12 @@ impl Worker { _worker_id: usize, queue: QueueReceiver, requeue: QueueSender, - lightwalletd_uri: Uri, zebrad_uri: Uri, atomic_status: AtomicStatus, online: Arc, ) -> Self { let grpc_client = GrpcClient { - lightwalletd_uri, - zebrad_uri, + zebrad_rpc_uri: zebrad_uri, online: online.clone(), }; Worker { @@ -205,7 +203,6 @@ impl WorkerPool { idle_size: u16, queue: QueueReceiver, _requeue: QueueSender, - lightwalletd_uri: Uri, zebrad_uri: Uri, status: WorkerPoolStatus, online: Arc, @@ -217,7 +214,6 @@ impl WorkerPool { workers.len(), queue.clone(), _requeue.clone(), - lightwalletd_uri.clone(), zebrad_uri.clone(), status.statuses[workers.len()].clone(), online.clone(), @@ -257,8 +253,7 @@ impl WorkerPool { worker_index, self.workers[0].queue.clone(), self.workers[0].requeue.clone(), - self.workers[0].grpc_client.lightwalletd_uri.clone(), - self.workers[0].grpc_client.zebrad_uri.clone(), + self.workers[0].grpc_client.zebrad_rpc_uri.clone(), self.status.statuses[worker_index].clone(), self.online.clone(), ) diff --git a/zaino-testutils/src/lib.rs b/zaino-testutils/src/lib.rs index 5a51140..8109840 100644 --- a/zaino-testutils/src/lib.rs +++ b/zaino-testutils/src/lib.rs @@ -338,8 +338,6 @@ impl TestManager2 { let indexer_config = zainodlib::config::IndexerConfig { tcp_active: true, listen_port: Some(zaino_grpc_listen_port), - // NOTE: Remove field from IndexerConfig with the removal of current testutils. - lightwalletd_port: portpicker::pick_unused_port().expect("No ports free"), zebrad_port: zebrad_rpc_listen_port, node_user: Some("xxxxxx".to_string()), node_password: Some("xxxxxx".to_string()), diff --git a/zainod/src/config.rs b/zainod/src/config.rs index e366d5a..ac6ac81 100644 --- a/zainod/src/config.rs +++ b/zainod/src/config.rs @@ -9,9 +9,6 @@ pub struct IndexerConfig { pub tcp_active: bool, /// TcpIngestors listen port pub listen_port: Option, - /// LightWalletD listen port [DEPRECATED]. - /// Used by zingo-testutils. - pub lightwalletd_port: u16, /// Full node / validator listen port. pub zebrad_port: u16, /// Full node Username. @@ -51,7 +48,6 @@ impl Default for IndexerConfig { Self { tcp_active: true, listen_port: Some(8080), - lightwalletd_port: 9067, zebrad_port: 18232, node_user: Some("xxxxxx".to_string()), node_password: Some("xxxxxx".to_string()), @@ -71,7 +67,6 @@ pub fn load_config(file_path: &std::path::PathBuf) -> IndexerConfig { config = IndexerConfig { tcp_active: parsed_config.tcp_active, listen_port: parsed_config.listen_port.or(config.listen_port), - lightwalletd_port: parsed_config.lightwalletd_port, zebrad_port: parsed_config.zebrad_port, node_user: parsed_config.node_user.or(config.node_user), node_password: parsed_config.node_password.or(config.node_password), diff --git a/zainod/src/indexer.rs b/zainod/src/indexer.rs index 66f1c76..84ee01e 100644 --- a/zainod/src/indexer.rs +++ b/zainod/src/indexer.rs @@ -9,7 +9,6 @@ use std::{ }, }; -use http::Uri; use zaino_fetch::jsonrpc::connector::test_node_and_return_uri; use zaino_serve::server::{ director::{Server, ServerStatus}, @@ -80,11 +79,6 @@ impl Indexer { let tcp_ingestor_listen_addr: Option = config .listen_port .map(|port| SocketAddr::new(std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST), port)); - let lightwalletd_uri = Uri::builder() - .scheme("http") - .authority(format!("localhost:{}", config.lightwalletd_port)) - .path_and_query("/") - .build()?; println!("Checking connection with node.."); let zebrad_uri = test_node_and_return_uri( &config.zebrad_port, @@ -97,7 +91,6 @@ impl Indexer { Server::spawn( config.tcp_active, tcp_ingestor_listen_addr, - lightwalletd_uri, zebrad_uri, config.max_queue_size, config.max_worker_pool_size, diff --git a/zainod/zindexer.toml b/zainod/zindexer.toml index ba7b650..4634f59 100644 --- a/zainod/zindexer.toml +++ b/zainod/zindexer.toml @@ -6,9 +6,6 @@ tcp_active = true # Optional TcpIngestors listen port (use None or specify a port number) listen_port = 8137 -# LightWalletD listen port [DEPRECATED] -lightwalletd_port = 9067 - # Full node / validator listen port zebrad_port = 18232