bincode config fix
This commit is contained in:
parent
9c837bf6a8
commit
4e16176721
2 changed files with 12 additions and 1 deletions
|
@ -6,6 +6,10 @@
|
||||||
- performance improvement: internally `get_difficulty` was being called
|
- performance improvement: internally `get_difficulty` was being called
|
||||||
multiple times while generating `PoW`, now it calls only once.
|
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
|
## 0.2.0
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
@ -140,7 +140,14 @@ fn score(prefix_sha: Sha256, nonce: u64) -> u128 {
|
||||||
///
|
///
|
||||||
/// panics if inp.len() < 16
|
/// panics if inp.len() < 16
|
||||||
fn first_bytes_as_u128(inp: &[u8]) -> u128 {
|
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
|
// utility function to get u128 difficulty factor from u32
|
||||||
|
|
Loading…
Reference in a new issue