backendRange returns a new start/end range for the backend based on the config parameter query_backend_after. If the returned start == the returned end then backend querying is not necessary.
(start, end uint32, queryBackendAfter time.Duration)
| 281 | // backendRange returns a new start/end range for the backend based on the config parameter |
| 282 | // query_backend_after. If the returned start == the returned end then backend querying is not necessary. |
| 283 | func backendRange(start, end uint32, queryBackendAfter time.Duration) (uint32, uint32) { |
| 284 | now := time.Now() |
| 285 | backendAfter := uint32(now.Add(-queryBackendAfter).Unix()) |
| 286 | |
| 287 | // adjust start/end if necessary. if the entire query range was inside backendAfter then |
| 288 | // start will == end. This signals we don't need to query the backend. |
| 289 | if end > backendAfter { |
| 290 | end = backendAfter |
| 291 | } |
| 292 | if start > backendAfter { |
| 293 | start = backendAfter |
| 294 | } |
| 295 | |
| 296 | return start, end |
| 297 | } |
| 298 | |
| 299 | // buildBackendRequests returns a slice of requests that cover all blocks in the store |
| 300 | // that are covered by start/end. |