File tree 1 file changed +3
-23
lines changed
1 file changed +3
-23
lines changed Original file line number Diff line number Diff line change @@ -145,29 +145,9 @@ impl<'b, B: 'b + DerefMut<Target=dyn BlockSource + 'b> + Sized + Sync + Send> Po
145
145
continue ;
146
146
}
147
147
148
- let result = match block_source. get_best_block ( ) . await {
149
- Err ( e) => Err ( e) ,
150
- Ok ( ( block_hash, height) ) => {
151
- if block_hash == heaviest_chain_tip. header . block_hash ( ) {
152
- Ok ( ChainTip :: Common )
153
- } else {
154
- match block_source. get_header ( & block_hash, height) . await {
155
- Err ( e) => Err ( e) ,
156
- Ok ( chain_tip) => {
157
- crate :: stateless_check_header ( & chain_tip. header ) ?;
158
- if chain_tip. header . block_hash ( ) != block_hash {
159
- Err ( BlockSourceError :: Persistent )
160
- } else if chain_tip. chainwork <= heaviest_chain_tip. chainwork {
161
- Ok ( ChainTip :: Worse ( block_hash, chain_tip) )
162
- } else {
163
- Ok ( ChainTip :: Better ( block_hash, chain_tip) )
164
- }
165
- } ,
166
- }
167
- }
168
- } ,
169
- } ;
170
-
148
+ let mut poller = ChainPoller :: new ( & mut * * block_source as & mut dyn BlockSource ) ;
149
+ let result = poller. poll_chain_tip ( heaviest_chain_tip) . await
150
+ . map ( |( chain_tip, _) | chain_tip) ;
171
151
match result {
172
152
Err ( BlockSourceError :: Persistent ) => {
173
153
* error = BlockSourceError :: Persistent ;
You can’t perform that action at this time.
0 commit comments