Skip to content

Commit

Permalink
removed lightwalletd from zaino
Browse files Browse the repository at this point in the history
  • Loading branch information
idky137 committed Nov 26, 2024
1 parent 383736a commit d3c4bb3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 54 deletions.
5 changes: 1 addition & 4 deletions zaino-serve/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AtomicBool>,
}
48 changes: 24 additions & 24 deletions zaino-serve/src/rpc/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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(_) => {
Expand All @@ -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()),
)
Expand Down Expand Up @@ -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(_) => {
Expand All @@ -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()),
)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -681,7 +681,7 @@ impl CompactTxStreamer for GrpcClient {
let reversed_hash = hash.iter().rev().copied().collect::<Vec<u8>>();
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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down Expand Up @@ -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()),
)
Expand Down
2 changes: 0 additions & 2 deletions zaino-serve/src/server/director.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl Server {
pub async fn spawn(
tcp_active: bool,
tcp_ingestor_listen_addr: Option<SocketAddr>,
lightwalletd_uri: Uri,
zebrad_uri: Uri,
max_queue_size: u16,
max_worker_pool_size: u16,
Expand Down Expand Up @@ -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(),
Expand Down
9 changes: 2 additions & 7 deletions zaino-serve/src/server/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ impl Worker {
_worker_id: usize,
queue: QueueReceiver<ZingoIndexerRequest>,
requeue: QueueSender<ZingoIndexerRequest>,
lightwalletd_uri: Uri,
zebrad_uri: Uri,
atomic_status: AtomicStatus,
online: Arc<AtomicBool>,
) -> Self {
let grpc_client = GrpcClient {
lightwalletd_uri,
zebrad_uri,
zebrad_rpc_uri: zebrad_uri,
online: online.clone(),
};
Worker {
Expand Down Expand Up @@ -205,7 +203,6 @@ impl WorkerPool {
idle_size: u16,
queue: QueueReceiver<ZingoIndexerRequest>,
_requeue: QueueSender<ZingoIndexerRequest>,
lightwalletd_uri: Uri,
zebrad_uri: Uri,
status: WorkerPoolStatus,
online: Arc<AtomicBool>,
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
)
Expand Down
2 changes: 0 additions & 2 deletions zaino-testutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
5 changes: 0 additions & 5 deletions zainod/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ pub struct IndexerConfig {
pub tcp_active: bool,
/// TcpIngestors listen port
pub listen_port: Option<u16>,
/// LightWalletD listen port [DEPRECATED].
/// Used by zingo-testutils.
pub lightwalletd_port: u16,
/// Full node / validator listen port.
pub zebrad_port: u16,
/// Full node Username.
Expand Down Expand Up @@ -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()),
Expand All @@ -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),
Expand Down
7 changes: 0 additions & 7 deletions zainod/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -80,11 +79,6 @@ impl Indexer {
let tcp_ingestor_listen_addr: Option<SocketAddr> = 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,
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions zainod/zindexer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d3c4bb3

Please sign in to comment.