bincode config fix

This commit is contained in:
Aravinth Manivannan 2021-04-01 22:45:48 +05:30
parent 9c837bf6a8
commit 4e16176721
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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