Skip to content

Commit

Permalink
Merge branch 'settle-queue-to-driver' into driver-settle-queue-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/driver/src/domain/competition/mod.rs
  • Loading branch information
squadgazzz committed Dec 19, 2024
2 parents 5b56fc7 + 572c68a commit f5970a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ impl Competition {
let _ = tokio::time::timeout(remaining, simulate_on_new_blocks).await;
}

// Check the settlement queue only here since its capacity can change while
// processing solutions.
if self.settle_queue.capacity() == 0 {
tracing::warn!("settlement queue is full; auction is rejected");
return Err(Error::TooManyPendingSettlements);
}

Ok(score)
}

Expand Down Expand Up @@ -364,6 +357,15 @@ impl Competition {
})?
}

pub fn ensure_settle_queue_capacity(&self) -> Result<(), Error> {
if self.settle_queue.capacity() == 0 {
tracing::warn!("settlement queue is full; auction is rejected");
Err(Error::TooManyPendingSettlements)
} else {
Ok(())
}
}

async fn process_settle_requests(
self: Arc<Self>,
mut settle_receiver: mpsc::Receiver<SettleRequest>,
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/infra/api/routes/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async fn route(
.prioritize(auction, &competition.solver.account().address())
.await;
let result = competition.solve(&auction).await;
competition.ensure_settle_queue_capacity()?;
observe::solved(state.solver().name(), &result);
Ok(axum::Json(dto::Solved::new(result?, &competition.solver)))
};
Expand Down

0 comments on commit f5970a4

Please sign in to comment.