Skip to content

Commit

Permalink
chore(deps): upgrade uint to 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Nov 28, 2024
1 parent 0d890fd commit 71a55bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ libp2p-identity = { workspace = true, features = ["rand"] }
rand = "0.8"
sha2 = "0.10.8"
smallvec = "1.13.2"
uint = "0.9"
uint = "0.10"
futures-timer = "3.0.3"
web-time = { workspace = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl BucketIndex {
let lower = usize::pow(2, rem);
let upper = usize::pow(2, rem + 1);
bytes[31 - quot] = rng.gen_range(lower..upper) as u8;
Distance(U256::from(bytes))
Distance(U256::from_big_endian(bytes.as_slice()))
}
}

Expand Down Expand Up @@ -651,7 +651,7 @@ mod tests {
fn rand_distance() {
fn prop(ix: u8) -> bool {
let d = BucketIndex(ix as usize).rand_distance(&mut rand::thread_rng());
let n = U256::from(<[u8; 32]>::from(d.0));
let n = d.0;
let b = U256::from(2);
let e = U256::from(ix);
let lower = b.pow(e);
Expand Down
8 changes: 4 additions & 4 deletions protocols/kad/src/kbucket/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ impl KeyBytes {
where
U: AsRef<KeyBytes>,
{
let a = U256::from(self.0.as_slice());
let b = U256::from(other.as_ref().0.as_slice());
let a = U256::from_big_endian(self.0.as_slice());
let b = U256::from_big_endian(other.as_ref().0.as_slice());
Distance(a ^ b)
}

Expand All @@ -174,8 +174,8 @@ impl KeyBytes {
///
/// `self xor other = distance <==> other = self xor distance`
pub fn for_distance(&self, d: Distance) -> KeyBytes {
let key_int = U256::from(self.0.as_slice()) ^ d.0;
KeyBytes(GenericArray::from(<[u8; 32]>::from(key_int)))
let key_int = U256::from_big_endian(self.0.as_slice()) ^ d.0;
KeyBytes(GenericArray::from(key_int.to_big_endian()))
}
}

Expand Down

0 comments on commit 71a55bd

Please sign in to comment.