MCPcopy Create free account
hub / github.com/CPChain/chain / rescheduleFetch

Method rescheduleFetch

protocols/cpc/fetcher/fetcher.go:575–588  ·  view source on GitHub ↗

rescheduleFetch resets the specified fetch timer to the next announce timeout. A block is fetched after arriveTimeout.

(fetch *time.Timer)

Source from the content-addressed store, hash-verified

573// rescheduleFetch resets the specified fetch timer to the next announce timeout.
574// A block is fetched after arriveTimeout.
575func (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.
591func (f *Fetcher) rescheduleComplete(complete *time.Timer) {

Callers 1

loopMethod · 0.95

Calls 2

NowMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected