Skip to content

Commit

Permalink
fix(tenderdash-abci): ensure crate features build without default fea…
Browse files Browse the repository at this point in the history
…tures (#39)

* fix(tenderdash-abci): correct handling of features

* chore: change resolver in cargo.toml to 2

* fix: missing prost-derive feature in proto
  • Loading branch information
lklimek authored Oct 9, 2023
1 parent 2a98bf2 commit 32cff5c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]

resolver = "2"
members = ["abci", "proto-compiler", "proto"]
1 change: 1 addition & 0 deletions abci/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::io;
pub use application::{check_version, Application, RequestDispatcher};
use prost::{DecodeError, EncodeError};
#[allow(deprecated)]
#[cfg(feature = "server")]
pub use server::{start_server, CancellationToken, Server, ServerBuilder};
pub use tenderdash_proto as proto;

Expand Down
15 changes: 10 additions & 5 deletions abci/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
mod codec;
mod generic;

#[cfg(feature = "tcp")]
use std::{
net::{IpAddr, SocketAddr, SocketAddrV4, SocketAddrV6},
str::FromStr,
};

use tokio::{
net::{TcpListener, UnixListener},
runtime::{Handle, Runtime},
};
#[cfg(feature = "tcp")]
use tokio::net::TcpListener;
#[cfg(feature = "unix")]
use tokio::net::UnixListener;
use tokio::runtime::{Handle, Runtime};
pub use tokio_util::sync::CancellationToken;

use self::generic::GenericServer;
use crate::{application::RequestDispatcher, Error};

#[cfg(not(any(feature = "tcp", feature = "unix")))]
compile_error!("At least one of `tcp` or `unix` features must be enabled");

/// ABCI Server handle.
///
/// Use [`Server::handle_connection()`] to accept connection and process all
Expand Down Expand Up @@ -247,7 +252,7 @@ where
{
ServerBuilder::new(app, bind_address.as_ref()).build()
}

#[cfg(feature = "tcp")]
fn parse_tcp_uri(uri: url::Url) -> SocketAddr {
let host = uri.host_str().unwrap();
// remove '[' and ']' from ipv6 address, as per https://github.com/servo/rust-url/issues/770
Expand Down
16 changes: 10 additions & 6 deletions abci/src/server/generic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
//! Generic ABCI server
#[cfg(feature = "tcp")]
use std::net::ToSocketAddrs;
use std::{fmt::Debug, sync::Arc};
#[cfg(feature = "unix")]
use std::{fs, path::Path};

use std::{fmt::Debug, fs, net::ToSocketAddrs, path::Path, sync::Arc};

use tokio::{
net::{TcpListener, UnixListener},
sync::Mutex,
};
#[cfg(feature = "tcp")]
use tokio::net::TcpListener;
#[cfg(feature = "unix")]
use tokio::net::UnixListener;
use tokio::sync::Mutex;
use tokio_util::net::Listener;
use tracing::info;

Expand Down
4 changes: 3 additions & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ description = """
all-features = true

[dependencies]
prost = { version = "0.12", default-features = false }
prost = { version = "0.12", default-features = false, features = [
"prost-derive",
] }
bytes = { version = "1.0", default-features = false, features = ["serde"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
subtle-encoding = { version = "0.5", default-features = false, features = [
Expand Down

0 comments on commit 32cff5c

Please sign in to comment.