@@ -506,12 +506,12 @@ log_download( fd_snapct_tile_t * ctx,
506506 FD_LOG_NOTICE (( "downloading %s snapshot at slot %lu from configured server with index %lu at https://%s:%hu/%s" ,
507507 full ? "full" : "incremental" , slot , i ,
508508 ctx -> config .sources .servers [ i ].hostname , fd_ushort_bswap ( addr .port ),
509- full ? "snapshot.tar.bz2" : "incremental-snapshot.tar.bz2" ));
509+ full ? ctx -> http_full_snapshot_name : ctx -> http_incr_snapshot_name ));
510510 } else {
511511 FD_LOG_NOTICE (( "downloading %s snapshot at slot %lu from configured server with index %lu at http://" FD_IP4_ADDR_FMT ":%hu/%s" ,
512512 full ? "full" : "incremental" , slot , i ,
513513 FD_IP4_ADDR_FMT_ARGS ( addr .addr ), fd_ushort_bswap ( addr .port ),
514- full ? "snapshot.tar.bz2" : "incremental-snapshot.tar.bz2" ));
514+ full ? ctx -> http_full_snapshot_name : ctx -> http_incr_snapshot_name ));
515515 }
516516 return ;
517517 }
@@ -601,11 +601,6 @@ after_credit( fd_snapct_tile_t * ctx,
601601 ctx -> config .incremental_snapshots = 0 ;
602602 }
603603
604- /* FIXME: Revisit the local age logic with new effective age
605- concept. Measure cluster slot based on snapshots we can
606- download / trust. Reevaluate incremental age after the full
607- snapshot download is completed. etc. etc. */
608-
609604 ulong cluster_slot = ctx -> config .incremental_snapshots ? cluster .incremental : cluster .full ;
610605 ulong local_slot = ctx -> config .incremental_snapshots ? ctx -> local_in .incremental_snapshot_slot : ctx -> local_in .full_snapshot_slot ;
611606 ulong local_slot_with_download = local_slot ;
@@ -657,13 +652,28 @@ after_credit( fd_snapct_tile_t * ctx,
657652 break ;
658653 }
659654
660- ctx -> predicted_incremental .slot = best .incr_slot ;
661- send_expected_slot ( ctx , stem , best .incr_slot );
655+ /* decide whether to use the local incremental snapshot if one
656+ exists and is not too old, otherwise download a new incremental
657+ snapshot. */
658+ ulong cluster_slot = fd_sspeer_selector_cluster_slot ( ctx -> selector ).incremental ;
659+ ulong local_slot = ctx -> local_in .incremental_snapshot_slot ;
660+ int local_too_old = local_slot < fd_ulong_sat_sub ( cluster_slot , ctx -> config .sources .max_local_incremental_age );
661+ if ( FD_LIKELY ( local_slot != ULONG_MAX && !local_too_old ) ) {
662+ ctx -> predicted_incremental .slot = local_slot ;
663+ send_expected_slot ( ctx , stem , local_slot );
662664
663- ctx -> peer = best ;
664- ctx -> state = FD_SNAPCT_STATE_READING_INCREMENTAL_HTTP ;
665- init_load ( ctx , stem , 0 , 0 );
666- log_download ( ctx , 0 , best .addr , best .incr_slot );
665+ FD_LOG_NOTICE (( "reading incremental snapshot at slot %lu from local file `%s`" , ctx -> local_in .incremental_snapshot_slot , ctx -> local_in .incremental_snapshot_path ));
666+ ctx -> state = FD_SNAPCT_STATE_READING_INCREMENTAL_FILE ;
667+ init_load ( ctx , stem , 0 , 1 );
668+ } else {
669+ ctx -> predicted_incremental .slot = best .incr_slot ;
670+ send_expected_slot ( ctx , stem , best .incr_slot );
671+
672+ ctx -> peer = best ;
673+ ctx -> state = FD_SNAPCT_STATE_READING_INCREMENTAL_HTTP ;
674+ init_load ( ctx , stem , 0 , 0 );
675+ log_download ( ctx , 0 , best .addr , best .incr_slot );
676+ }
667677 break ;
668678 }
669679
@@ -724,7 +734,7 @@ after_credit( fd_snapct_tile_t * ctx,
724734 break ;
725735 }
726736
727- if ( FD_LIKELY ( ctx -> local_in . incremental_snapshot_slot == ULONG_MAX ) ) {
737+ if ( FD_LIKELY ( ctx -> download_enabled ) ) {
728738 ctx -> state = FD_SNAPCT_STATE_COLLECTING_PEERS_INCREMENTAL ;
729739 ctx -> deadline_nanos = 0L ;
730740 } else {
@@ -801,6 +811,7 @@ after_credit( fd_snapct_tile_t * ctx,
801811 our local snapshot, we must shutdown the validator. */
802812 FD_LOG_ERR (( "unable to load local snapshot %s and no snapshot peers were configured. aborting." , ctx -> local_in .full_snapshot_path ));
803813 } else {
814+ ctx -> local_in .full_snapshot_slot = ULONG_MAX ;
804815 ctx -> state = FD_SNAPCT_STATE_COLLECTING_PEERS ;
805816 ctx -> deadline_nanos = 0L ;
806817 }
@@ -826,6 +837,7 @@ after_credit( fd_snapct_tile_t * ctx,
826837 our local snapshot, we must shutdown the validator. */
827838 FD_LOG_ERR (( "unable to load local snapshot %s and no snapshot peers were configured. aborting." , ctx -> local_in .full_snapshot_path ));
828839 } else {
840+ ctx -> local_in .incremental_snapshot_slot = ULONG_MAX ;
829841 ctx -> state = FD_SNAPCT_STATE_COLLECTING_PEERS_INCREMENTAL ;
830842 ctx -> deadline_nanos = 0L ;
831843 }
0 commit comments