sdk: rename and adjust BatchSizePerNumberOfQueries() -> PerQueryLimitInBatch().

This commit is contained in:
fiatjaf
2025-01-12 21:29:10 -03:00
parent 7be4b02236
commit de19a457e3

View File

@@ -28,16 +28,19 @@ func IsVirtualRelay(url string) bool {
return false
}
// BatchSizePerNumberOfQueries tries to make an educated guess for the batch size given the total filter limit and
// PerQueryLimitInBatch tries to make an educated guess for the batch size given the total filter limit and
// the number of abstract queries we'll be conducting at the same time
func BatchSizePerNumberOfQueries(totalFilterLimit int, numberOfQueries int) int {
func PerQueryLimitInBatch(totalFilterLimit int, numberOfQueries int) int {
if numberOfQueries == 1 || totalFilterLimit*numberOfQueries < 50 {
return totalFilterLimit
}
return int(
math.Ceil(
math.Pow(float64(totalFilterLimit), 0.80) / math.Pow(float64(numberOfQueries), 0.71),
return max(4,
int(
math.Ceil(
float64(totalFilterLimit)/
math.Pow(float64(numberOfQueries), 0.4),
),
),
)
}