From de19a457e311486b666b7969638a399f1a635e1e Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 12 Jan 2025 21:29:10 -0300 Subject: [PATCH] sdk: rename and adjust BatchSizePerNumberOfQueries() -> PerQueryLimitInBatch(). --- sdk/utils.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sdk/utils.go b/sdk/utils.go index 75fceeb..cd932e9 100644 --- a/sdk/utils.go +++ b/sdk/utils.go @@ -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), + ), ), ) }