Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all optional compilation #16

Merged
merged 5 commits into from
Aug 18, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 15 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,32 @@ authors = [
circle-ci = { repository = "tendermint/kms" }

[dependencies]
byteorder = { version = "1.2", optional = true }
byteorder = { version = "1.2" }
bytes = "0.4"
chrono = { version = "0.4", features = ["serde"] }
digest = "0.8"
failure = "0.1"
hkdf = { version = "0.7", optional = true }
hyper = { version = "0.10", optional = true }
prost-amino = { version = "0.4.0", optional = true }
prost-amino-derive = { version = "0.4.0", optional = true }
rand_os = { version = "0.1", optional = true }
ring = { version = "0.14", optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
serde_json = { version = "1", optional = true }
hkdf = { version = "0.7" }
hyper = { version = "0.10" }
prost-amino = { version = "0.4.0" }
prost-amino-derive = { version = "0.4.0" }
rand_os = { version = "0.1" }
ring = { version = "0.14" }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
signatory = { version = "0.12", features = ["ed25519", "ecdsa"] }
signatory-dalek = { version = "0.12", optional = true }
signatory-dalek = { version = "0.12" }
sha2 = { version = "0.8", default-features = false }
subtle = "2"
subtle-encoding = { version = "0.3", features = ["bech32-preview"] }
tai64 = { version = "2", optional = true, features = ["chrono"] }
toml = { version = "0.5", optional = true }
uuid = { version = "0.7", optional = true, default-features = false }
x25519-dalek = { version = "0.5", optional = true, default-features = false, features = ["u64_backend"] }
zeroize = { version = "0.9", optional = true }
tai64 = { version = "2", features = ["chrono"] }
toml = { version = "0.5" }
uuid = { version = "0.7", default-features = false }
x25519-dalek = { version = "0.5", default-features = false, features = ["u64_backend"] }
zeroize = { version = "0.9" }

[dev-dependencies]
serde_json = "1"

[features]
default = ["serde", "tai64"]
amino-types = ["prost-amino", "prost-amino-derive"]
config = ["serde", "serde_json", "toml", "zeroize"]
keys = ["signatory-dalek"]
rpc = ["hyper", "rand_os", "serde", "serde_json", "uuid"]
secret-connection = [
"amino-types",
"byteorder",
"rand_os",
"hkdf",
"ring",
"signatory-dalek",
"x25519-dalek",
"zeroize"
]

[package.metadata.docs.rs]
all-features = true
10 changes: 0 additions & 10 deletions src/abci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,17 @@
//!
//! <https://github.com/tendermint/rust-abci>
#[cfg(feature = "rpc")]
mod code;
#[cfg(feature = "rpc")]
mod data;
#[cfg(feature = "rpc")]
mod gas;
#[cfg(feature = "rpc")]
mod info;
#[cfg(feature = "rpc")]
mod log;
#[cfg(feature = "rpc")]
mod path;
#[cfg(feature = "rpc")]
mod proof;
#[cfg(feature = "rpc")]
mod responses;
#[cfg(any(feature = "config", feature = "rpc"))]
pub mod tag;
pub mod transaction;

#[cfg(feature = "rpc")]
pub use self::{
code::Code, data::Data, gas::Gas, info::Info, log::Log, path::Path, proof::Proof,
responses::Responses, transaction::Transaction,
Expand Down
2 changes: 0 additions & 2 deletions src/abci/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ impl FromStr for Gas {
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for Gas {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(Self::from_str(&String::deserialize(deserializer)?)
.map_err(|e| D::Error::custom(format!("{}", e)))?)
}
}

#[cfg(feature = "serde")]
impl Serialize for Gas {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.to_string().serialize(serializer)
Expand Down
2 changes: 0 additions & 2 deletions src/abci/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "serde_json")]
use crate::{Error, ErrorKind};
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
Expand All @@ -9,7 +8,6 @@ pub struct Log(String);

impl Log {
/// Parse the log data as JSON, returning a `serde_json::Value`
#[cfg(feature = "serde_json")]
pub fn parse_json(&self) -> Result<serde_json::Value, Error> {
serde_json::from_str(&self.0).map_err(|_| ErrorKind::Parse.into())
}
Expand Down
6 changes: 1 addition & 5 deletions src/abci/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod hash;

pub use self::hash::Hash;
use std::slice;
#[cfg(feature = "serde")]
use {
serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer},
subtle_encoding::base64,
Expand Down Expand Up @@ -41,7 +40,6 @@ impl AsRef<[u8]> for Transaction {
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for Transaction {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let bytes = base64::decode(String::deserialize(deserializer)?.as_bytes())
Expand All @@ -51,7 +49,6 @@ impl<'de> Deserialize<'de> for Transaction {
}
}

#[cfg(feature = "serde")]
impl Serialize for Transaction {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
String::from_utf8(base64::encode(self.as_bytes()))
Expand All @@ -64,8 +61,7 @@ impl Serialize for Transaction {
/// transactions are arbitrary byte arrays.
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#data>
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug)]
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct Data {
txs: Option<Vec<Transaction>>,
}
Expand Down
3 changes: 0 additions & 3 deletions src/abci/transaction/hash.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Transaction hashes
use crate::error::{Error, ErrorKind};
#[cfg(feature = "serde")]
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::{
fmt::{self, Debug, Display},
Expand Down Expand Up @@ -77,7 +76,6 @@ impl FromStr for Hash {
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for Hash {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand All @@ -94,7 +92,6 @@ impl<'de> Deserialize<'de> for Hash {
}
}

#[cfg(feature = "serde")]
impl Serialize for Hash {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.to_string().serialize(serializer)
Expand Down
3 changes: 0 additions & 3 deletions src/account.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Tendermint accounts
use crate::error::{Error, ErrorKind};
#[cfg(feature = "serde")]
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use sha2::{Digest, Sha256};
use signatory::{ecdsa::curve::secp256k1, ed25519};
Expand Down Expand Up @@ -99,7 +98,6 @@ impl FromStr for Id {
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for Id {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand All @@ -116,7 +114,6 @@ impl<'de> Deserialize<'de> for Id {
}
}

#[cfg(feature = "serde")]
impl Serialize for Id {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.to_string().serialize(serializer)
Expand Down
4 changes: 1 addition & 3 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ pub use self::{
size::Size,
};
use crate::{abci::transaction, evidence};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Blocks consist of a header, transactions, votes (the commit), and a list of
/// evidence of malfeasance (i.e. signing conflicting votes).
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#block>
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug)]
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct Block {
/// Block header
pub header: Header,
Expand Down
7 changes: 2 additions & 5 deletions src/block/commit.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Commits to a Tendermint blockchain
use crate::{block, Vote};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{ops::Deref, slice};

/// Last commit to a particular blockchain: +2/3 precommit signatures.
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#lastcommit>
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct LastCommit {
/// Block ID of the last commit
pub block_id: block::Id,
Expand All @@ -19,8 +17,7 @@ pub struct LastCommit {
}

/// Precommits which certify that a block is valid
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Precommits(Option<Vec<Option<Vote>>>);

impl Precommits {
Expand Down
43 changes: 14 additions & 29 deletions src/block/header.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Block headers
use crate::{account, block, chain, Hash, Time};
#[cfg(feature = "serde")]
use {
crate::serializers,
serde::{Deserialize, Serialize},
Expand All @@ -12,8 +11,7 @@ use {
/// previous block, and the results returned by the application.
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#header>
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Header {
/// Header version
pub version: Version,
Expand All @@ -28,22 +26,16 @@ pub struct Header {
pub time: Time,

/// Number of transactions in block
#[cfg_attr(
feature = "serde",
serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)
#[serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)]
pub num_txs: u64,

/// Total number of transactions
#[cfg_attr(
feature = "serde",
serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)
#[serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)]
pub total_txs: u64,

Expand Down Expand Up @@ -82,26 +74,19 @@ pub struct Header {
/// application.
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#version>
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Version {
/// Block version
#[cfg_attr(
feature = "serde",
serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)
#[serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)]
pub block: u64,

/// App version
#[cfg_attr(
feature = "serde",
serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)
#[serde(
serialize_with = "serializers::serialize_u64",
deserialize_with = "serializers::parse_u64"
)]
pub app: u64,
}
3 changes: 0 additions & 3 deletions src/block/height.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::{Error, ErrorKind};
#[cfg(feature = "serde")]
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
use std::{
fmt::{self, Debug, Display},
Expand Down Expand Up @@ -90,15 +89,13 @@ impl FromStr for Height {
}
}

#[cfg(feature = "serde")]
impl<'de> Deserialize<'de> for Height {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
Ok(Self::from_str(&String::deserialize(deserializer)?)
.map_err(|e| D::Error::custom(format!("{}", e)))?)
}
}

#[cfg(feature = "serde")]
impl Serialize for Height {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.to_string().serialize(serializer)
Expand Down
4 changes: 1 addition & 3 deletions src/block/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{
error::Error,
hash::{Algorithm, Hash},
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::{
fmt::{self, Display},
Expand All @@ -17,8 +16,7 @@ pub const PREFIX_LENGTH: usize = 10;
/// as well as the number of parts in the block.
///
/// <https://github.com/tendermint/tendermint/blob/master/docs/spec/blockchain/blockchain.md#blockid>
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
pub struct Id {
/// The block's main hash is the Merkle root of all the fields in the
/// block header.
Expand Down
4 changes: 1 addition & 3 deletions src/block/meta.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//! Block metadata
use super::{Header, Id};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Block metadata
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Meta {
/// ID of the block
pub block_id: Id,
Expand Down
Loading