From 874640f765d9b0b388d129188bda482ca6a3dec0 Mon Sep 17 00:00:00 2001 From: Alexander Tesfamichael Date: Sun, 11 Feb 2024 14:00:14 +0100 Subject: [PATCH] feat(demotion_monitor): compress demotion message --- src/phoenix/demotion_monitor.rs | 56 +++++++++++++++++---------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/phoenix/demotion_monitor.rs b/src/phoenix/demotion_monitor.rs index 9cfdcef..57977ff 100644 --- a/src/phoenix/demotion_monitor.rs +++ b/src/phoenix/demotion_monitor.rs @@ -99,33 +99,35 @@ pub async fn run_demotion_monitor(relay_pool: &PgPool, mev_pool: &PgPool) -> Res .collect_vec(); if !demotions.is_empty() { - let message = demotions - .into_iter() - .map(|demotion| { - let builder_id = { - let builder_id = demotion.builder_id.unwrap_or("unknown".to_string()); - telegram_escape(&builder_id) - }; - let builder_pubkey = demotion.builder_pubkey; - let error = escape_code_block(&demotion.sim_error); - let slot = demotion.slot; - formatdoc!( - " - *builder demoted* - - beaconcha\\.in: [{slot}]({explorer_url}/slot/{slot}) - slot: `{slot}` - builder\\_id: `{builder_id}` - builder\\_pubkey: `{builder_pubkey}` - - error: - ``` - {error} - ``` - " - ) - }) - .join("\n\n"); + let message = { + let header = "*builder demoted*"; + let demotion_messages: Vec = demotions + .into_iter() + .map(|demotion| { + let builder_id = { + let builder_id = + demotion.builder_id.unwrap_or_else(|| "unknown".to_string()); + telegram_escape(&builder_id) + }; + let builder_pubkey = demotion.builder_pubkey; + let error = escape_code_block(&demotion.sim_error); + let slot = demotion.slot; + formatdoc!( + " + [beaconcha\\.in/slot/{slot}]({explorer_url}/slot/{slot}) + slot: `{slot}` + builder\\_id: `{builder_id}` + builder\\_pubkey: `{builder_pubkey}` + ``` + {error} + ``` + " + ) + }) + .collect(); + + format!("{}\n\n{}", header, demotion_messages.join("\n\n")) + }; info!(?message, "sending telegram alert");