Skip to content

Commit

Permalink
fix: unsigned and one day (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
ytqaljn committed Jun 7, 2022
1 parent b01450a commit aae2ac4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions c-pallets/file-bank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pub mod pallet {

let number: u128 = block_number.saturated_into();
let one_day: u128 = <T as Config>::OneDay::get().saturated_into();
if number % 5 == 0 || number == 1 {
if number % one_day == 0 || number == 1 {
//Query price
let result = Self::offchain_fetch_price(block_number);
if let Err(e) = result {
Expand Down Expand Up @@ -845,16 +845,10 @@ pub mod pallet {
//offchain helper
//Signature chaining method
fn offchain_signed_tx(_block_number: T::BlockNumber, price: Vec<u8>) -> Result<(), Error<T>> {
let signer = Signer::<T, T::AuthorityId>::any_account();
let call = Call::update_price{price: price};

let results = signer.send_signed_transaction(|_account| {
Call::update_price{price: price.clone()}
});
let (_acc, res) = results.unwrap();
match res {
Ok(()) => log::info!(" Submitted price of cents"),
Err(e) => log::error!("[{:?}] Failed to submit transaction", e),
}
SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into())
.map_err(|()| Error::<T>::OffchainUnSignedTxError)?;

Ok(())
}
Expand Down

0 comments on commit aae2ac4

Please sign in to comment.