From 31189719e786eb8ca6141995ecab03ba78344a5a Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Thu, 29 Feb 2024 11:03:42 +0100 Subject: [PATCH] Address comments --- auction-server/src/api/bid.rs | 10 +++++----- auction-server/src/api/liquidation.rs | 2 +- auction-server/src/server.rs | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/auction-server/src/api/bid.rs b/auction-server/src/api/bid.rs index 93631a7e..9c6a5e72 100644 --- a/auction-server/src/api/bid.rs +++ b/auction-server/src/api/bid.rs @@ -9,6 +9,7 @@ use { Bid, }, state::{ + BidId, BidStatus, Store, }, @@ -29,15 +30,14 @@ use { ToResponse, ToSchema, }, - uuid::Uuid, }; #[derive(Serialize, Deserialize, ToResponse, ToSchema, Clone)] pub struct BidResult { pub status: String, /// The unique id created to identify the bid. This id can be used to query the status of the bid. - #[schema(example = "f47ac10b-58cc-4372-a567-0e02b2c3d479", value_type=String)] - pub id: Uuid, + #[schema(example = "beedbeed-58cc-4372-a567-0e02b2c3d479", value_type=String)] + pub id: BidId, } @@ -47,7 +47,7 @@ pub struct BidResult { /// containing the contract call will be sent to the blockchain expecting the bid amount to be paid after the call. #[utoipa::path(post, path = "/v1/bids", request_body = Bid, responses( (status = 200, description = "Bid was placed successfully", body = BidResult, - example = json!({"status": "OK", "id": "115c5c03-b346-4fa1-8fab-2541a9e1872d"})), + example = json!({"status": "OK", "id": "beedbeed-b346-4fa1-8fab-2541a9e1872d"})), (status = 400, response = ErrorBodyResponse), (status = 404, description = "Chain id was not found", body = ErrorBodyResponse), ),)] @@ -80,7 +80,7 @@ pub async fn process_bid(store: Arc, bid: Bid) -> Result, ),)] pub async fn bid_status( State(store): State>, - Path(bid_id): Path, + Path(bid_id): Path, ) -> Result, RestError> { let status = store.bid_status_store.get_status(&bid_id).await; match status { diff --git a/auction-server/src/api/liquidation.rs b/auction-server/src/api/liquidation.rs index 364b092c..5de10285 100644 --- a/auction-server/src/api/liquidation.rs +++ b/auction-server/src/api/liquidation.rs @@ -52,7 +52,7 @@ use { #[derive(Serialize, Deserialize, ToSchema, Clone, ToResponse)] pub struct OpportunityParamsWithMetadata { /// The opportunity unique id - #[schema(example = "f47ac10b-58cc-4372-a567-0e02b2c3d479", value_type=String)] + #[schema(example = "obo3ee3e-58cc-4372-a567-0e02b2c3d479", value_type=String)] opportunity_id: OpportunityId, /// Creation time of the opportunity #[schema(example = 1700000000, value_type=i64)] diff --git a/auction-server/src/server.rs b/auction-server/src/server.rs index ddacdd4e..e35f0bfd 100644 --- a/auction-server/src/server.rs +++ b/auction-server/src/server.rs @@ -96,19 +96,20 @@ pub async fn start_server(run_options: RunOptions) -> anyhow::Result<()> { .into_iter() .collect(); - let (update_tx, update_rx) = tokio::sync::broadcast::channel(NOTIFICATIONS_CHAN_LEN); + let (broadcast_sender, broadcast_receiver) = + tokio::sync::broadcast::channel(NOTIFICATIONS_CHAN_LEN); let store = Arc::new(Store { chains: chain_store?, liquidation_store: LiquidationStore::default(), bid_status_store: BidStatusStore { bids_status: Default::default(), - event_sender: update_tx.clone(), + event_sender: broadcast_sender.clone(), }, per_operator: wallet, ws: ws::WsState { subscriber_counter: AtomicUsize::new(0), - broadcast_sender: update_tx, - broadcast_receiver: update_rx, + broadcast_sender, + broadcast_receiver, }, });