From 9a31aabf0e06d40cd5297556ee29e0e0f6efb329 Mon Sep 17 00:00:00 2001 From: Leonid Tyurin Date: Tue, 21 Jan 2025 10:02:06 +0100 Subject: [PATCH] feat: sort addresses prior to insert (#1199) --- .../multichain-aggregator-logic/src/repository/addresses.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs b/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs index 160725640..dea15445a 100644 --- a/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs +++ b/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs @@ -21,7 +21,7 @@ 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(db: &C, addresses: Vec
) -> Result<(), DbErr> +pub async fn upsert_many(db: &C, mut addresses: Vec
) -> Result<(), DbErr> where C: ConnectionTrait, { @@ -29,6 +29,7 @@ where 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();