Skip to content

Commit 6f56c2e

Browse files
authored
Merge pull request #7 from G8XSU/use-bytes
Use Bytes instead of Vec<u8> in generated protos.
2 parents af08f03 + f4b87d4 commit 6f56c2e

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

protos/build.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ fn main() {
1212

1313
#[cfg(genproto)]
1414
fn generate_protos() {
15-
prost_build::compile_protos(&["src/proto/ldk_node_server.proto"], &["src/"])
15+
prost_build::Config::new()
16+
.bytes(&["."])
17+
.compile_protos(&["src/proto/ldk_node_server.proto"], &["src/"])
1618
.expect("protobuf compilation failed");
17-
println!("sss {}", &env::var("OUT_DIR").unwrap());
19+
println!("OUT_DIR: {}", &env::var("OUT_DIR").unwrap());
1820
let from_path = Path::new(&env::var("OUT_DIR").unwrap()).join("ldk_node_server.rs");
1921
fs::copy(from_path, "src/lib.rs").unwrap();
2022
}

protos/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ pub struct Bolt11SendResponse {
9494
#[allow(clippy::derive_partial_eq_without_eq)]
9595
#[derive(Clone, PartialEq, ::prost::Message)]
9696
pub struct PaymentId {
97-
#[prost(bytes = "vec", tag = "1")]
98-
pub data: ::prost::alloc::vec::Vec<u8>,
97+
#[prost(bytes = "bytes", tag = "1")]
98+
pub data: ::prost::bytes::Bytes,
9999
}
100100
/// Returns a BOLT12 offer for the given amount, if specified.
101101
///
@@ -180,8 +180,8 @@ pub struct OpenChannelRequest {
180180
#[derive(Clone, PartialEq, ::prost::Message)]
181181
pub struct OpenChannelResponse {
182182
/// The channel id of the created channel that user can use to refer to channel.
183-
#[prost(bytes = "vec", tag = "1")]
184-
pub user_channel_id: ::prost::alloc::vec::Vec<u8>,
183+
#[prost(bytes = "bytes", tag = "1")]
184+
pub user_channel_id: ::prost::bytes::Bytes,
185185
}
186186
/// ChannelConfig represents the configuration settings for a channel in a Lightning Network node.
187187
/// See more: <https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html>
@@ -249,14 +249,14 @@ pub mod channel_config {
249249
#[derive(Clone, PartialEq, ::prost::Message)]
250250
pub struct CloseChannelRequest {
251251
/// The channel id of the created channel that user can use to refer to channel.
252-
#[prost(bytes = "vec", tag = "1")]
253-
pub user_channel_id: ::prost::alloc::vec::Vec<u8>,
252+
#[prost(bytes = "bytes", tag = "1")]
253+
pub user_channel_id: ::prost::bytes::Bytes,
254254
/// The hex-encoded public key of the node to close a channel with.
255255
#[prost(string, tag = "2")]
256256
pub counterparty_node_id: ::prost::alloc::string::String,
257257
/// Whether to force close the specified channel.
258-
#[prost(bool, tag = "3")]
259-
pub force_close: bool,
258+
#[prost(bool, optional, tag = "3")]
259+
pub force_close: ::core::option::Option<bool>,
260260
}
261261
#[allow(clippy::derive_partial_eq_without_eq)]
262262
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -290,10 +290,10 @@ pub struct Channel {
290290
/// The channel's funding transaction output, if we've negotiated the funding transaction with
291291
/// our counterparty already.
292292
#[prost(message, optional, tag = "3")]
293-
pub funding_txo: ::core::option::Option<Outpoint>,
293+
pub funding_txo: ::core::option::Option<OutPoint>,
294294
/// The local `user_channel_id` of this channel.
295-
#[prost(bytes = "vec", tag = "4")]
296-
pub user_channel_id: ::prost::alloc::vec::Vec<u8>,
295+
#[prost(bytes = "bytes", tag = "4")]
296+
pub user_channel_id: ::prost::bytes::Bytes,
297297
/// The value, in satoshis, that must always be held as a reserve in the channel for us. This
298298
/// value ensures that if we broadcast a revoked state, our counterparty can punish us by
299299
/// claiming at least this value on chain.
@@ -406,7 +406,7 @@ pub struct Channel {
406406
/// Represent a transaction outpoint.
407407
#[allow(clippy::derive_partial_eq_without_eq)]
408408
#[derive(Clone, PartialEq, ::prost::Message)]
409-
pub struct Outpoint {
409+
pub struct OutPoint {
410410
/// The referenced transaction's txid.
411411
#[prost(string, tag = "1")]
412412
pub txid: ::prost::alloc::string::String,

0 commit comments

Comments
 (0)