tokenDistance returns the distance between the given tokens from and to. The distance between a token and itself is the whole ring, i.e., math.MaxUint32 + 1.
(from, to uint32)
| 280 | // tokenDistance returns the distance between the given tokens from and to. |
| 281 | // The distance between a token and itself is the whole ring, i.e., math.MaxUint32 + 1. |
| 282 | func tokenDistance(from, to uint32) int64 { |
| 283 | if from < to { |
| 284 | return int64(to - from) |
| 285 | } |
| 286 | // the trailing +1 is needed to ensure that token 0 is counted |
| 287 | return maxTokenValue - int64(from) + int64(to) + 1 |
| 288 | } |
| 289 | |
| 290 | func findFirst(n int, f func(int) bool) int { |
| 291 | for i := range n { |
no outgoing calls