Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Mar 14, 2024
1 parent 9be74e7 commit cdc8455
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion pallets/ocex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,6 @@ pub mod pallet {
Ok(())
}


/// Starts a new liquidity mining epoch
#[pallet::call_index(23)]
#[pallet::weight(< T as Config >::WeightInfo::set_fee_distribution())]
Expand Down
11 changes: 7 additions & 4 deletions pallets/ocex/src/lmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,17 @@ pub fn get_fees_paid_by_main_account_in_quote(
}

/// Returns the LMP configuration from offchain work state trie
pub fn get_lmp_config(state: &mut OffchainState, current_on_chain_epoch: u16) -> Result<LMPConfig, &'static str> {
pub fn get_lmp_config(
state: &mut OffchainState,
current_on_chain_epoch: u16,
) -> Result<LMPConfig, &'static str> {
let key = LMP_CONFIG_KEY.encode();
Ok(match state.get(&key)? {
None => {
if current_on_chain_epoch == 0 {
let config = LMPConfig{ epoch: current_on_chain_epoch, index: 0 };
store_lmp_config(state,config);
return Ok(config)
let config = LMPConfig { epoch: current_on_chain_epoch, index: 0 };
store_lmp_config(state, config);
return Ok(config);
}
return Err("LMPConfigNotFound");
},
Expand Down
8 changes: 4 additions & 4 deletions pallets/ocex/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::lmp::{get_lmp_config, get_total_maker_volume, store_lmp_config};
use crate::pallet::LMPEpoch;
use crate::{
aggregator::AggregatorClient,
lmp::{
Expand Down Expand Up @@ -56,7 +57,6 @@ use sp_runtime::{
};
use sp_std::{borrow::ToOwned, boxed::Box, collections::btree_map::BTreeMap, vec::Vec};
use trie_db::{TrieError, TrieMut};
use crate::pallet::LMPEpoch;

/// Key of the storage that stores the status of an offchain worker
pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status";
Expand Down Expand Up @@ -733,7 +733,7 @@ impl<T: Config> Pallet<T> {
},
UserActions::OneMinLMPReport(market, _total, scores) => {
let current_on_chain_epoch = <LMPEpoch<T>>::get();
Self::store_q_scores(state, *market, scores,current_on_chain_epoch)?;
Self::store_q_scores(state, *market, scores, current_on_chain_epoch)?;
},
}
}
Expand All @@ -746,9 +746,9 @@ impl<T: Config> Pallet<T> {
state: &mut OffchainState,
market: TradingPair,
scores: &BTreeMap<T::AccountId, Decimal>,
current_on_chain_epoch: u16
current_on_chain_epoch: u16,
) -> Result<(), &'static str> {
let mut config = get_lmp_config(state,current_on_chain_epoch)?;
let mut config = get_lmp_config(state, current_on_chain_epoch)?;
let next_index = config.index.saturating_add(1);
for (main, score) in scores {
store_q_score_and_uptime(
Expand Down

0 comments on commit cdc8455

Please sign in to comment.