pub fn bind(miner: T::AccountId, pubkey: WorkerPublicKey) -> DispatchResult {
			let worker =
				registry::Workers::<T>::get(&pubkey).ok_or(Error::<T>::WorkerNotRegistered)?;
			// Check the worker has finished the benchmark
			ensure!(worker.initial_score != None, Error::<T>::BenchmarkMissing);
			// Check miner and worker not bound
			ensure!(
				Self::ensure_miner_bound(&miner).is_err(),
				Error::<T>::DuplicateBoundMiner
			);
			ensure!(
				Self::ensure_worker_bound(&pubkey).is_err(),
				Error::<T>::DuplicateBoundWorker
			);
			// Make sure we are not overriding a running miner (even if the worker is unbound)
			let can_bind = match Miners::<T>::get(&miner) {
				Some(info) => info.state == MinerState::Ready,
				None => true,
			};
			ensure!(can_bind, Error::<T>::MinerNotReady);

			let now = Self::now_sec();
			MinerBindings::<T>::insert(&miner, &pubkey);
			WorkerBindings::<T>::insert(&pubkey, &miner);
			Miners::<T>::insert(
				&miner,
				MinerInfo {
					state: MinerState::Ready,
					ve: 0,
					v: 0,
					v_updated_at: now,
					benchmark: Benchmark {
						p_init: 0u32,
						p_instant: 0u32,
						iterations: 0u64,
						mining_start_time: now,
						challenge_time_last: 0u64,
					},
					cool_down_start: 0u64,
					stats: Default::default(),
				},
			);

			Self::deposit_event(Event::<T>::MinerBound(miner, pubkey));
			Ok(())
		}
/// Binds a miner to a worker
///
/// This will bind the miner account to the worker, and then create a `Miners` entry to
/// track the mining session in the future. The mining session will exist until ther miner
/// and the worker is unbound.
///
/// Requires:
/// 1. The worker is alerady registered
/// 2. The worker has an initial benchmark
/// 3. Both the worker and the miner are not bound
/// 4. There's no stake in CD associated with the miner
Binds a miner to a worker
This will bind the miner account to the worker, and then create a `Miners` entry to
track the mining session in the future. The mining session will exist until ther miner
and the worker is unbound.

1. The worker is alerady registered
2. The worker has an initial benchmark
3. Both the worker and the miner are not bound
4. There's no stake in CD associated with the miner
Binds a miner to a worker This will bind the miner account to the worker and then create a ` Miners ` entry to track the mining session in the future . The mining session will exist until ther miner and the worker is unbound . 1 . The worker is alerady registered 2 . The worker has an initial benchmark 3 . Both the worker and the miner are not bound 4 . There ' s no stake in CD associated with the miner
pub fn bind(miner: T::AccountId, pubkey: WorkerPublicKey) -> DispatchResult {
			let worker =
				registry::Workers::<T>::get(&pubkey).ok_or(Error::<T>::WorkerNotRegistered)?;
			// Check the worker has finished the benchmark
			ensure!(worker.initial_score != None, Error::<T>::BenchmarkMissing);
			// Check miner and worker not bound
			ensure!(
				Self::ensure_miner_bound(&miner).is_err(),
				Error::<T>::DuplicateBoundMiner
			);
			ensure!(
				Self::ensure_worker_bound(&pubkey).is_err(),
				Error::<T>::DuplicateBoundWorker
			);
			// Make sure we are not overriding a running miner (even if the worker is unbound)
			let can_bind = match Miners::<T>::get(&miner) {
				Some(info) => info.state == MinerState::Ready,
				None => true,
			};
			ensure!(can_bind, Error::<T>::MinerNotReady);
			let now = Self::now_sec();
			MinerBindings::<T>::insert(&miner, &pubkey);
			WorkerBindings::<T>::insert(&pubkey, &miner);
			Miners::<T>::insert(
				&miner,
				MinerInfo {
					state: MinerState::Ready,
					ve: 0,
					v: 0,
					v_updated_at: now,
					benchmark: Benchmark {
						p_init: 0u32,
						p_instant: 0u32,
						iterations: 0u64,
						mining_start_time: now,
						challenge_time_last: 0u64,
					},
					cool_down_start: 0u64,
					stats: Default::default(),
				},
			);
			Self::deposit_event(Event::<T>::MinerBound(miner, pubkey));
			Ok(())
		}
pub fn bind ( miner : T :: AccountId , pubkey : WorkerPublicKey ) -> DispatchResult { let worker = registry :: Workers :: < T > :: get ( & pubkey ) . ok_or ( Error :: < T > :: WorkerNotRegistered ) ? ; // Check the worker has finished the benchmark ensure ! ( worker initial_score None Error T BenchmarkMissing ) ; // Check miner and worker not bound ensure ! ( Self ensure_miner_bound ( miner ) is_err ( ) Error T DuplicateBoundMiner ) ; ensure ! ( Self ensure_worker_bound ( pubkey ) is_err ( ) Error T DuplicateBoundWorker ) ; // Make sure we are not overriding a running miner (even if the worker is unbound) let can_bind = match Miners :: < T > :: get ( & miner ) { Some ( info ) => info . state == MinerState :: Ready , None => true , } ; ensure ! ( can_bind Error T MinerNotReady ) ; let now = Self :: now_sec ( ) ; MinerBindings :: < T > :: insert ( & miner , & pubkey ) ; WorkerBindings :: < T > :: insert ( & pubkey , & miner ) ; Miners :: < T > :: insert ( & miner , MinerInfo { state : MinerState :: Ready , ve : 0 , v : 0 , v_updated_at : now , benchmark : Benchmark { p_init : 0u32 , p_instant : 0u32 , iterations : 0u64 , mining_start_time : now , challenge_time_last : 0u64 , } , cool_down_start : 0u64 , stats : Default :: default ( ) , } , ) ; Self :: deposit_event ( Event :: < T > :: MinerBound ( miner , pubkey ) ) ; Ok ( ( ) ) }
Binds a miner to a worker
This will bind the miner account to the worker, and then create a `Miners` entry to
track the mining session in the future.
Binds a miner to a worker This will bind the miner account to the worker and then create a ` Miners ` entry to track the mining session in the future .
miner
T::AccountId
pubkey
WorkerPublicKey
miner
T::AccountId
pubkey
WorkerPublicKey