rescheduleFetch resets the specified fetch timer to the next announce timeout. A block is fetched after arriveTimeout.
(fetch *time.Timer)
| 573 | // rescheduleFetch resets the specified fetch timer to the next announce timeout. |
| 574 | // A block is fetched after arriveTimeout. |
| 575 | func (f *Fetcher) rescheduleFetch(fetch *time.Timer) { |
| 576 | // Short circuit if no blocks are announced |
| 577 | if len(f.announced) == 0 { |
| 578 | return |
| 579 | } |
| 580 | // Otherwise find the earliest expiring announcement |
| 581 | earliest := time.Now() |
| 582 | for _, announces := range f.announced { |
| 583 | if earliest.After(announces[0].time) { |
| 584 | earliest = announces[0].time |
| 585 | } |
| 586 | } |
| 587 | fetch.Reset(arriveTimeout - time.Since(earliest)) |
| 588 | } |
| 589 | |
| 590 | // rescheduleComplete resets the specified completion timer to the next fetch timeout. |
| 591 | func (f *Fetcher) rescheduleComplete(complete *time.Timer) { |