@@ -1133,10 +1133,20 @@ func (d *Downloader) reportSnapSyncProgress(force bool) {
11331133 header = d .blockchain .CurrentHeader ()
11341134 block = d .blockchain .CurrentSnapBlock ()
11351135 )
1136- syncedBlocks := block . Number . Uint64 () - d . syncStartBlock
1137- if syncedBlocks == 0 {
1136+ // Prevent reporting if nothing has been synchronized yet
1137+ if block . Number . Uint64 () <= d . syncStartBlock {
11381138 return
11391139 }
1140+ // Prevent reporting noise if the actual chain synchronization (headers
1141+ // and bodies) hasn't started yet. Inserting the ancient header chain is
1142+ // fast enough and would introduce significant bias if included in the count.
1143+ if d .chainCutoffNumber != 0 && block .Number .Uint64 () < d .chainCutoffNumber {
1144+ return
1145+ }
1146+ fetchedBlocks := block .Number .Uint64 () - d .syncStartBlock
1147+ if d .chainCutoffNumber != 0 {
1148+ fetchedBlocks = block .Number .Uint64 () - d .chainCutoffNumber
1149+ }
11401150 // Retrieve the current chain head and calculate the ETA
11411151 latest , _ , _ , err := d .skeleton .Bounds ()
11421152 if err != nil {
@@ -1151,9 +1161,7 @@ func (d *Downloader) reportSnapSyncProgress(force bool) {
11511161 }
11521162 var (
11531163 left = latest .Number .Uint64 () - block .Number .Uint64 ()
1154-
1155- // TODO(rjl493456442) fix the ETA in the pruning mode.
1156- eta = time .Since (d .syncStartTime ) / time .Duration (syncedBlocks ) * time .Duration (left )
1164+ eta = time .Since (d .syncStartTime ) / time .Duration (fetchedBlocks ) * time .Duration (left )
11571165
11581166 progress = fmt .Sprintf ("%.2f%%" , float64 (block .Number .Uint64 ())* 100 / float64 (latest .Number .Uint64 ()))
11591167 headers = fmt .Sprintf ("%v@%v" , log .FormatLogfmtUint64 (header .Number .Uint64 ()), common .StorageSize (headerBytes ).TerminalString ())
0 commit comments