fn add_price(who: T::AccountId, price: u32) {
		log::info!("Adding to the average: {}", price);
		<Prices<T>>::mutate(|prices| {
			const MAX_LEN: usize = 64;

			if prices.len() < MAX_LEN {
				prices.push(price);
			} else {
				prices[price as usize % MAX_LEN] = price;
			}
		});

		let average = Self::average_price()
			.expect("The average is not empty, because it was just mutated; qed");
		log::info!("Current average price is: {}", average);
		// here we are raising the NewPrice event
		Self::deposit_event(Event::NewPrice(price, who));
	}
/// Add new price to the list.
Add new price to the list.
Add new price to the list .
fn add_price(who: T::AccountId, price: u32) {
		log::info!("Adding to the average: {}", price);
		<Prices<T>>::mutate(|prices| {
			const MAX_LEN: usize = 64;
			if prices.len() < MAX_LEN {
				prices.push(price);
			} else {
				prices[price as usize % MAX_LEN] = price;
			}
		});
		let average = Self::average_price()
			.expect("The average is not empty, because it was just mutated; qed");
		log::info!("Current average price is: {}", average);
		// here we are raising the NewPrice event
		Self::deposit_event(Event::NewPrice(price, who));
	}
fn add_price ( who : T :: AccountId , price : u32 ) { log :: info ! ( " " price ) ; < Prices < T > > :: mutate ( | prices | { const MAX_LEN : usize = 64 ; if prices . len ( ) < MAX_LEN { prices . push ( price ) ; } else { prices [ price as usize % MAX_LEN ] = price ; } } ) ; let average = Self :: average_price ( ) . expect ( " " ) ; log :: info ! ( " " average ) ; // here we are raising the NewPrice event Self :: deposit_event ( Event :: NewPrice ( price , who ) ) ; }
Add new price to the list.
Add new price to the list .
who
T::AccountId
price
u32