Skip to content

Commit

Permalink
resolve borrow error
Browse files Browse the repository at this point in the history
  • Loading branch information
Anirudh Suresh authored and Anirudh Suresh committed Jan 18, 2024
1 parent 1919aa7 commit 1d2f165
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions auction-server/src/api/rest.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use {
crate::{
api::RestError,
auction::{
per::MulticallStatus,
simulate_bids,
},
auction::simulate_bids,
state::{
GetOppsParams,
Opportunity,
Expand Down Expand Up @@ -209,17 +206,17 @@ pub async fn get_opps(
let key = x
.parse::<Address>()
.map_err(|_| RestError::BadParameters("Invalid contract address".to_string()))?;

opps = chain_store.opps.write().await.entry(key).or_default().to_vec();

if let Some(x) = chain_store.opps.read().await.get(&key) {
opps = x.clone();
}
},
None => {
// TODO: fix this double write access, to make this work
let opps_dict = chain_store.opps.write().await;
let opps_dict = chain_store.opps.read().await;

for key in opps_dict.keys() {
let opps_key = chain_store.opps.write().await.entry(key.clone()).or_default().clone();
opps.extend(opps_key);
}
opps_dict.iter().for_each(|(_, value)| {
opps.extend(value.clone());
});
}
}
Ok(Json(opps))
Expand Down

0 comments on commit 1d2f165

Please sign in to comment.