diff --git a/CHANGELOG.md b/CHANGELOG.md index 02feb41..a7ecb32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - performance improvement: internally `get_difficulty` was being called multiple times while generating `PoW`, now it calls only once. +### Fixed +- encoding and decoding configuration used internally was causing an + error in `PoW` computation + ## 0.2.0 ### Changed diff --git a/src/lib.rs b/src/lib.rs index d7256b0..0635cb3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,7 +140,14 @@ fn score(prefix_sha: Sha256, nonce: u64) -> u128 { /// /// panics if inp.len() < 16 fn first_bytes_as_u128(inp: &[u8]) -> u128 { - bincode::deserialize(&inp).unwrap() + use bincode::config::*; + DefaultOptions::new() + .with_fixint_encoding() + .allow_trailing_bytes() + .with_no_limit() + .with_big_endian() + .deserialize(&inp) + .unwrap() } // utility function to get u128 difficulty factor from u32