Преглед изворни кода

make [btc] feature optional and the default one & enable [sol] as optional feature

ghassmo пре 4 година
родитељ
комит
df97ccf8fb
2 измењених фајлова са 7 додато и 6 уклоњено
  1. 4 6
      Cargo.toml
  2. 3 0
      src/error.rs

+ 4 - 6
Cargo.toml

@@ -88,19 +88,17 @@ tokio-tungstenite = {version = "0.15.0", optional = true}
 tokio = {version = "1.11.0", features = ["full"], optional = true}
 tokio = {version = "1.11.0", features = ["full"], optional = true}
 
 
 ## Cashier Bitcoin Dependencies
 ## Cashier Bitcoin Dependencies
-# TODO: Make optional, cashier should have "features" to enable different chains
-# See https://doc.rust-lang.org/cargo/reference/features.html
-bitcoin = {version = "0.27.0", optional = false }
-secp256k1 = {version = "0.20.3", optional = false }
-electrum-client = {version = "0.8.0", optional = false }
+bitcoin = {version = "0.27.0", optional = true }
+secp256k1 = {version = "0.20.3", optional = true}
+electrum-client = {version = "0.8.0", optional = true }
 
 
 [dependencies.rusqlite]
 [dependencies.rusqlite]
 version = "0.25.1"
 version = "0.25.1"
 features = ["bundled", "sqlcipher"]
 features = ["bundled", "sqlcipher"]
 
 
 [features]
 [features]
+default = ["bitcoin", "secp256k1", "electrum-client"]
 sol = ["solana-sdk", "solana-client", "tokio-tungstenite", "tokio"]
 sol = ["solana-sdk", "solana-client", "tokio-tungstenite", "tokio"]
-#btc = ["bitcoin", "secp256k1", "electrum-client"]
 
 
 [[bin]]
 [[bin]]
 name = "lisp"
 name = "lisp"

+ 3 - 0
src/error.rs

@@ -42,6 +42,7 @@ pub enum Error {
     ZmqError(String),
     ZmqError(String),
     VerifyFailed,
     VerifyFailed,
     ClientFailed(String),
     ClientFailed(String),
+    #[cfg(feature = "default")]
     BtcFailed(String),
     BtcFailed(String),
     TryIntoError,
     TryIntoError,
     TryFromError,
     TryFromError,
@@ -94,6 +95,7 @@ impl fmt::Display for Error {
             Error::ZmqError(ref err) => write!(f, "ZmqError: {}", err),
             Error::ZmqError(ref err) => write!(f, "ZmqError: {}", err),
             Error::VerifyFailed => f.write_str("Verify failed"),
             Error::VerifyFailed => f.write_str("Verify failed"),
             Error::ClientFailed(ref err) => write!(f, "Client failed: {}", err),
             Error::ClientFailed(ref err) => write!(f, "Client failed: {}", err),
+            #[cfg(feature = "default")]
             Error::BtcFailed(ref err) => write!(f, "Btc client failed: {}", err),
             Error::BtcFailed(ref err) => write!(f, "Btc client failed: {}", err),
             Error::TryIntoError => f.write_str("TryInto error"),
             Error::TryIntoError => f.write_str("TryInto error"),
             Error::TryFromError => f.write_str("TryFrom error"),
             Error::TryFromError => f.write_str("TryFrom error"),
@@ -217,6 +219,7 @@ impl From<client::ClientFailed> for Error {
     }
     }
 }
 }
 
 
+#[cfg(feature = "default")]
 impl From<crate::service::BtcFailed> for Error {
 impl From<crate::service::BtcFailed> for Error {
     fn from(err: crate::service::BtcFailed) -> Error {
     fn from(err: crate::service::BtcFailed) -> Error {
         Error::BtcFailed(err.to_string())
         Error::BtcFailed(err.to_string())