Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): upgrade uint to 0.10 #5699

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -175,7 +175,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 @@ -650,7 +650,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 @@ -169,8 +169,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 @@ -180,8 +180,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