Skip to content

Commit

Permalink
Rework comments
Browse files Browse the repository at this point in the history
  • Loading branch information
m-lord-renkse committed Jul 16, 2024
1 parent 70211f3 commit 3c5df56
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/autopilot/src/domain/auction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Auction {
pub latest_settlement_block: u64,
pub orders: Vec<Order>,
pub prices: BTreeMap<H160, U256>,
pub surplus_capturing_jit_order_owners: Vec<H160>,
pub surplus_capturing_jit_order_owners: Vec<eth::Address>,
}

pub type Id = i64;
Expand Down
12 changes: 10 additions & 2 deletions crates/autopilot/src/infra/persistence/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ pub fn from_domain(auction: domain::Auction) -> Auction {
.map(super::order::from_domain)
.collect(),
prices: auction.prices,
surplus_capturing_jit_order_owners: auction.surplus_capturing_jit_order_owners,
surplus_capturing_jit_order_owners: auction
.surplus_capturing_jit_order_owners
.into_iter()
.map(Into::into)
.collect(),
}
}

Expand All @@ -32,7 +36,11 @@ pub fn to_domain(auction: Auction) -> domain::Auction {
.map(super::order::to_domain)
.collect(),
prices: auction.prices,
surplus_capturing_jit_order_owners: auction.surplus_capturing_jit_order_owners,
surplus_capturing_jit_order_owners: auction
.surplus_capturing_jit_order_owners
.into_iter()
.map(Into::into)
.collect(),
}
}

Expand Down
9 changes: 6 additions & 3 deletions crates/autopilot/src/infra/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
},
anyhow::Context,
chrono::Utc,
database::Address,
database::byte_array::ByteArray,
primitive_types::H256,
std::sync::Arc,
tracing::Instrument,
Expand Down Expand Up @@ -97,12 +97,15 @@ impl Persistence {
pub async fn save_surplus_capturing_jit_orders_orders(
&self,
auction_id: AuctionId,
surplus_capturing_jit_order_owners: &[Address],
surplus_capturing_jit_order_owners: &[domain::eth::Address],
) -> Result<(), Error> {
self.postgres
.save_surplus_capturing_jit_orders_orders(
auction_id,
surplus_capturing_jit_order_owners,
&surplus_capturing_jit_order_owners
.iter()
.map(|address| ByteArray(address.0.into()))
.collect::<Vec<_>>(),
)
.await
.map_err(Error::DbError)
Expand Down
11 changes: 5 additions & 6 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use {
},
::observe::metrics,
anyhow::Result,
database::{byte_array::ByteArray, order_events::OrderEventLabel},
database::order_events::OrderEventLabel,
model::solver_competition::{
CompetitionAuction,
Order,
Expand Down Expand Up @@ -280,7 +280,7 @@ impl RunLoop {
auction_id,
&surplus_capturing_jit_order_owners
.into_iter()
.map(|address| ByteArray(address.0))
.map(Into::into)
.collect::<Vec<_>>(),
)
.await
Expand Down Expand Up @@ -327,16 +327,15 @@ impl RunLoop {
id: domain::auction::Id,
auction: &domain::Auction,
) -> Vec<Participant<'_>> {
let surplus_capturing_jit_order_owners =
self.surplus_capturing_jit_order_owners.list_all().await;
let request = solve::Request::new(
id,
auction,
&self.market_makable_token_list.all(),
self.solve_deadline,
&surplus_capturing_jit_order_owners
&auction
.surplus_capturing_jit_order_owners
.iter()
.cloned()
.map(|address| address.0)
.collect::<Vec<_>>(),
);
let request = &request;
Expand Down
6 changes: 5 additions & 1 deletion crates/autopilot/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ impl RunLoop {
auction,
&self.trusted_tokens.all(),
self.solve_deadline,
&auction.surplus_capturing_jit_order_owners,
&auction
.surplus_capturing_jit_order_owners
.iter()
.map(|address| address.0)
.collect::<Vec<_>>(),
);
let request = &request;

Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/solvable_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl SolvableOrdersCache {
})
.collect(),
prices,
surplus_capturing_jit_order_owners: cow_amms.iter().map(|cow_amm| cow_amm.address()).cloned().collect(),
surplus_capturing_jit_order_owners: cow_amms.iter().map(|cow_amm| cow_amm.address()).cloned().map(Into::into).collect(),
};
*self.cache.lock().unwrap() = Inner {
auction: Some(auction),
Expand Down

0 comments on commit 3c5df56

Please sign in to comment.