Skip to content

Commit

Permalink
feat: sort addresses prior to insert (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
lok52 authored Jan 21, 2025
1 parent 5903fd0 commit 9a31aab
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ fn hex_regex() -> &'static Regex {
RE.get_or_init(|| Regex::new(r"^(0x)?[0-9a-fA-F]{3,40}$").unwrap())
}

pub async fn upsert_many<C>(db: &C, addresses: Vec<Address>) -> Result<(), DbErr>
pub async fn upsert_many<C>(db: &C, mut addresses: Vec<Address>) -> Result<(), DbErr>
where
C: ConnectionTrait,
{
if addresses.is_empty() {
return Ok(());
}

addresses.sort_by(|a, b| (a.hash, a.chain_id).cmp(&(b.hash, b.chain_id)));
let addresses = addresses.into_iter().map(|address| {
let model: Model = address.into();
let mut active: ActiveModel = model.into();
Expand Down

0 comments on commit 9a31aab

Please sign in to comment.