@@ -6,6 +6,7 @@ use std::io;
66use color_eyre:: owo_colors:: OwoColorize ;
77use data_encoding:: HEXLOWER ;
88use either:: Either ;
9+ use futures:: StreamExt ;
910use masp_primitives:: asset_type:: AssetType ;
1011use masp_primitives:: merkle_tree:: MerklePath ;
1112use masp_primitives:: sapling:: Node ;
@@ -2145,18 +2146,22 @@ pub async fn query_conversions(
21452146 . get_addresses_with_vp_type ( AddressVpType :: Token ) ;
21462147
21472148 // Download conversions from all epochs to facilitate decoding asset types
2148- let mut conversions = BTreeMap :: new ( ) ;
21492149 let from = MaspEpoch :: zero ( ) ;
21502150 let to = rpc:: query_masp_epoch ( context. client ( ) )
21512151 . await
21522152 . expect ( "Unable to query current MASP epoch" ) ;
2153- for epoch in MaspEpoch :: iter_bounds_inclusive ( from, to) {
2154- conversions. append (
2155- & mut rpc:: query_conversions ( context. client ( ) , & epoch)
2156- . await
2157- . expect ( "Conversions should be defined" ) ,
2158- ) ;
2159- }
2153+ let epochs: Vec < _ > = MaspEpoch :: iter_bounds_inclusive ( from, to) . collect ( ) ;
2154+ let conversion_tasks = epochs
2155+ . iter ( )
2156+ . map ( |epoch| rpc:: query_conversions ( context. client ( ) , epoch) ) ;
2157+ let task_stream = futures:: stream:: iter ( conversion_tasks) ;
2158+ let conversions = task_stream
2159+ . buffer_unordered ( 100 )
2160+ . fold ( BTreeMap :: default ( ) , async |mut acc, conversion| {
2161+ acc. append ( & mut conversion. expect ( "Conversion should be defined" ) ) ;
2162+ acc
2163+ } )
2164+ . await ;
21602165
21612166 if args. dump_tree {
21622167 display_line ! ( context. io( ) , "Conversions: {conversions:?}" ) ;
0 commit comments