Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove unused code in off-chain worker example #7027

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions frame/example-offchain-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ decl_storage! {
decl_event!(
/// Events generated by the module.
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
/// Event generated when new price is accepted to contribute to the average.
/// Event generated when new price is accepted to contribute to the average.
/// [price, who]
NewPrice(u32, AccountId),
}
Expand Down Expand Up @@ -461,16 +461,6 @@ impl<T: Trait> Module<T> {
// Note this call will block until response is received.
let price = Self::fetch_price().map_err(|_| "Failed to fetch price")?;

// Received price is wrapped into a call to `submit_price_unsigned` public function of this
// pallet. This means that the transaction, when executed, will simply call that function
// passing `price` as an argument.
let call = Call::submit_price_unsigned(block_number, price);

// Now let's create a transaction out of this call and submit it to the pool.
// Here we showcase two ways to send an unsigned transaction with a signed payload
SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into())
.map_err(|()| "Unable to submit unsigned transaction.")?;

// -- Sign using any account
let (_, result) = Signer::<T, T::AuthorityId>::any_account().send_unsigned_transaction(
|account| PricePayload {
Copy link
Contributor Author

@jimmychu0807 jimmychu0807 Sep 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomusdrw
But reading the code carefully, the call and submit_unsigned_transaction in L464 - L473 are just sending an unsigned tx. In this function, what we want to demo is doing unsigned tx with signed payload, which is what the code at L477 - L485 doing. And they are not any way related to L464 - L473. Same logic applied for L503 - L512.

Probably it is an oversight that got copied over from L432 - L446? That's why I am removing them. Tell me if this is not the case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough! I thought that there is only one function that sends both a "raw" unsigned transaction and an unsigned transaction with signed payload. Thanks for spotting that this is a copy-paste error most likely.

Expand Down Expand Up @@ -500,16 +490,6 @@ impl<T: Trait> Module<T> {
// Note this call will block until response is received.
let price = Self::fetch_price().map_err(|_| "Failed to fetch price")?;

// Received price is wrapped into a call to `submit_price_unsigned` public function of this
// pallet. This means that the transaction, when executed, will simply call that function
// passing `price` as an argument.
let call = Call::submit_price_unsigned(block_number, price);

// Now let's create a transaction out of this call and submit it to the pool.
// Here we showcase two ways to send an unsigned transaction with a signed payload
SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into())
.map_err(|()| "Unable to submit unsigned transaction.")?;

// -- Sign using all accounts
let transaction_results = Signer::<T, T::AuthorityId>::all_accounts()
.send_unsigned_transaction(
Expand Down