fn offchain_worker(block_number: T::BlockNumber) {
			if Self::should_trigger_offchain(block_number) {
				// obtain the OCW lock
				let lock_expiration = Duration::from_millis(OCW_LOCK_DURATION);
				let mut lock = StorageLock::<'static, Time>::with_deadline(OCW_WORKER_LOCK, lock_expiration);

				match lock.try_lock() {
					Ok(_guard) => {
						if let Err(e) = Self::fetch_prices_and_update_best_paths(block_number) {
							log::error!("OCW price fetching error: {}", e);
						}
						// bump the offchain trigger block
						let next_trigger = block_number + T::OffchainTriggerDelay::get();
						StorageValueRef::persistent(NEXT_OFFCHAIN_TRIGGER_BLOCK).set(&next_trigger);
					},
					Err(e) => log::warn!("OCW failed to obtain OCW lock due to {:?}", e)
				};
			}
		}
/// Off-chain Worker entry point.
///
/// First checks whether can act upon this block, if so, attempts to obtain the lock, if successful, fetches and updates the best paths.
/// Once done, bumps the next trigger block storage by the delay amount, and lock is released.
Off-chain Worker entry point.
First checks whether can act upon this block, if so, attempts to obtain the lock, if successful, fetches and updates the best paths.
Once done, bumps the next trigger block storage by the delay amount, and lock is released.
Off - chain Worker entry point . First checks whether can act upon this block if so attempts to obtain the lock if successful fetches and updates the best paths . Once done bumps the next trigger block storage by the delay amount and lock is released .
fn offchain_worker(block_number: T::BlockNumber) {
			if Self::should_trigger_offchain(block_number) {
				// obtain the OCW lock
				let lock_expiration = Duration::from_millis(OCW_LOCK_DURATION);
				let mut lock = StorageLock::<'static, Time>::with_deadline(OCW_WORKER_LOCK, lock_expiration);
				match lock.try_lock() {
					Ok(_guard) => {
						if let Err(e) = Self::fetch_prices_and_update_best_paths(block_number) {
							log::error!("OCW price fetching error: {}", e);
						}
						// bump the offchain trigger block
						let next_trigger = block_number + T::OffchainTriggerDelay::get();
						StorageValueRef::persistent(NEXT_OFFCHAIN_TRIGGER_BLOCK).set(&next_trigger);
					},
					Err(e) => log::warn!("OCW failed to obtain OCW lock due to {:?}", e)
				};
			}
		}
fn offchain_worker ( block_number : T :: BlockNumber ) { if Self :: should_trigger_offchain ( block_number ) { // obtain the OCW lock let lock_expiration = Duration :: from_millis ( OCW_LOCK_DURATION ) ; let mut lock = StorageLock :: < ' static , Time > :: with_deadline ( OCW_WORKER_LOCK , lock_expiration ) ; match lock . try_lock ( ) { Ok ( _guard ) => { if let Err ( e ) = Self :: fetch_prices_and_update_best_paths ( block_number ) { log :: error ! ( " " e ) ; } // bump the offchain trigger block let next_trigger = block_number + T :: OffchainTriggerDelay :: get ( ) ; StorageValueRef :: persistent ( NEXT_OFFCHAIN_TRIGGER_BLOCK ) . set ( & next_trigger ) ; } , Err ( e ) => log :: warn ! ( " " e ) } ; } }
Off-chain Worker entry point.
Off - chain Worker entry point .
block_number
T::BlockNumber
block_number
T::BlockNumber