|
| 1 | +use core::cmp::{max, min, Ordering}; |
1 | 2 | use mina_p2p_messages::v2::{ |
2 | 3 | self, BlockTimeTimeStableV1, |
3 | 4 | ConsensusProofOfStakeDataConsensusStateValueStableV2 as MinaConsensusState, StateHash, |
@@ -196,8 +197,6 @@ pub fn is_short_range_fork(a: &MinaConsensusState, b: &MinaConsensusState) -> bo |
196 | 197 | /// See [Relative Minimum Window Density](https://github.com/MinaProtocol/mina/blob/compatible/docs/specs/consensus/README.md#5412-relative-minimum-window-density) |
197 | 198 | /// in the consensus specification for detailed mathematical definitions. |
198 | 199 | pub fn relative_min_window_density(b1: &MinaConsensusState, b2: &MinaConsensusState) -> u32 { |
199 | | - use std::cmp::{max, min}; |
200 | | - |
201 | 200 | let max_slot = max(global_slot(b1), global_slot(b2)); |
202 | 201 |
|
203 | 202 | if max_slot < GRACE_PERIOD_END { |
@@ -279,23 +278,22 @@ pub fn short_range_fork_take( |
279 | 278 | tip_hash: &StateHash, |
280 | 279 | candidate_hash: &StateHash, |
281 | 280 | ) -> (bool, ConsensusShortRangeForkDecisionReason) { |
282 | | - use std::cmp::Ordering::*; |
283 | 281 | use ConsensusShortRangeForkDecisionReason::*; |
284 | 282 |
|
285 | 283 | let tip_height = &tip_cs.blockchain_length; |
286 | 284 | let candidate_height = &candidate_cs.blockchain_length; |
287 | 285 | match candidate_height.cmp(tip_height) { |
288 | | - Greater => return (true, ChainLength), |
289 | | - Less => return (false, ChainLength), |
290 | | - Equal => {} |
| 286 | + Ordering::Greater => return (true, ChainLength), |
| 287 | + Ordering::Less => return (false, ChainLength), |
| 288 | + Ordering::Equal => {} |
291 | 289 | } |
292 | 290 |
|
293 | 291 | let tip_vrf = tip_cs.last_vrf_output.blake2b(); |
294 | 292 | let candidate_vrf = candidate_cs.last_vrf_output.blake2b(); |
295 | 293 | match candidate_vrf.cmp(&tip_vrf) { |
296 | | - Greater => return (true, Vrf), |
297 | | - Less => return (false, Vrf), |
298 | | - Equal => {} |
| 294 | + Ordering::Greater => return (true, Vrf), |
| 295 | + Ordering::Less => return (false, Vrf), |
| 296 | + Ordering::Equal => {} |
299 | 297 | } |
300 | 298 |
|
301 | 299 | (candidate_hash > tip_hash, StateHash) |
@@ -344,31 +342,30 @@ pub fn long_range_fork_take( |
344 | 342 | tip_hash: &StateHash, |
345 | 343 | candidate_hash: &StateHash, |
346 | 344 | ) -> (bool, ConsensusLongRangeForkDecisionReason) { |
347 | | - use std::cmp::Ordering::*; |
348 | 345 | use ConsensusLongRangeForkDecisionReason::*; |
349 | 346 |
|
350 | 347 | let tip_density = relative_min_window_density(tip_cs, candidate_cs); |
351 | 348 | let candidate_density = relative_min_window_density(candidate_cs, tip_cs); |
352 | 349 | match candidate_density.cmp(&tip_density) { |
353 | | - Greater => return (true, SubWindowDensity), |
354 | | - Less => return (false, SubWindowDensity), |
355 | | - Equal => {} |
| 350 | + Ordering::Greater => return (true, SubWindowDensity), |
| 351 | + Ordering::Less => return (false, SubWindowDensity), |
| 352 | + Ordering::Equal => {} |
356 | 353 | } |
357 | 354 |
|
358 | 355 | let tip_height = &tip_cs.blockchain_length; |
359 | 356 | let candidate_height = &candidate_cs.blockchain_length; |
360 | 357 | match candidate_height.cmp(tip_height) { |
361 | | - Greater => return (true, ChainLength), |
362 | | - Less => return (false, ChainLength), |
363 | | - Equal => {} |
| 358 | + Ordering::Greater => return (true, ChainLength), |
| 359 | + Ordering::Less => return (false, ChainLength), |
| 360 | + Ordering::Equal => {} |
364 | 361 | } |
365 | 362 |
|
366 | 363 | let tip_vrf = tip_cs.last_vrf_output.blake2b(); |
367 | 364 | let candidate_vrf = candidate_cs.last_vrf_output.blake2b(); |
368 | 365 | match candidate_vrf.cmp(&tip_vrf) { |
369 | | - Greater => return (true, Vrf), |
370 | | - Less => return (false, Vrf), |
371 | | - Equal => {} |
| 366 | + Ordering::Greater => return (true, Vrf), |
| 367 | + Ordering::Less => return (false, Vrf), |
| 368 | + Ordering::Equal => {} |
372 | 369 | } |
373 | 370 |
|
374 | 371 | (candidate_hash > tip_hash, StateHash) |
|
0 commit comments