Skip to content

Commit

Permalink
adding trade-index in Order and SmallOrder Struct
Browse files Browse the repository at this point in the history
  • Loading branch information
arkanoider committed Dec 8, 2024
1 parent c0cd7bb commit a30ee39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl Message {
sig: Option<Signature>,
) -> Self {
let kind = MessageKind::new(id, request_id, trade_index, action, content, sig);

Self::Order(kind)
}

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub struct Order {
pub failed_payment: bool,
pub payment_attempts: i64,
pub expires_at: i64,
pub trade_index: Option<i64>,
}

impl Order {
Expand All @@ -166,6 +167,7 @@ impl Order {
Some(self.expires_at),
None,
None,
self.trade_index,
)
}

Expand Down Expand Up @@ -198,6 +200,7 @@ pub struct SmallOrder {
pub expires_at: Option<i64>,
pub buyer_token: Option<u16>,
pub seller_token: Option<u16>,
pub trade_index: Option<i64>,
}

#[allow(dead_code)]
Expand All @@ -221,6 +224,7 @@ impl SmallOrder {
expires_at: Option<i64>,
buyer_token: Option<u16>,
seller_token: Option<u16>,
trade_index: Option<i64>,
) -> Self {
Self {
id,
Expand All @@ -240,6 +244,7 @@ impl SmallOrder {
expires_at,
buyer_token,
seller_token,
trade_index,
}
}
/// New order from json string
Expand Down
4 changes: 2 additions & 2 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -37,7 +37,7 @@ impl User {
is_banned,
category,
created_at: Utc::now().timestamp(),
trade_index
trade_index,
}
}
}

0 comments on commit a30ee39

Please sign in to comment.