File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -112,15 +112,26 @@ impl Blockchain for ElectrumBlockchain {
112112 }
113113
114114 Request :: Conftime ( conftimereq) => {
115- let needs_block_height = conftimereq
116- . request ( )
117- . filter_map ( |txid| txid_to_height. get ( txid) . cloned ( ) )
118- . filter ( |height| block_times. get ( height) . is_none ( ) )
119- . take ( chunk_size)
120- . collect :: < HashSet < _ > > ( ) ;
121-
122- let new_block_headers =
123- self . client . batch_block_header ( needs_block_height. clone ( ) ) ?;
115+ // collect up to chunk_size heights to fetch from electrum
116+ let needs_block_height = {
117+ let mut needs_block_height_iter = conftimereq
118+ . request ( )
119+ . filter_map ( |txid| txid_to_height. get ( txid) . cloned ( ) )
120+ . filter ( |height| block_times. get ( height) . is_none ( ) ) ;
121+ let mut needs_block_height = HashSet :: new ( ) ;
122+
123+ while needs_block_height. len ( ) < chunk_size {
124+ match needs_block_height_iter. next ( ) {
125+ Some ( height) => needs_block_height. insert ( height) ,
126+ None => break ,
127+ } ;
128+ }
129+ needs_block_height
130+ } ;
131+
132+ let new_block_headers = self
133+ . client
134+ . batch_block_header ( needs_block_height. iter ( ) . cloned ( ) ) ?;
124135
125136 for ( height, header) in needs_block_height. into_iter ( ) . zip ( new_block_headers) {
126137 block_times. insert ( height, header. time ) ;
You can’t perform that action at this time.
0 commit comments