File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -126,21 +126,26 @@ func (a *Antiquary) Loop() error {
126126 return nil
127127 }
128128 if a .downloader != nil {
129- completedReply , err := a .downloader .Completed (a .ctx , & downloaderproto.CompletedRequest {})
130- if err != nil {
131- return err
132- }
133129 reCheckTicker := time .NewTicker (3 * time .Second )
134130 defer reCheckTicker .Stop ()
135131
132+ // We need to make sure we 100% finish the download process.
133+ // 1) Define some time completionEpoch window
134+ completionEpoch := 2 * time .Minute
135+ // 2) Define a progress counter
136+ progress := time .Now ()
137+
136138 // Fist part of the antiquate is to download caplin snapshots
137- for ( ! completedReply . Completed || ! doesSnapshotDirHaveBeaconBlocksFiles ( a . dirs . Snap ) ) && ! a .backfilled .Load () {
139+ for ! time . Now (). Add ( completionEpoch ). Before ( progress ) && ! a .backfilled .Load () {
138140 select {
139141 case <- reCheckTicker .C :
140- completedReply , err = a .downloader .Completed (a .ctx , & downloaderproto.CompletedRequest {})
142+ completedReply , err : = a .downloader .Completed (a .ctx , & downloaderproto.CompletedRequest {})
141143 if err != nil {
142144 return err
143145 }
146+ if ! completedReply .Completed {
147+ progress = time .Now () // reset the progress if we are not completed
148+ }
144149 case <- a .ctx .Done ():
145150 }
146151 }
You can’t perform that action at this time.
0 commit comments