fn validate_unsigned(_source: TransactionSource, call: &Self::Call)
		-> TransactionValidity
		{
			let valid_tx = |provide| ValidTransaction::with_tag_prefix("ocw-demo")
			.priority(UNSIGNED_TXS_PRIORITY)
			.and_provides([&provide])
			.longevity(3)
			.propagate(true)
			.build();

			match call {
				Call::submit_number_unsigned(_number) => valid_tx(b"submit_number_unsigned".to_vec()),
				Call::submit_number_unsigned_with_signed_payload(ref payload, ref signature) => {
					if !SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone()) {
						return InvalidTransaction::BadProof.into();
					}
					valid_tx(b"submit_number_unsigned_with_signed_payload".to_vec())
				},
				Call::submit_price_unsigned_with_signed_payload(ref price_payload, ref signature) => {
					if !SignedPayload::<T>::verify::<T::AuthorityId>(price_payload, signature.clone()) {
						return InvalidTransaction::BadProof.into();
					}
					valid_tx(b"submit_price_unsigned_with_signed_payload".to_vec())
				},
				_ => InvalidTransaction::Call.into(),
			}
		}
/// Validate unsigned call 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 call 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 call 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
		{
			let valid_tx = |provide| ValidTransaction::with_tag_prefix("ocw-demo")
			.priority(UNSIGNED_TXS_PRIORITY)
			.and_provides([&provide])
			.longevity(3)
			.propagate(true)
			.build();
			match call {
				Call::submit_number_unsigned(_number) => valid_tx(b"submit_number_unsigned".to_vec()),
				Call::submit_number_unsigned_with_signed_payload(ref payload, ref signature) => {
					if !SignedPayload::<T>::verify::<T::AuthorityId>(payload, signature.clone()) {
						return InvalidTransaction::BadProof.into();
					}
					valid_tx(b"submit_number_unsigned_with_signed_payload".to_vec())
				},
				Call::submit_price_unsigned_with_signed_payload(ref price_payload, ref signature) => {
					if !SignedPayload::<T>::verify::<T::AuthorityId>(price_payload, signature.clone()) {
						return InvalidTransaction::BadProof.into();
					}
					valid_tx(b"submit_price_unsigned_with_signed_payload".to_vec())
				},
				_ => InvalidTransaction::Call.into(),
			}
		}
fn validate_unsigned ( _source : TransactionSource , call : & Self :: Call ) -> TransactionValidity { let valid_tx = | provide | ValidTransaction :: with_tag_prefix ( " " ) . priority ( UNSIGNED_TXS_PRIORITY ) . and_provides ( [ & provide ] ) . longevity ( 3 ) . propagate ( true ) . build ( ) ; match call { Call :: submit_number_unsigned ( _number ) => valid_tx ( b" " . to_vec ( ) ) , Call :: submit_number_unsigned_with_signed_payload ( ref payload , ref signature ) => { if ! SignedPayload :: < T > :: verify :: < T :: AuthorityId > ( payload , signature . clone ( ) ) { return InvalidTransaction :: BadProof . into ( ) ; } valid_tx ( b" " . to_vec ( ) ) } , Call :: submit_price_unsigned_with_signed_payload ( ref price_payload , ref signature ) => { if ! SignedPayload :: < T > :: verify :: < T :: AuthorityId > ( price_payload , signature . clone ( ) ) { return InvalidTransaction :: BadProof . into ( ) ; } valid_tx ( b" " . to_vec ( ) ) } , _ => InvalidTransaction :: Call . into ( ) , } }
Validate unsigned call to this module.
Validate unsigned call to this module .
_source
TransactionSource
call
&Self::Call
_source
TransactionSource
call
&Self::Call