Skip to content

Commit

Permalink
Fix CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Mar 20, 2024
1 parent 8f42e19 commit f27cd6a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pallets/ocex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ pub mod pallet {
let config = crate::lmp::get_lmp_config(&mut state, current_epoch)?;

log::debug!(target:"ocex", "fetch_checkpoint returning");
Ok(ObCheckpointRaw::new(
Ok(ObCheckpointRaw {
snapshot_id,
balances,
last_processed_block_number,
Expand All @@ -1977,7 +1977,7 @@ pub mod pallet {
taker_volume_map,
fees_paid_map,
total_maker_volume_map,
))
})
}

/// Fetches balance of given `AssetId` for given `AccountId` from offchain storage
Expand Down
9 changes: 5 additions & 4 deletions pallets/ocex/src/lmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub mod keys {
use orderbook_primitives::types::TradingPair;
use parity_scale_codec::Encode;
use polkadex_primitives::AccountId;
use sp_std::vec::Vec;

pub fn get_trade_volume_by_main_account_key(
epoch: u16,
Expand Down Expand Up @@ -103,7 +104,7 @@ pub fn update_trade_volume_by_main_account(
volume: Decimal,
main: &AccountId,
) -> Result<Decimal, &'static str> {
let key = get_trade_volume_by_main_account_key(epoch, trading_pair, &main);
let key = get_trade_volume_by_main_account_key(epoch, trading_pair, main);
Ok(match state.get(&key)? {
None => {
state.insert(key, volume.encode());
Expand All @@ -126,7 +127,7 @@ pub fn get_trade_volume_by_main_account(
trading_pair: &TradingPair,
main: &AccountId,
) -> Result<Decimal, &'static str> {
let key = get_trade_volume_by_main_account_key(epoch, *trading_pair, &main);
let key = get_trade_volume_by_main_account_key(epoch, *trading_pair, main);
Ok(match state.get(&key)? {
None => Decimal::zero(),
Some(encoded_volume) => {
Expand All @@ -142,7 +143,7 @@ pub fn get_maker_volume_by_main_account(
trading_pair: &TradingPair,
main: &AccountId,
) -> Result<Decimal, &'static str> {
let key = get_maker_volume_by_main_account_key(epoch, *trading_pair, &main);
let key = get_maker_volume_by_main_account_key(epoch, *trading_pair, main);
Ok(match state.get(&key)? {
None => Decimal::zero(),
Some(encoded_volume) => {
Expand All @@ -159,7 +160,7 @@ pub fn update_maker_volume_by_main_account(
volume: Decimal,
main: &AccountId,
) -> Result<Decimal, &'static str> {
let key = get_maker_volume_by_main_account_key(epoch, trading_pair, &main);
let key = get_maker_volume_by_main_account_key(epoch, trading_pair, main);
Ok(match state.get(&key)? {
None => {
state.insert(key, volume.encode());
Expand Down
38 changes: 2 additions & 36 deletions primitives/orderbook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

use crate::ingress::EgressMessages;
use crate::lmp::LMPConfig;
#[cfg(feature = "std")]
use crate::recovery::ObCheckpoint;
use crate::types::{AccountAsset, TradingPair};
Expand All @@ -38,7 +39,6 @@ use serde::{Deserialize, Serialize};
use sp_core::crypto::AccountId32;
use sp_core::H256;
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
use crate::lmp::LMPConfig;

pub mod constants;
pub mod types;
Expand Down Expand Up @@ -180,40 +180,6 @@ pub struct ObCheckpointRaw {
}

impl ObCheckpointRaw {
/// Create a new `ObCheckpointRaw` instance.
/// # Parameters
/// * `snapshot_id`: The snapshot ID of the order book recovery state.
/// * `balances`: A `BTreeMap` that maps `AccountAsset`s to `Decimal` balances.
/// * `last_processed_block_number`: The last block number that was processed by validator.
/// * `state_change_id`: State change id
/// # Returns
/// * `ObCheckpointRaw`: A new `ObCheckpointRaw` instance.
pub fn new(
snapshot_id: u64,
balances: BTreeMap<AccountAsset, Decimal>,
last_processed_block_number: BlockNumber,
state_change_id: u64,
config: LMPConfig,
q_scores_uptime_map: BTreeMap<(u16, TradingPair, AccountId32), BTreeMap<u16, Decimal>>,
maker_volume_map: BTreeMap<(u16, TradingPair, AccountId32), Decimal>,
taker_volume_map: BTreeMap<(u16, TradingPair, AccountId32), Decimal>,
fees_paid_map: BTreeMap<(u16, TradingPair, AccountId32), Decimal>,
total_maker_volume_map: BTreeMap<(u16, TradingPair), Decimal>,
) -> Self {
Self {
snapshot_id,
balances,
last_processed_block_number,
state_change_id,
config,
q_scores_uptime_map,
maker_volume_map,
taker_volume_map,
fees_paid_map,
total_maker_volume_map
}
}

/// Convert `ObCheckpointRaw` to `ObCheckpoint`.
/// # Returns
/// * `ObCheckpoint`: A new `ObCheckpoint` instance.
Expand All @@ -229,7 +195,7 @@ impl ObCheckpointRaw {
maker_volume_map: self.maker_volume_map,
taker_volume_map: self.taker_volume_map,
fees_paid_map: self.fees_paid_map,
total_maker_volume_map: self.total_maker_volume_map
total_maker_volume_map: self.total_maker_volume_map,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion primitives/orderbook/src/lmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use sp_std::collections::btree_map::BTreeMap;
use sp_std::vec::Vec;

/// LMP Epoch config
#[derive(Decode, Encode, TypeInfo, Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default)]
#[derive(
Decode, Encode, TypeInfo, Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default,
)]
pub struct LMPConfig {
pub epoch: u16,
pub index: u16,
Expand Down
6 changes: 3 additions & 3 deletions primitives/orderbook/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::lmp::LMPConfig;
use crate::types::TradingPair;
use crate::{types::AccountAsset, ObCheckpointRaw};
use parity_scale_codec::{Decode, Encode};
use polkadex_primitives::{AccountId, AssetId, BlockNumber};
use rust_decimal::Decimal;
use scale_info::TypeInfo;
use serde_with::{json::JsonString, serde_as};
use std::collections::BTreeMap;
use sp_core::crypto::AccountId32;
use crate::lmp::LMPConfig;
use crate::types::TradingPair;
use std::collections::BTreeMap;

/// A struct representing the recovery state of an Order Book.
#[serde_as]
Expand Down

0 comments on commit f27cd6a

Please sign in to comment.