@@ -6,6 +6,7 @@ use std::io;
6
6
use color_eyre:: owo_colors:: OwoColorize ;
7
7
use data_encoding:: HEXLOWER ;
8
8
use either:: Either ;
9
+ use futures:: StreamExt ;
9
10
use masp_primitives:: asset_type:: AssetType ;
10
11
use masp_primitives:: merkle_tree:: MerklePath ;
11
12
use masp_primitives:: sapling:: Node ;
@@ -2145,18 +2146,22 @@ pub async fn query_conversions(
2145
2146
. get_addresses_with_vp_type ( AddressVpType :: Token ) ;
2146
2147
2147
2148
// Download conversions from all epochs to facilitate decoding asset types
2148
- let mut conversions = BTreeMap :: new ( ) ;
2149
2149
let from = MaspEpoch :: zero ( ) ;
2150
2150
let to = rpc:: query_masp_epoch ( context. client ( ) )
2151
2151
. await
2152
2152
. 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 ;
2160
2165
2161
2166
if args. dump_tree {
2162
2167
display_line ! ( context. io( ) , "Conversions: {conversions:?}" ) ;
0 commit comments