diff --git a/jormungandr/src/fragment/pool.rs b/jormungandr/src/fragment/pool.rs index 3015809cda..7340dbe784 100644 --- a/jormungandr/src/fragment/pool.rs +++ b/jormungandr/src/fragment/pool.rs @@ -154,7 +154,7 @@ impl Pool { pub async fn insert_and_propagate_all( &mut self, origin: FragmentOrigin, - fragments: Vec<(Fragment, FragmentId)>, + fragments: Vec, fail_fast: bool, ) -> Result { tracing::debug!(origin = ?origin, "received {} fragments", fragments.len()); @@ -162,7 +162,10 @@ impl Pool { let mut filtered_fragments = Vec::new(); let mut rejected = Vec::new(); - let mut fragments = fragments.into_iter(); + let mut fragments = fragments.into_iter().map(|el| { + let id = el.hash(); + (el, id) + }); let tip = self.tip.get_ref().await; let ledger = tip.ledger(); diff --git a/jormungandr/src/fragment/process.rs b/jormungandr/src/fragment/process.rs index c7fca76750..ceeedab4ef 100644 --- a/jormungandr/src/fragment/process.rs +++ b/jormungandr/src/fragment/process.rs @@ -8,7 +8,6 @@ use crate::{ task::TokioServiceInfo, }, }; -use chain_core::property::Fragment; use futures::{future, TryFutureExt}; use std::{ collections::HashMap, @@ -138,10 +137,7 @@ impl Process { async { let stats_counter = stats_counter.clone(); let summary = pool - .insert_and_propagate_all(origin, fragments.into_iter().map(|el| { - let id = el.id(); - (el, id) - }).collect(), fail_fast) + .insert_and_propagate_all(origin, fragments, fail_fast) .await?; stats_counter.add_tx_recv_cnt(summary.accepted.len()); diff --git a/jormungandr/src/rest/v0/mod.rs b/jormungandr/src/rest/v0/mod.rs index 35605fee68..1a24753d68 100644 --- a/jormungandr/src/rest/v0/mod.rs +++ b/jormungandr/src/rest/v0/mod.rs @@ -10,6 +10,25 @@ pub fn filter( let with_context = warp::any().map(move || context.clone()); let root = warp::path!("v0" / ..); + #[cfg(feature = "evm")] + let address_mapping = { + let root = warp::path!("address_mapping" / ..); + + let get_jor_address = warp::path!("jormungandr_address" / String) + .and(warp::get()) + .and(with_context.clone()) + .and_then(handlers::get_jor_address) + .boxed(); + + let get_evm_address = warp::path!("evm_address" / String) + .and(warp::get()) + .and(with_context.clone()) + .and_then(handlers::get_evm_address) + .boxed(); + + root.and(get_jor_address.or(get_evm_address)).boxed() + }; + let shutdown = warp::path!("shutdown") .and(warp::get().or(warp::post())) .and(with_context.clone()) @@ -221,31 +240,12 @@ pub fn filter( let vote_plans = warp::path!("plans") .and(warp::get()) - .and(with_context.clone()) + .and(with_context) .and_then(handlers::get_active_vote_plans) .boxed(); root.and(committees.or(vote_plans)).boxed() }; - #[cfg(feature = "evm")] - let address_mapping = { - let root = warp::path!("address_mapping" / ..); - - let get_jor_address = warp::path!("jormungandr_address" / String) - .and(warp::get()) - .and(with_context.clone()) - .and_then(handlers::get_jor_address) - .boxed(); - - let get_evm_address = warp::path!("evm_address" / String) - .and(warp::get()) - .and(with_context) - .and_then(handlers::get_evm_address) - .boxed(); - - root.and(get_jor_address.or(get_evm_address)).boxed() - }; - let routes = shutdown .or(account) .or(block)