fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
			// Firstly let's check that we call the right function.
			if let Call::ocw_submit_best_paths_changes {
				best_path_change_payload: ref payload,
				ref signature,
			} = call
			{
				let signature_valid = SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone());
				if !signature_valid {
					log::error!("OCW rejected transaction due to invalid signature");
					return InvalidTransaction::BadProof.into()
				}

				let current_block = <frame_system::Pallet<T>>::block_number();
				if payload.block_number + T::MaxTxPoolStayTime::get() < current_block {
					// transaction was in pool for too long
					return InvalidTransaction::Stale.into();
				}

				let account_id = payload.public.clone().into_account();
				if !WhitelistedOffchainAuthorities::<T>::contains_key(&account_id) {
					log::error!("OCW rejected transaction due to signer not on the offchain authority whitelist: {:?}", account_id);
					return InvalidTransaction::BadProof.into();
				}

				ValidTransaction::with_tag_prefix("AggregatorWorker")
					.priority(T::UnsignedPriority::get())
					.and_provides((TX_TAG, current_block))
					.longevity(5)  // transaction is only valid for next 5 blocks. After that it's revalidated by the pool.
					.propagate(true)
					.build()
			} else {
				InvalidTransaction::Call.into()
			}
		}
/// Validate unsigned calls to this module.
///
/// By default unsigned transactions are disallowed, but implementing the validator
/// here we make sure that some particular calls (the ones produced by offchain worker)
/// are being whitelisted and marked as valid.
Validate unsigned calls to this module.
By default unsigned transactions are disallowed, but implementing the validator
here we make sure that some particular calls (the ones produced by offchain worker)
are being whitelisted and marked as valid.
Validate unsigned calls to this module . By default unsigned transactions are disallowed but implementing the validator here we make sure that some particular calls ( the ones produced by offchain worker ) are being whitelisted and marked as valid .
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
			// Firstly let's check that we call the right function.
			if let Call::ocw_submit_best_paths_changes {
				best_path_change_payload: ref payload,
				ref signature,
			} = call
			{
				let signature_valid = SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone());
				if !signature_valid {
					log::error!("OCW rejected transaction due to invalid signature");
					return InvalidTransaction::BadProof.into()
				}
				let current_block = <frame_system::Pallet<T>>::block_number();
				if payload.block_number + T::MaxTxPoolStayTime::get() < current_block {
					// transaction was in pool for too long
					return InvalidTransaction::Stale.into();
				}
				let account_id = payload.public.clone().into_account();
				if !WhitelistedOffchainAuthorities::<T>::contains_key(&account_id) {
					log::error!("OCW rejected transaction due to signer not on the offchain authority whitelist: {:?}", account_id);
					return InvalidTransaction::BadProof.into();
				}
				ValidTransaction::with_tag_prefix("AggregatorWorker")
					.priority(T::UnsignedPriority::get())
					.and_provides((TX_TAG, current_block))
					.longevity(5)  // transaction is only valid for next 5 blocks. After that it's revalidated by the pool.
					.propagate(true)
					.build()
			} else {
				InvalidTransaction::Call.into()
			}
		}
fn validate_unsigned ( _source : TransactionSource , call : & Self :: Call ) -> TransactionValidity { // Firstly let's check that we call the right function. if let Call :: ocw_submit_best_paths_changes { best_path_change_payload : ref payload , ref signature , } = call { let signature_valid = SignedPayload :: < T > :: verify :: < T :: AuthorityId > ( payload , signature . clone ( ) ) ; if ! signature_valid { log :: error ! ( " " ) ; return InvalidTransaction :: BadProof . into ( ) } let current_block = < frame_system :: Pallet < T > > :: block_number ( ) ; if payload . block_number + T :: MaxTxPoolStayTime :: get ( ) < current_block { // transaction was in pool for too long return InvalidTransaction :: Stale . into ( ) ; } let account_id = payload . public . clone ( ) . into_account ( ) ; if ! WhitelistedOffchainAuthorities :: < T > :: contains_key ( & account_id ) { log :: error ! ( " " account_id ) ; return InvalidTransaction :: BadProof . into ( ) ; } ValidTransaction :: with_tag_prefix ( " " ) . priority ( T :: UnsignedPriority :: get ( ) ) . and_provides ( ( TX_TAG , current_block ) ) . longevity ( 5 ) // transaction is only valid for next 5 blocks. After that it's revalidated by the pool. . propagate ( true ) . build ( ) } else { InvalidTransaction :: Call . into ( ) } }
Validate unsigned calls to this module.
Validate unsigned calls to this module .
_source
TransactionSource
call
&Self::Call
_source
TransactionSource
call
&Self::Call