Add WASM support to `lightwalletd-tonic` feature flag (#1270)

The transport-specific code is moved behind a new `lightwalletd-tonic-transport` feature flag.
This commit is contained in:
Willem Olding 2024-03-15 22:58:13 +11:00 committed by GitHub
parent 50a4ce3f04
commit 1775f6525b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 16 deletions

View File

@ -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

View File

@ -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"

View File

@ -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",

View File

@ -779,3 +779,16 @@ impl proposal::Proposal {
}
}
}
#[cfg(feature = "lightwalletd-tonic-transport")]
impl service::compact_tx_streamer_client::CompactTxStreamerClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<tonic::codegen::StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}

View File

@ -284,17 +284,6 @@ pub mod compact_tx_streamer_client {
pub struct CompactTxStreamerClient<T> {
inner: tonic::client::Grpc<T>,
}
impl CompactTxStreamerClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> CompactTxStreamerClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,