mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Remove potentially-failing unchecked arithmetic operations for ones which error
In response to 9.13.3. Requires a bump to Rust 1.82 to take advantage of `Option::is_none_or`.
This commit is contained in:
@@ -166,7 +166,14 @@ impl Decoys {
|
||||
/// `offsets` are the positions of each ring member within the Monero blockchain, offset from the
|
||||
/// prior member's position (with the initial ring member offset from 0).
|
||||
pub fn new(offsets: Vec<u64>, signer_index: u8, ring: Vec<[EdwardsPoint; 2]>) -> Option<Self> {
|
||||
if (offsets.len() != ring.len()) || (usize::from(signer_index) >= ring.len()) {
|
||||
if (offsets.len() > usize::from(u8::MAX)) ||
|
||||
(offsets.len() != ring.len()) ||
|
||||
(usize::from(signer_index) >= ring.len())
|
||||
{
|
||||
None?;
|
||||
}
|
||||
// Check these offsets form representable positions
|
||||
if offsets.iter().copied().try_fold(0, u64::checked_add).is_none() {
|
||||
None?;
|
||||
}
|
||||
Some(Decoys { offsets, signer_index, ring })
|
||||
|
||||
Reference in New Issue
Block a user