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:
parent
50a4ce3f04
commit
1775f6525b
|
@ -195,7 +195,7 @@ jobs:
|
||||||
run: cargo add --no-default-features --path ../crates/zcash_proofs
|
run: cargo add --no-default-features --path ../crates/zcash_proofs
|
||||||
- name: Add zcash_client_backend as a dependency of the synthetic crate
|
- name: Add zcash_client_backend as a dependency of the synthetic crate
|
||||||
working-directory: ./ci-build
|
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
|
- name: Copy pinned dependencies into synthetic crate
|
||||||
run: cp crates/Cargo.lock ci-build/
|
run: cp crates/Cargo.lock ci-build/
|
||||||
- name: Add target
|
- name: Add target
|
||||||
|
|
|
@ -94,8 +94,8 @@ rayon = "1.5"
|
||||||
|
|
||||||
# Protobuf and gRPC
|
# Protobuf and gRPC
|
||||||
prost = "0.12"
|
prost = "0.12"
|
||||||
tonic = "0.10"
|
tonic = { version = "0.10", default-features = false }
|
||||||
tonic-build = "0.10"
|
tonic-build = { version = "0.10", default-features = false }
|
||||||
|
|
||||||
# Secret management
|
# Secret management
|
||||||
secrecy = "0.8"
|
secrecy = "0.8"
|
||||||
|
|
|
@ -66,7 +66,7 @@ tracing.workspace = true
|
||||||
# - Protobuf interfaces and gRPC bindings
|
# - Protobuf interfaces and gRPC bindings
|
||||||
hex.workspace = true
|
hex.workspace = true
|
||||||
prost.workspace = true
|
prost.workspace = true
|
||||||
tonic = { workspace = true, optional = true }
|
tonic = { workspace = true, optional = true, features = ["prost", "codegen"]}
|
||||||
|
|
||||||
# - Secret management
|
# - Secret management
|
||||||
secrecy.workspace = true
|
secrecy.workspace = true
|
||||||
|
@ -102,7 +102,7 @@ crossbeam-channel.workspace = true
|
||||||
rayon.workspace = true
|
rayon.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tonic-build.workspace = true
|
tonic-build = { workspace = true, features = ["prost"]}
|
||||||
which = "4"
|
which = "4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[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.
|
## Enables the `tonic` gRPC client bindings for connecting to a `lightwalletd` server.
|
||||||
lightwalletd-tonic = ["dep:tonic"]
|
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.
|
## Enables receiving transparent funds and shielding them.
|
||||||
transparent-inputs = [
|
transparent-inputs = [
|
||||||
"dep:hdwallet",
|
"dep:hdwallet",
|
||||||
|
|
|
@ -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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -284,17 +284,6 @@ pub mod compact_tx_streamer_client {
|
||||||
pub struct CompactTxStreamerClient<T> {
|
pub struct CompactTxStreamerClient<T> {
|
||||||
inner: tonic::client::Grpc<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>
|
impl<T> CompactTxStreamerClient<T>
|
||||||
where
|
where
|
||||||
T: tonic::client::GrpcService<tonic::body::BoxBody>,
|
T: tonic::client::GrpcService<tonic::body::BoxBody>,
|
||||||
|
|
Loading…
Reference in New Issue