@@ -14,6 +14,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
1414use bdk_chain:: { BlockId , ConfirmationBlockTime , TxUpdate } ;
1515use bdk_wallet:: { KeychainKind , Update } ;
1616use bip157:: chain:: { BlockHeaderChanges , ChainState } ;
17+ use bip157:: error:: FetchBlockError ;
1718use bip157:: {
1819 BlockHash , Builder , Client , Event , HeaderCheckpoint , Info , Node as CbfNode , Requester ,
1920 SyncUpdate , TrustedPeer , Warning ,
@@ -989,54 +990,65 @@ impl CbfChainSource {
989990 // On later iterations we may walk past Kyoto's known header range and
990991 // hit `UnknownHash`; in that case we use whatever blocks we already
991992 // have rather than failing the whole fee update.
992- let indexed_block =
993- match tokio:: time:: timeout ( remaining_timeout, requester. get_block ( current_hash) )
994- . await
995- {
996- Ok ( Ok ( indexed_block) ) => indexed_block,
997- Ok ( Err ( e) ) if idx == 0 => {
998- log_debug ! (
999- self . logger,
1000- "Cached CBF tip {} was unavailable during fee estimation, \
993+ let indexed_block = match tokio:: time:: timeout (
994+ remaining_timeout,
995+ requester. get_block ( current_hash) ,
996+ )
997+ . await
998+ {
999+ Ok ( Ok ( indexed_block) ) => indexed_block,
1000+ Ok ( Err ( e) ) if idx == 0 => {
1001+ log_debug ! (
1002+ self . logger,
1003+ "Cached CBF tip {} was unavailable during fee estimation, \
10011004 likely due to initial sync or a reorg: {:?}",
1002- current_hash,
1003- e
1004- ) ;
1005- * self . latest_tip . lock ( ) . unwrap ( ) = None ;
1006- return Ok ( None ) ;
1007- } ,
1008- Ok ( Err ( e ) ) => {
1009- log_debug ! (
1005+ current_hash,
1006+ e
1007+ ) ;
1008+ * self . latest_tip . lock ( ) . unwrap ( ) = None ;
1009+ return Ok ( None ) ;
1010+ } ,
1011+ Ok ( Err ( FetchBlockError :: UnknownHash ) ) => {
1012+ log_debug ! (
10101013 self . logger,
1011- "CBF could not serve block {} during fee estimation after {} successful fetches: {:?} " ,
1014+ "CBF walked past known header range at {} during fee estimation after {} successful fetches. " ,
10121015 current_hash,
10131016 block_fee_rates. len( ) ,
1014- e
10151017 ) ;
1016- break ;
1017- } ,
1018- Err ( e) if idx == 0 => {
1019- log_debug ! (
1018+ break ;
1019+ } ,
1020+ Ok ( Err ( e) ) => {
1021+ log_error ! (
10201022 self . logger,
1021- "Timed out fetching cached CBF tip {} during fee estimation, \
1022- likely due to initial sync or a reorg: {}",
1023+ "Failed to fetch block {} during fee estimation after {} successful fetches: {:?}" ,
10231024 current_hash,
1025+ block_fee_rates. len( ) ,
10241026 e
10251027 ) ;
1026- * self . latest_tip . lock ( ) . unwrap ( ) = None ;
1027- return Ok ( None ) ;
1028- } ,
1029- Err ( e) => {
1030- log_debug ! (
1028+ break ;
1029+ } ,
1030+ Err ( e) if idx == 0 => {
1031+ log_debug ! (
1032+ self . logger,
1033+ "Timed out fetching cached CBF tip {} during fee estimation, \
1034+ likely due to initial sync or a reorg: {}",
1035+ current_hash,
1036+ e
1037+ ) ;
1038+ * self . latest_tip . lock ( ) . unwrap ( ) = None ;
1039+ return Ok ( None ) ;
1040+ } ,
1041+ Err ( e) => {
1042+ log_debug ! (
10311043 self . logger,
10321044 "Timed out fetching block {} during fee estimation after {} successful fetches: {}" ,
10331045 current_hash,
10341046 block_fee_rates. len( ) ,
10351047 e
10361048 ) ;
1037- break ;
1038- } ,
1039- } ;
1049+ break ;
1050+ } ,
1051+ } ;
10401052
10411053 let height = indexed_block. height ;
10421054 let block = & indexed_block. block ;
0 commit comments