fix: add a limit of max 10 content topics per query (#3117)

This commit is contained in:
richΛrd 2024-10-16 17:55:04 -04:00 committed by GitHub
parent bdb31cc114
commit c35dc54923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -22,6 +22,7 @@ logScope:
const
DefaultPageSize*: uint = 20
MaxPageSize*: uint = 100
MaxContentTopicsPerQuery*: int = 10
# Retention policy
WakuArchiveDefaultRetentionPolicyInterval* = chronos.minutes(30)
@ -125,6 +126,9 @@ proc findMessages*(
if cursor == EmptyWakuMessageHash:
return err(ArchiveError.invalidQuery("all zeroes cursor hash"))
if query.contentTopics.len > MaxContentTopicsPerQuery:
return err(ArchiveError.invalidQuery("too many content topics"))
let maxPageSize =
if query.pageSize <= 0:
DefaultPageSize