Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gRPC proxy from wRPC #593

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ members = [
"rpc/grpc/server",
"rpc/wrpc/server",
"rpc/wrpc/client",
"rpc/wrpc/proxy",
"rpc/wrpc/wasm",
"rpc/wrpc/examples/subscriber",
"rpc/wrpc/examples/simple_client",
Expand Down Expand Up @@ -129,7 +128,6 @@ kaspa-wallet-macros = { version = "0.15.3", path = "wallet/macros" }
kaspa-wasm = { version = "0.15.3", path = "wasm" }
kaspa-wasm-core = { version = "0.15.3", path = "wasm/core" }
kaspa-wrpc-client = { version = "0.15.3", path = "rpc/wrpc/client" }
kaspa-wrpc-proxy = { version = "0.15.3", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.15.3", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.15.3", path = "rpc/wrpc/wasm" }
kaspa-wrpc-example-subscriber = { version = "0.15.3", path = "rpc/wrpc/examples/subscriber" }
Expand Down
3 changes: 1 addition & 2 deletions kaspad/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,12 @@ do you confirm? (answer y/n or pass --yes to the Kaspad command line to confirm
listen_address.map(|listen_address| {
Arc::new(WrpcService::new(
wrpc_service_tasks,
Some(rpc_core_service.clone()),
rpc_core_service.clone(),
&encoding,
wrpc_server_counters,
WrpcServerOptions {
listen_address: listen_address.to_address(&network.network_type, &encoding).to_string(), // TODO: use a normalized ContextualNetAddress instead of a String
verbose: args.wrpc_verbose,
..WrpcServerOptions::default()
},
))
})
Expand Down
2 changes: 1 addition & 1 deletion rpc/macros/src/wrpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ToTokens for RpcTable {
let verbose = server_ctx.verbose();
if verbose { workflow_log::log_info!("request: {:?}",request); }
// TODO: RPC-CONNECT
let response: #response_type = server_ctx.rpc_service(&connection_ctx).#fn_call(None, request.into_inner()).await
let response: #response_type = server_ctx.rpc_service().#fn_call(None, request.into_inner()).await
.map_err(|e|ServerError::Text(e.to_string()))?;
if verbose { workflow_log::log_info!("response: {:?}",response); }
Ok(Serializable(response))
Expand Down
28 changes: 0 additions & 28 deletions rpc/wrpc/proxy/Cargo.toml

This file was deleted.

26 changes: 0 additions & 26 deletions rpc/wrpc/proxy/src/error.rs

This file was deleted.

104 changes: 0 additions & 104 deletions rpc/wrpc/proxy/src/main.rs

This file was deleted.

1 change: 0 additions & 1 deletion rpc/wrpc/proxy/src/result.rs

This file was deleted.

1 change: 0 additions & 1 deletion rpc/wrpc/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ borsh = { workspace = true, features = ["rc"] }
futures.workspace = true
kaspa-consensus-core.workspace = true
kaspa-core.workspace = true
kaspa-grpc-client.workspace = true
kaspa-notify.workspace = true
kaspa-rpc-core.workspace = true
kaspa-rpc-macros.workspace = true
Expand Down
24 changes: 3 additions & 21 deletions rpc/wrpc/server/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use kaspa_grpc_client::{GrpcClient, GrpcClientNotify};
use kaspa_notify::{
connection::Connection as ConnectionT,
error::{Error as NotifyError, Result as NotifyResult},
listener::ListenerId,
notification::Notification as NotificationT,
notifier::Notify,
};
use kaspa_rpc_core::{api::ops::RpcApiOps, notify::mode::NotificationMode, Notification};
use kaspa_rpc_core::{api::ops::RpcApiOps, Notification};
use std::{
fmt::{Debug, Display},
sync::{Arc, Mutex},
Expand Down Expand Up @@ -48,7 +47,6 @@ struct ConnectionInner {
pub id: u64,
pub peer: SocketAddr,
pub messenger: Arc<Messenger>,
pub grpc_client: Option<Arc<GrpcClient>>,
// not using an atomic in case an Id will change type in the future...
pub listener_id: Mutex<Option<ListenerId>>,
}
Expand Down Expand Up @@ -83,12 +81,8 @@ pub struct Connection {
}

impl Connection {
pub fn new(id: u64, peer: &SocketAddr, messenger: Arc<Messenger>, grpc_client: Option<Arc<GrpcClient>>) -> Connection {
// If a GrpcClient is provided, it has to come configured in direct mode
assert!(grpc_client.is_none() || grpc_client.as_ref().unwrap().notification_mode() == NotificationMode::Direct);
// Should a gRPC client be provided, no listener_id is required for subscriptions so the listener id is set to default
let listener_id = Mutex::new(grpc_client.clone().map(|_| ListenerId::default()));
Connection { inner: Arc::new(ConnectionInner { id, peer: *peer, messenger, grpc_client, listener_id }) }
pub fn new(id: u64, peer: &SocketAddr, messenger: Arc<Messenger>) -> Connection {
Connection { inner: Arc::new(ConnectionInner { id, peer: *peer, messenger, listener_id: Mutex::new(None) }) }
}

/// Obtain the connection id
Expand All @@ -101,18 +95,6 @@ impl Connection {
&self.inner.messenger
}

pub fn grpc_client(&self) -> Arc<GrpcClient> {
self.inner
.grpc_client
.as_ref()
.cloned()
.unwrap_or_else(|| panic!("Incorrect use: `server::Connection` does not carry RpcApi references"))
}

pub fn grpc_client_notify_target(&self) -> GrpcClientNotify {
self.inner.clone()
}

pub fn listener_id(&self) -> Option<ListenerId> {
*self.inner.listener_id.lock().unwrap()
}
Expand Down
Loading