Skip to content

Commit 1d810a5

Browse files
committed
Use u64 for required_unknown_bits_from indexes, not usize
While `usize` should be fine, we're multiplying the index by 8 so if we have a jumbo feature bit fitting in a 32-bit size type may not quite work. More importantly, this would be the first use of a `usize` in the public API and dealing with it in bindings is annoying so we just replace with a `u64`.
1 parent 1122e82 commit 1d810a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning-types/src/features.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ impl<T: sealed::Context> Features<T> {
911911
}
912912

913913
/// Returns the set of required features unknown by `other`, as their bit position.
914-
pub fn required_unknown_bits_from(&self, other: &Self) -> Vec<usize> {
914+
pub fn required_unknown_bits_from(&self, other: &Self) -> Vec<u64> {
915915
let mut unknown_bits = Vec::new();
916916

917917
// Bitwise AND-ing with all even bits set except for known features will select required
@@ -921,7 +921,7 @@ impl<T: sealed::Context> Features<T> {
921921
if byte & unknown_features != 0 {
922922
for bit in (0..8).step_by(2) {
923923
if ((byte & unknown_features) >> bit) & 1 == 1 {
924-
unknown_bits.push(i * 8 + bit);
924+
unknown_bits.push((i as u64) * 8 + bit);
925925
}
926926
}
927927
}

0 commit comments

Comments
 (0)