]> Untitled Git - bdk/commitdiff
Improve feature combinations for ureq/reqwest
authorTobin Harding <me@tobin.cc>
Wed, 28 Jul 2021 23:39:36 +0000 (09:39 +1000)
committerTobin Harding <me@tobin.cc>
Thu, 29 Jul 2021 00:12:17 +0000 (10:12 +1000)
Our features are a bit convoluted, most annoyingly we cannot build with
`--all-features`. However we can make life for users a little easier.

Explicitly we want users to be able to:

- Use async-interface/WASM without using esplora (to implement their own blockchain)
- Use esplora in an ergonomic manner

Currently using esplora requires either reqwest or ureq. Instead of
making the user add all the features manually we can add features that
add the required feature sets, this makes it easier for users to
understand what is required and also makes usage easier.

With this patch applied we can do

- `cargo check --no-default-features --features=use-esplora-reqwest`
- `cargo check --no-default-features --features=use-esplora-ureq`
- `cargo check --features=use-esplora-ureq`
- `cargo check --no-default-features --features=async-trait`

.github/workflows/cont_integration.yml
Cargo.toml
src/lib.rs

index 35101517a0805757533c833e7c8cb92418b77a98..aa03c86524435d354b3f2bb8eec4bfd13f02d7b9 100644 (file)
@@ -16,7 +16,7 @@ jobs:
           - default
           - minimal
           - all-keys
-          - minimal,esplora,ureq
+          - minimal,use-esplora-ureq
           - key-value-db
           - electrum
           - compact_filters
@@ -25,7 +25,7 @@ jobs:
           - rpc
           - verify
           - async-interface
-          - async-interface,esplora,reqwest
+          - use-esplora-reqwest
     steps:
       - name: checkout
         uses: actions/checkout@v2
@@ -139,7 +139,7 @@ jobs:
       - name: Update toolchain
         run: rustup update
       - name: Check
-        run: cargo check --target wasm32-unknown-unknown --features esplora,reqwest --no-default-features
+        run: cargo check --target wasm32-unknown-unknown --features use-esplora-reqwest --no-default-features
 
 
   fmt:
index f8caafbf3a1c604a31ef22f5fd9bc2d8e0d15d00..fd3c5a91834ca828a0b73ec5ee08f8b1a807a7ff 100644 (file)
@@ -60,13 +60,20 @@ rpc = ["bitcoincore-rpc"]
 #
 # - Users wanting asynchronous HTTP calls should enable `async-interface` to get
 #   access to the asynchronous method implementations. Then, if Esplora is wanted,
-#   enable `esplora` AND `reqwest`.
+#   enable `esplora` AND `reqwest` (`--features=use-esplora-reqwest`).
 # - Users wanting blocking HTTP calls can use any of the other blockchain
 #   implementations (`compact_filters`, `electrum`, or `esplora`). Users wanting to
-#   use Esplora should enable `esplora` AND `ureq`.
+#   use Esplora should enable `esplora` AND `ureq`  (`--features=use-esplora-ureq`).
+#
+# WARNING: Please take care with the features below, various combinations will
+# fail to build. We cannot currently build `bdk` with `--all-features`.
 async-interface = ["async-trait"]
 electrum = ["electrum-client"]
-esplora = ["futures"]           # Requires one of: `ureq` or `reqwest`.
+# MUST ALSO USE `--no-default-features`.
+use-esplora-reqwest = ["async-interface", "esplora", "reqwest", "futures"]
+use-esplora-ureq = ["esplora", "ureq"]
+# Typical configurations will not need to use `esplora` feature directly.
+esplora = []
 
 
 # Debug/Test features
index 0d0c3e9c5dc6d9cfff710a7df35f53fb69bc380c..0a7d61b3774fff26df76e355fbf0a4608d8775d6 100644 (file)
@@ -223,9 +223,6 @@ compile_error!(
     "Features async-interface and compact_filters are mutually exclusive and cannot be enabled together"
 );
 
-#[cfg(all(feature = "esplora", not(feature = "ureq"), not(feature = "reqwest")))]
-compile_error!("Feature missing: esplora requires either ureq or reqwest to be enabled");
-
 #[cfg(feature = "keys-bip39")]
 extern crate bip39;