From a30ee390feeb79abd1c8acea239bf6a4c3f222ac Mon Sep 17 00:00:00 2001 From: arkanoider Date: Sun, 8 Dec 2024 13:55:00 +0100 Subject: [PATCH] adding trade-index in Order and SmallOrder Struct --- src/message.rs | 7 +++---- src/order.rs | 5 +++++ src/user.rs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/message.rs b/src/message.rs index 3437ae1..4808967 100644 --- a/src/message.rs +++ b/src/message.rs @@ -110,7 +110,6 @@ impl Message { sig: Option, ) -> Self { let kind = MessageKind::new(id, request_id, trade_index, action, content, sig); - Self::Order(kind) } @@ -358,10 +357,10 @@ impl MessageKind { } pub fn has_trade_index(&self) -> (bool, i64) { - if let Some(index) = self.trade_index{ - return (true,index) + if let Some(index) = self.trade_index { + return (true, index); } - (false,0) + (false, 0) } pub fn verify_content_signature(&self, pubkey: PublicKey) -> bool { diff --git a/src/order.rs b/src/order.rs index e01065d..c0b1f00 100644 --- a/src/order.rs +++ b/src/order.rs @@ -144,6 +144,7 @@ pub struct Order { pub failed_payment: bool, pub payment_attempts: i64, pub expires_at: i64, + pub trade_index: Option, } impl Order { @@ -166,6 +167,7 @@ impl Order { Some(self.expires_at), None, None, + self.trade_index, ) } @@ -198,6 +200,7 @@ pub struct SmallOrder { pub expires_at: Option, pub buyer_token: Option, pub seller_token: Option, + pub trade_index: Option, } #[allow(dead_code)] @@ -221,6 +224,7 @@ impl SmallOrder { expires_at: Option, buyer_token: Option, seller_token: Option, + trade_index: Option, ) -> Self { Self { id, @@ -240,6 +244,7 @@ impl SmallOrder { expires_at, buyer_token, seller_token, + trade_index, } } /// New order from json string diff --git a/src/user.rs b/src/user.rs index 4f92085..3edd0f8 100644 --- a/src/user.rs +++ b/src/user.rs @@ -27,7 +27,7 @@ impl User { is_solver: i64, is_banned: i64, category: i64, - trade_index: i64 + trade_index: i64, ) -> Self { Self { id: Uuid::new_v4(), @@ -37,7 +37,7 @@ impl User { is_banned, category, created_at: Utc::now().timestamp(), - trade_index + trade_index, } } }