Fix calculation of hashed rate limit keys

This commit is contained in:
dolfies 2025-06-25 21:05:13 -04:00 committed by GitHub
parent a62b25c6c0
commit 20055e7cc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -673,14 +673,13 @@ class HTTPClient:
_log.debug(fmt, route_key, bucket_hash, discord_hash) _log.debug(fmt, route_key, bucket_hash, discord_hash)
self._bucket_hashes[route_key] = discord_hash self._bucket_hashes[route_key] = discord_hash
recalculated_key = discord_hash + route.major_parameters self._buckets[f'{discord_hash}:{route.major_parameters}'] = ratelimit
self._buckets[recalculated_key] = ratelimit
self._buckets.pop(key, None) self._buckets.pop(key, None)
elif route_key not in self._bucket_hashes: elif route_key not in self._bucket_hashes:
fmt = '%s has found its initial rate limit bucket hash (%s).' fmt = '%s has found its initial rate limit bucket hash (%s).'
_log.debug(fmt, route_key, discord_hash) _log.debug(fmt, route_key, discord_hash)
self._bucket_hashes[route_key] = discord_hash self._bucket_hashes[route_key] = discord_hash
self._buckets[discord_hash + route.major_parameters] = ratelimit self._buckets[f'{discord_hash}:{route.major_parameters}'] = ratelimit
if has_ratelimit_headers: if has_ratelimit_headers:
if response.status != 429: if response.status != 429: