Skip to content

Add client-side rate limiting to prevent RPC endpoint abuse #391

Description

@Kingsman-99

Overview

The SDK currently fires RPC requests as fast as callers trigger them. Add a built-in token-bucket rate limiter so the SDK never exceeds the RPC provider's request quota, preventing 429 errors before they happen.

Acceptance Criteria

  • StellarSplitSDK({ rateLimit: { requestsPerSecond: 10 } }) constructor option
  • Token-bucket algorithm: bucket refills at the configured rate; requests block if empty
  • Blocked requests queue and execute in FIFO order once tokens are available
  • Queue capped at 50 pending requests; excess throws RateLimitQueueFullError
  • sdk.getRateLimitStats() returns { tokensAvailable, queuedRequests, totalThrottled }
  • Rate limiting disabled by default; opt-in via config
  • Per-method override: sdk.getLeaderboard({ rateLimit: false }) to bypass for a single call
  • Unit tests: burst of 20 calls with limit of 5/s — verify only 5 fire in the first second

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions