Skip to content

Commit 524afb4

Browse files
authored
chore(deps): upgrade uint to 0.10
This PR upgrade `uint` to `0.10` https://github.com/paritytech/parity-common/blob/master/uint/CHANGELOG.md#0100---2024-09-11 (Skipping changelog as there's no changes in public APIs) Pull-Request: #5699.
1 parent 1e9bb4c commit 524afb4

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocols/kad/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ libp2p-identity = { workspace = true, features = ["rand"] }
2626
rand = "0.8"
2727
sha2 = "0.10.8"
2828
smallvec = "1.13.2"
29-
uint = "0.9"
29+
uint = "0.10"
3030
futures-timer = "3.0.3"
3131
web-time = { workspace = true }
3232
serde = { version = "1.0", optional = true, features = ["derive"] }

protocols/kad/src/kbucket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl BucketIndex {
175175
let lower = usize::pow(2, rem);
176176
let upper = usize::pow(2, rem + 1);
177177
bytes[31 - quot] = rng.gen_range(lower..upper) as u8;
178-
Distance(U256::from(bytes))
178+
Distance(U256::from_big_endian(bytes.as_slice()))
179179
}
180180
}
181181

@@ -650,7 +650,7 @@ mod tests {
650650
fn rand_distance() {
651651
fn prop(ix: u8) -> bool {
652652
let d = BucketIndex(ix as usize).rand_distance(&mut rand::thread_rng());
653-
let n = U256::from(<[u8; 32]>::from(d.0));
653+
let n = d.0;
654654
let b = U256::from(2);
655655
let e = U256::from(ix);
656656
let lower = b.pow(e);

protocols/kad/src/kbucket/key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ impl KeyBytes {
169169
where
170170
U: AsRef<KeyBytes>,
171171
{
172-
let a = U256::from(self.0.as_slice());
173-
let b = U256::from(other.as_ref().0.as_slice());
172+
let a = U256::from_big_endian(self.0.as_slice());
173+
let b = U256::from_big_endian(other.as_ref().0.as_slice());
174174
Distance(a ^ b)
175175
}
176176

@@ -180,8 +180,8 @@ impl KeyBytes {
180180
///
181181
/// `self xor other = distance <==> other = self xor distance`
182182
pub fn for_distance(&self, d: Distance) -> KeyBytes {
183-
let key_int = U256::from(self.0.as_slice()) ^ d.0;
184-
KeyBytes(GenericArray::from(<[u8; 32]>::from(key_int)))
183+
let key_int = U256::from_big_endian(self.0.as_slice()) ^ d.0;
184+
KeyBytes(GenericArray::from(key_int.to_big_endian()))
185185
}
186186
}
187187

0 commit comments

Comments
 (0)