diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6263019a60..ebf418cfed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,7 +195,7 @@ jobs: run: cargo add --no-default-features --path ../crates/zcash_proofs - name: Add zcash_client_backend as a dependency of the synthetic crate working-directory: ./ci-build - run: cargo add --no-default-features --path ../crates/zcash_client_backend + run: cargo add --features lightwalletd-tonic --path ../crates/zcash_client_backend - name: Copy pinned dependencies into synthetic crate run: cp crates/Cargo.lock ci-build/ - name: Add target diff --git a/Cargo.toml b/Cargo.toml index 405c9dd1ed..ab50918ed5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,8 +94,8 @@ rayon = "1.5" # Protobuf and gRPC prost = "0.12" -tonic = "0.10" -tonic-build = "0.10" +tonic = { version = "0.10", default-features = false } +tonic-build = { version = "0.10", default-features = false } # Secret management secrecy = "0.8" diff --git a/zcash_client_backend/Cargo.toml b/zcash_client_backend/Cargo.toml index 41a6639a37..c61045b071 100644 --- a/zcash_client_backend/Cargo.toml +++ b/zcash_client_backend/Cargo.toml @@ -66,7 +66,7 @@ tracing.workspace = true # - Protobuf interfaces and gRPC bindings hex.workspace = true prost.workspace = true -tonic = { workspace = true, optional = true } +tonic = { workspace = true, optional = true, features = ["prost", "codegen"]} # - Secret management secrecy.workspace = true @@ -102,7 +102,7 @@ crossbeam-channel.workspace = true rayon.workspace = true [build-dependencies] -tonic-build.workspace = true +tonic-build = { workspace = true, features = ["prost"]} which = "4" [dev-dependencies] @@ -123,6 +123,9 @@ time = ">=0.3.22, <0.3.24" # time 0.3.24 has MSRV 1.67 ## Enables the `tonic` gRPC client bindings for connecting to a `lightwalletd` server. lightwalletd-tonic = ["dep:tonic"] +## Enables the `transport` feature of `tonic` producing a fully-featured client and server implementation +lightwalletd-tonic-transport = ["lightwalletd-tonic", "tonic?/transport"] + ## Enables receiving transparent funds and shielding them. transparent-inputs = [ "dep:hdwallet", diff --git a/zcash_client_backend/src/proto.rs b/zcash_client_backend/src/proto.rs index 5277d599ca..69d89070cc 100644 --- a/zcash_client_backend/src/proto.rs +++ b/zcash_client_backend/src/proto.rs @@ -779,3 +779,16 @@ impl proposal::Proposal { } } } + +#[cfg(feature = "lightwalletd-tonic-transport")] +impl service::compact_tx_streamer_client::CompactTxStreamerClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } +} diff --git a/zcash_client_backend/src/proto/service.rs b/zcash_client_backend/src/proto/service.rs index 5e2d1b59a4..ccfd3fed7a 100644 --- a/zcash_client_backend/src/proto/service.rs +++ b/zcash_client_backend/src/proto/service.rs @@ -284,17 +284,6 @@ pub mod compact_tx_streamer_client { pub struct CompactTxStreamerClient { inner: tonic::client::Grpc, } - impl CompactTxStreamerClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } impl CompactTxStreamerClient where T: tonic::client::GrpcService,