pub fn stop_mining(miner: T::AccountId) -> DispatchResult {
			let worker = MinerBindings::<T>::get(&miner).ok_or(Error::<T>::MinerNotBound)?;
			let mut miner_info = Miners::<T>::get(&miner).ok_or(Error::<T>::MinerNotFound)?;

			ensure!(
				miner_info.state != MinerState::Ready
					&& miner_info.state != MinerState::MiningCoolingDown,
				Error::<T>::MinerNotMining
			);

			let now = Self::now_sec();
			miner_info.state = MinerState::MiningCoolingDown;
			miner_info.cool_down_start = now;
			Miners::<T>::insert(&miner, &miner_info);
			OnlineMiners::<T>::mutate(|v| *v -= 1); // v cannot be 0

			// Calcualte remaining stake (assume there's no more slash after calling `stop_mining`)
			let orig_stake = Stakes::<T>::get(&miner).unwrap_or_default();
			let (_returned, slashed) = miner_info.calc_final_stake(orig_stake);
			// Notify the subscriber with the slash prediction
			T::OnStopped::on_stopped(&worker, orig_stake, slashed);

			Self::push_message(SystemEvent::new_worker_event(
				worker,
				WorkerEvent::MiningStop,
			));
			Self::deposit_event(Event::<T>::MinerStopped(miner));
			Ok(())
		}
/// Stops mining, enterying cool down state
///
/// Requires:
/// 1. Ther miner is in Idle, MiningActive, or MiningUnresponsive state
Stops mining, enterying cool down state
Requires:
1. Ther miner is in Idle, MiningActive, or MiningUnresponsive state
Stops mining enterying cool down state Requires : 1 . Ther miner is in Idle MiningActive or MiningUnresponsive state
pub fn stop_mining(miner: T::AccountId) -> DispatchResult {
			let worker = MinerBindings::<T>::get(&miner).ok_or(Error::<T>::MinerNotBound)?;
			let mut miner_info = Miners::<T>::get(&miner).ok_or(Error::<T>::MinerNotFound)?;
			ensure!(
				miner_info.state != MinerState::Ready
					&& miner_info.state != MinerState::MiningCoolingDown,
				Error::<T>::MinerNotMining
			);
			let now = Self::now_sec();
			miner_info.state = MinerState::MiningCoolingDown;
			miner_info.cool_down_start = now;
			Miners::<T>::insert(&miner, &miner_info);
			OnlineMiners::<T>::mutate(|v| *v -= 1); // v cannot be 0
			// Calcualte remaining stake (assume there's no more slash after calling `stop_mining`)
			let orig_stake = Stakes::<T>::get(&miner).unwrap_or_default();
			let (_returned, slashed) = miner_info.calc_final_stake(orig_stake);
			// Notify the subscriber with the slash prediction
			T::OnStopped::on_stopped(&worker, orig_stake, slashed);
			Self::push_message(SystemEvent::new_worker_event(
				worker,
				WorkerEvent::MiningStop,
			));
			Self::deposit_event(Event::<T>::MinerStopped(miner));
			Ok(())
		}
pub fn stop_mining ( miner : T :: AccountId ) -> DispatchResult { let worker = MinerBindings :: < T > :: get ( & miner ) . ok_or ( Error :: < T > :: MinerNotBound ) ? ; let mut miner_info = Miners :: < T > :: get ( & miner ) . ok_or ( Error :: < T > :: MinerNotFound ) ? ; ensure ! ( miner_info state MinerState Ready miner_info state MinerState MiningCoolingDown Error T MinerNotMining ) ; let now = Self :: now_sec ( ) ; miner_info . state = MinerState :: MiningCoolingDown ; miner_info . cool_down_start = now ; Miners :: < T > :: insert ( & miner , & miner_info ) ; OnlineMiners :: < T > :: mutate ( | v | * v -= 1 ) ; // v cannot be 0 // Calcualte remaining stake (assume there's no more slash after calling `stop_mining`) let orig_stake = Stakes :: < T > :: get ( & miner ) . unwrap_or_default ( ) ; let ( _returned , slashed ) = miner_info . calc_final_stake ( orig_stake ) ; // Notify the subscriber with the slash prediction T :: OnStopped :: on_stopped ( & worker , orig_stake , slashed ) ; Self :: push_message ( SystemEvent :: new_worker_event ( worker , WorkerEvent :: MiningStop , ) ) ; Self :: deposit_event ( Event :: < T > :: MinerStopped ( miner ) ) ; Ok ( ( ) ) }
Stops mining, enterying cool down state
Requires:
1.
Stops mining enterying cool down state Requires : 1 .
miner
T::AccountId
miner
T::AccountId