Skip to content

Commit

Permalink
fix cdp-engine offchain worker (#2133)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 authored and xlc committed May 18, 2022
1 parent 78219aa commit 92c2803
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion modules/cdp-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,20 @@ impl<T: Config> Pallet<T> {
.unwrap_or(Some(DEFAULT_MAX_ITERATIONS))
.unwrap_or(DEFAULT_MAX_ITERATIONS);

let currency_id = collateral_currency_ids[collateral_position as usize];
let currency_id = match collateral_currency_ids.get(collateral_position as usize) {
Some(currency_id) => *currency_id,
None => {
log::debug!(
target: "cdp-engine offchain worker",
"collateral_currency was removed, need to reset the offchain worker: collateral_position is {:?}, collateral_currency_ids: {:?}",
collateral_position,
collateral_currency_ids
);
to_be_continue.set(&(0, Option::<Vec<u8>>::None));
return Ok(());
}
};

let is_shutdown = T::EmergencyShutdown::is_shutdown();

// If start key is Some(value) continue iterating from that point in storage otherwise start
Expand Down

0 comments on commit 92c2803

Please sign in to comment.