diff --git a/Makefile b/Makefile index 0946b85fa3..dd834bb408 100644 --- a/Makefile +++ b/Makefile @@ -204,13 +204,17 @@ bench-test: .PHONY: ci ci: ## Run recipes for CI. -ci: fmt clippy test bench-test check-cargotoml check-whitespaces check-dirty-rpc-doc security-audit check-crates check-licenses +ci: fmt clippy test bench-test check-cargo-metadata check-cargotoml check-whitespaces check-dirty-rpc-doc security-audit check-crates check-licenses git diff --exit-code Cargo.lock .PHONY: check-cargotoml check-cargotoml: ./devtools/ci/check-cargotoml.sh +.PHONY: check-cargo-metadata +check-cargo-metadata: ## Check cargo metadata is success + cargo metadata --format-version 1 --all-features --manifest-path ./Cargo.toml &> /dev/null + .PHONY: check-whitespace check-whitespaces: git -c core.whitespace=-blank-at-eof diff-index --check --cached $$(git rev-parse --verify master 2>/dev/null || echo "4b825dc642cb6eb9a060e54bf8d69288fbee4904") -- diff --git a/util/hash/Cargo.toml b/util/hash/Cargo.toml index 21bd1a3e60..9cad6007c5 100644 --- a/util/hash/Cargo.toml +++ b/util/hash/Cargo.toml @@ -9,14 +9,14 @@ homepage = "https://github.com/nervosnetwork/ckb" repository = "https://github.com/nervosnetwork/ckb" [features] -default = ["blake2b"] +default = ["blake2b-ref", "blake2b-rs"] ckb-contract = ["blake2b-ref"] # This feature is used for CKB contract development [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -blake2b = { package = "blake2b-rs", version = "0.2", optional = true } +blake2b-rs = { version = "0.2", optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -blake2b = { package = "blake2b-ref", version = "0.3", optional = true } +blake2b-ref = { version = "0.3", optional = true } [dependencies] -blake2b-ref = { version = "0.3", optional = true } \ No newline at end of file +blake2b-ref = { version = "0.3", optional = true } diff --git a/util/hash/src/lib.rs b/util/hash/src/lib.rs index 651e3168bb..b988f041f5 100644 --- a/util/hash/src/lib.rs +++ b/util/hash/src/lib.rs @@ -9,11 +9,15 @@ #![no_std] -#[cfg(feature = "default")] -pub use blake2b::{Blake2b, Blake2bBuilder}; #[cfg(feature = "ckb-contract")] pub use blake2b_ref::{Blake2b, Blake2bBuilder}; +#[cfg(all(not(feature = "ckb-contract"), target_arch = "wasm32"))] +pub use blake2b_ref::{Blake2b, Blake2bBuilder}; + +#[cfg(all(not(feature = "ckb-contract"), not(target_arch = "wasm32")))] +pub use blake2b_rs::{Blake2b, Blake2bBuilder}; + #[doc(hidden)] pub const BLAKE2B_KEY: &[u8] = &[]; /// Output digest size.