-func connIsIpv6(nc net.Conn) bool {
- ra := nc.RemoteAddr()
- rip := missinggo.AddrIP(ra)
- return rip.To4() == nil && rip.To16() != nil
+func maxInt(as ...int) int {
+ ret := as[0]
+ for _, a := range as[1:] {
+ if a > ret {
+ ret = a
+ }
+ }
+ return ret
+}
+
+func min(as ...int64) int64 {
+ ret := as[0]
+ for _, a := range as[1:] {
+ if a < ret {
+ ret = a
+ }
+ }
+ return ret
+}
+
+func minInt(as ...int) int {
+ ret := as[0]
+ for _, a := range as[1:] {
+ if a < ret {
+ ret = a
+ }
+ }
+ return ret
+}
+
+var unlimited = rate.NewLimiter(rate.Inf, 0)
+
+type (
+ pieceIndex = int
+ // Deprecated: Use infohash.T directly to avoid unnecessary imports.
+ InfoHash = infohash.T
+ IpPort = missinggo.IpPort
+)
+
+func boolSliceToBitmap(slice []bool) (rb roaring.Bitmap) {
+ for i, b := range slice {
+ if b {
+ rb.AddInt(i)
+ }
+ }
+ return