Skip to content

Commit 3f25833

Browse files
Cleanup formatting and whitespace
Minor stylistic cleanup across multiple files: reflowed assignments and conditionals to single lines, removed extra blank lines and trailing whitespace, and compacted chained calls (transaction_handler.rs, order_book/engine.rs, order_book/position_tracker.rs, websocket/handlers.rs, websocket/server.rs). No behavioral changes—purely formatting to improve readability.
1 parent b346ac7 commit 3f25833

5 files changed

Lines changed: 7 additions & 16 deletions

File tree

src/handlers/transaction_handler.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ pub async fn deposit_money(
7575

7676
// Update user balance
7777
let mut user_active_model: users::ActiveModel = user.into();
78-
user_active_model.wallet_balance =
79-
Set(RustDecimal::try_from(balance_after).unwrap());
78+
user_active_model.wallet_balance = Set(RustDecimal::try_from(balance_after).unwrap());
8079
user_active_model.updated_at = Set(chrono::Utc::now().naive_utc());
8180

8281
let _updated_user = user_active_model.update(&txn).await.map_err(|e| {
@@ -219,8 +218,7 @@ pub async fn withdraw_money(
219218

220219
// Update user balance
221220
let mut user_active_model: users::ActiveModel = user.into();
222-
user_active_model.wallet_balance =
223-
Set(RustDecimal::try_from(balance_after).unwrap());
221+
user_active_model.wallet_balance = Set(RustDecimal::try_from(balance_after).unwrap());
224222
user_active_model.updated_at = Set(chrono::Utc::now().naive_utc());
225223

226224
let _updated_user = user_active_model.update(&txn).await.map_err(|e| {

src/order_book/engine.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ impl OrderBookEngine {
4848
}
4949

5050
// For Fill-Or-Kill orders, check if we can fill the entire order
51-
if order.time_in_force == TimeInForce::FOK
52-
&& !self.can_fill_entire_order(&order) {
53-
order.reject();
54-
return Ok(vec![]);
55-
}
51+
if order.time_in_force == TimeInForce::FOK && !self.can_fill_entire_order(&order) {
52+
order.reject();
53+
return Ok(vec![]);
54+
}
5655

5756
// Market orders get the best available price
5857
let trades = if order.order_type == OrderType::Market {

src/order_book/position_tracker.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,7 @@ impl PositionTracker {
210210

211211
let mut grouped: HashMap<i32, Vec<UserPosition>> = HashMap::new();
212212
for position in positions {
213-
grouped
214-
.entry(position.event_id)
215-
.or_default()
216-
.push(position);
213+
grouped.entry(position.event_id).or_default().push(position);
217214
}
218215

219216
Ok(grouped)

src/websocket/handlers.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ impl WebSocketHandlers {
394394
pub async fn fetch_and_broadcast_portfolio(&self, user_id: i32) {
395395
// Import position tracker
396396
use crate::order_book::position_tracker::PositionTracker;
397-
398397

399398
// Get user data
400399
let user = match users::Entity::find_by_id(user_id)
@@ -633,7 +632,6 @@ impl WebSocketHandlers {
633632
}
634633
}
635634

636-
637635
impl Default for PaginationQuery {
638636
fn default() -> Self {
639637
Self {

src/websocket/server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub struct WebSocketServer {
2727
redis_pool: Option<web::Data<Pool>>,
2828
}
2929

30-
3130
impl WebSocketServer {
3231
pub fn with_handlers(db: web::Data<DatabaseConnection>, redis_pool: web::Data<Pool>) -> Self {
3332
Self {

0 commit comments

Comments
 (0)