Fallback to another DC if given is unknown

This commit is contained in:
9seconds
2021-09-24 11:47:35 +03:00
parent d0f18be91d
commit fbe4d32590
4 changed files with 44 additions and 1 deletions
+8
View File
@@ -7,6 +7,14 @@ type addressPool struct {
v6 [][]tgAddr
}
func (a addressPool) isValidDC(dc int) bool {
return dc > 0 && dc <= len(a.v4) && dc <= len(a.v6)
}
func (a addressPool) getRandomDC() int {
return 1 + rand.Intn(len(a.v4))
}
func (a addressPool) getV4(dc int) []tgAddr {
return a.get(a.v4, dc-1)
}