mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
chore: reduce copy times for bytes in core-hashing (#13519)
* chore: reduce copy bytes for core-hashing * improve by suggestions and remove unused `xx_into` * chore: replace sha2 crate by `sp_core::hashing` for pallet-alliance * fix features * use sp-core-hashing directly * add to dev-dep
This commit is contained in:
@@ -14,7 +14,6 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
array-bytes = { version = "4.1", optional = true }
|
||||
sha2 = { version = "0.10.1", default-features = false, optional = true }
|
||||
log = { version = "0.4.14", default-features = false }
|
||||
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
@@ -22,6 +21,7 @@ scale-info = { version = "2.0.1", default-features = false, features = ["derive"
|
||||
|
||||
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
|
||||
sp-core-hashing = { version = "5.0.0", default-features = false, path = "../../primitives/core/hashing", optional = true }
|
||||
sp-io = { version = "7.0.0", default-features = false, path = "../../primitives/io" }
|
||||
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
|
||||
|
||||
@@ -34,13 +34,14 @@ pallet-collective = { version = "4.0.0-dev", path = "../collective", default-fea
|
||||
|
||||
[dev-dependencies]
|
||||
array-bytes = "4.1"
|
||||
sha2 = "0.10.1"
|
||||
sp-core-hashing = { version = "5.0.0", default-features = false, path = "../../primitives/core/hashing" }
|
||||
pallet-balances = { version = "4.0.0-dev", path = "../balances" }
|
||||
pallet-collective = { version = "4.0.0-dev", path = "../collective" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"sp-core-hashing?/std",
|
||||
"pallet-collective?/std",
|
||||
"frame-benchmarking?/std",
|
||||
"log/std",
|
||||
@@ -56,7 +57,7 @@ std = [
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"array-bytes",
|
||||
"sha2",
|
||||
"sp-core-hashing",
|
||||
"frame-benchmarking/runtime-benchmarks",
|
||||
"sp-runtime/runtime-benchmarks",
|
||||
"frame-support/runtime-benchmarks",
|
||||
|
||||
@@ -40,11 +40,8 @@ fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::
|
||||
}
|
||||
|
||||
fn cid(input: impl AsRef<[u8]>) -> Cid {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(input);
|
||||
let result = hasher.finalize();
|
||||
Cid::new_v0(&*result)
|
||||
let result = sp_core_hashing::sha2_256(input.as_ref());
|
||||
Cid::new_v0(result)
|
||||
}
|
||||
|
||||
fn rule(input: impl AsRef<[u8]>) -> Cid {
|
||||
|
||||
@@ -368,11 +368,8 @@ pub fn new_bench_ext() -> sp_io::TestExternalities {
|
||||
}
|
||||
|
||||
pub fn test_cid() -> Cid {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
hasher.update(b"hello world");
|
||||
let result = hasher.finalize();
|
||||
Cid::new_v0(&*result)
|
||||
let result = sp_core_hashing::sha2_256(b"hello world");
|
||||
Cid::new_v0(result)
|
||||
}
|
||||
|
||||
pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32, H256) {
|
||||
|
||||
Reference in New Issue
Block a user