@dashevo/dapi-grpc 4.1.0 → 4.2.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml CHANGED
@@ -26,12 +26,30 @@ tenderdash-proto = []
26
26
  # Client support.
27
27
  client = ["platform"]
28
28
 
29
+ # Networked tonic client: `connect()` on generated clients, TLS roots.
30
+ # Deliberately NOT in the default set: cargo features are not target-scoped,
31
+ # so a default-on transport would force tonic's transport stack onto wasm32
32
+ # consumers riding defaults, where it does not build. Without this feature
33
+ # the crate provides message types and transport-generic client stubs only.
34
+ # Tonic's codegen graph still includes tokio-stream and a minimal Tokio
35
+ # slice, but its hyper/rustls transport stack is not enabled. Native
36
+ # networked consumers enable this explicitly (rs-dapi-client does so through
37
+ # its non-wasm dependency); the wasm codegen path never emits `connect()`.
38
+ transport = [
39
+ "tonic/channel",
40
+ "tonic/transport",
41
+ "tonic/tls-native-roots",
42
+ "tonic/tls-webpki-roots",
43
+ "tonic/tls-ring",
44
+ ]
45
+
29
46
  # Build tonic server code. Includes all client features and adds server-specific dependencies.
30
47
  server = [
31
48
  "platform",
32
49
  "tenderdash-proto/server",
33
50
  "client",
34
51
  "drive",
52
+ "transport",
35
53
  "tonic/router",
36
54
  ]
37
55
 
@@ -55,14 +73,7 @@ tonic = { version = "0.14.2", features = ["codegen"], default-features = false }
55
73
  getrandom = { version = "0.2", features = ["js"] }
56
74
 
57
75
  [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
58
- tonic = { version = "0.14.2", features = [
59
- "codegen",
60
- "channel",
61
- "transport",
62
- "tls-native-roots",
63
- "tls-webpki-roots",
64
- "tls-ring",
65
- ], default-features = false }
76
+ tonic = { version = "0.14.2", features = ["codegen"], default-features = false }
66
77
 
67
78
  [build-dependencies]
68
79
  tonic-prost-build = { version = "0.14.2" }
package/build.rs CHANGED
@@ -69,6 +69,7 @@ fn generate_code(typ: ImplType, output_base: &Path) {
69
69
 
70
70
  println!("cargo:rerun-if-changed=./protos");
71
71
  println!("cargo:rerun-if-env-changed=CARGO_FEATURE_SERDE");
72
+ println!("cargo:rerun-if-env-changed=CARGO_FEATURE_TRANSPORT");
72
73
  println!("cargo:rerun-if-env-changed=CARGO_CFG_TARGET_ARCH");
73
74
  println!("cargo:rerun-if-env-changed=DAPI_GRPC_OUT_DIR");
74
75
  }
@@ -416,15 +417,23 @@ enum ImplType {
416
417
  impl ImplType {
417
418
  // Configure the builder based on the implementation type.
418
419
  pub fn configure(&self, builder: Builder) -> Builder {
420
+ // The `transport` cargo feature controls whether generated clients get
421
+ // the `connect()` convenience impls over tonic's own channel. Without
422
+ // it, clients are still generated but stay generic over the caller's
423
+ // transport. Never enabled for wasm32, where tonic transport does not
424
+ // build. Note: cfg!(target_arch) in a build script reflects the HOST,
425
+ // so the target must be read from CARGO_CFG_TARGET_ARCH.
426
+ let transport = std::env::var("CARGO_FEATURE_TRANSPORT").is_ok()
427
+ && std::env::var("CARGO_CFG_TARGET_ARCH").map(|arch| arch != "wasm32") == Ok(true);
419
428
  match self {
420
429
  Self::Server => builder
421
430
  .build_client(true)
422
431
  .build_server(true)
423
- .build_transport(true),
432
+ .build_transport(transport),
424
433
  Self::Client => builder
425
434
  .build_client(true)
426
435
  .build_server(false)
427
- .build_transport(true),
436
+ .build_transport(transport),
428
437
  Self::Wasm => builder
429
438
  .build_client(true)
430
439
  .build_server(false)