Skip to content

Commit

Permalink
nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Krayt78 committed Nov 27, 2024
1 parent 047fb15 commit fccd816
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions polkadot/runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ impl<T: Config> Pallet<T> {
let mut outgoing_winner = Some((bidder.clone(), para, amount));
swap(&mut current_winning[range_index], &mut outgoing_winner);
if let Some((who, para, _amount)) = outgoing_winner {
if auction_status.is_starting()
&& current_winning
if auction_status.is_starting() &&
current_winning
.iter()
.filter_map(Option::as_ref)
.all(|&(ref other, other_para, _)| other != &who || other_para != para)
Expand Down Expand Up @@ -543,8 +543,8 @@ impl<T: Config> Pallet<T> {
&mut raw_offset.as_ref(),
)
.expect("secure hashes should always be bigger than the block number; qed");
let offset = (raw_offset_block_number % ending_period)
/ T::SampleLength::get().max(One::one());
let offset = (raw_offset_block_number % ending_period) /
T::SampleLength::get().max(One::one());

let auction_counter = AuctionCounter::<T>::get();
Self::deposit_event(Event::<T>::WinningOffset {
Expand Down Expand Up @@ -592,9 +592,9 @@ impl<T: Config> Pallet<T> {
let period_count = LeasePeriodOf::<T>::from(range.len() as u32);

match T::Leaser::lease_out(para, &leaser, amount, period_begin, period_count) {
Err(LeaseError::ReserveFailed)
| Err(LeaseError::AlreadyEnded)
| Err(LeaseError::NoLeasePeriod) => {
Err(LeaseError::ReserveFailed) |
Err(LeaseError::AlreadyEnded) |
Err(LeaseError::NoLeasePeriod) => {
// Should never happen since we just unreserved this amount (and our offset is
// from the present period). But if it does, there's not much we can do.
},
Expand Down Expand Up @@ -1872,14 +1872,15 @@ mod benchmarking {
bigger_amount,
);

// Confirms that we unreserved funds from a previous bidder, which is worst case scenario.
// Confirms that we unreserved funds from a previous bidder, which is worst case
// scenario.
assert_eq!(CurrencyOf::<T>::reserved_balance(&caller), bigger_amount);

Ok(())
}

// Worst case: 10 bidders taking all wining spots, and we need to calculate the winner for auction end.
// Entire winner map should be full and removed at the end of the benchmark.
// Worst case: 10 bidders taking all wining spots, and we need to calculate the winner for
// auction end. Entire winner map should be full and removed at the end of the benchmark.
#[benchmark]
fn on_initialize() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
Expand Down

0 comments on commit fccd816

Please sign in to comment.