diff --git a/CHANGELOG.md b/CHANGELOG.md index 20cd863..02feb41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,18 @@ # Changelog +## 0.2.1 + +### Changed +- performance improvement: internally `get_difficulty` was being called + multiple times while generating `PoW`, now it calls only once. + +## 0.2.0 + +### Changed +- Difficulty factor is now an unsigned 32 bit number + ## 0.1 + +### Added: - PoW constructor - unique salt - -## 0.2 -- Difficulty factor is now an unsigned 32 bit number diff --git a/Cargo.lock b/Cargo.lock index 8ece04e..f92283f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pow_sha256" -version = "0.2.0" +version = "0.2.1" dependencies = [ "bincode", "derive_builder", diff --git a/Cargo.toml b/Cargo.toml index 1b71c7d..0197f09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pow_sha256" -version = "0.2.0" +version = "0.2.1" authors = [ "Aravinth Manivannan ", "Robert Kornacki "] description = """ SHA256 PoW on any serializable datatype used in mCaptcha diff --git a/src/lib.rs b/src/lib.rs index 6c662e2..d7256b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,7 +69,8 @@ impl Config { let prefix_sha = Sha256::new().chain(&self.salt).chain(prefix); let mut n = 0; let mut result = 0; - while result < get_difficulty(difficulty) { + let difficulty = get_difficulty(difficulty); + while result < difficulty { n += 1; result = score(prefix_sha.clone(), n); }