mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-09-06 21:21:36 +02:00
sdk: rename and adjust BatchSizePerNumberOfQueries() -> PerQueryLimitInBatch().
This commit is contained in:
11
sdk/utils.go
11
sdk/utils.go
@@ -28,16 +28,19 @@ func IsVirtualRelay(url string) bool {
|
|||||||
return false
|
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
|
// 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 {
|
if numberOfQueries == 1 || totalFilterLimit*numberOfQueries < 50 {
|
||||||
return totalFilterLimit
|
return totalFilterLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
return int(
|
return max(4,
|
||||||
|
int(
|
||||||
math.Ceil(
|
math.Ceil(
|
||||||
math.Pow(float64(totalFilterLimit), 0.80) / math.Pow(float64(numberOfQueries), 0.71),
|
float64(totalFilterLimit)/
|
||||||
|
math.Pow(float64(numberOfQueries), 0.4),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user