Skip to content

Commit

Permalink
Merge pull request #15 from kdembler/rpc-rate-limit
Browse files Browse the repository at this point in the history
add env variable for RPC rate limit
  • Loading branch information
zeeshanakram3 committed Jan 25, 2024
2 parents 2c8eca9 + e1445db commit f4302c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ ARCHIVE_GATEWAY_URL=${CUSTOM_ARCHIVE_GATEWAY_URL:-https://v2.archive.subsquid.io
# Use private endpoints in production!
RPC_ENDPOINT=wss://rpc.joystream.org:9944

# Rate limit for RPC sync
RPC_RATE_LIMIT=10

# Uncommenting this line enables the debug mode
# More info at https://docs.subsquid.io/basics/logging/
#SQD_DEBUG=*
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.3

- Allow configuring RPC rate limit via `RPC_RATE_LIMIT` environment variable.

# 1.4.2

- **FIX**: Bump Subsquid processor (`@subsquid/substrate-processor`) version to include fix for switching to RPC when processing unfinalized blocks.
Expand Down Expand Up @@ -29,4 +33,4 @@

# 1.0.0

- Initial release of `storage-squid` package.
- Initial release of `storage-squid` package.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storage-squid",
"version": "1.4.2",
"version": "1.4.3",
"engines": {
"node": ">=16"
},
Expand Down
3 changes: 2 additions & 1 deletion src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ const eventNames = Object.keys(eventHandlers)
const archiveUrl = process.env.ARCHIVE_GATEWAY_URL

const rpcURL = process.env.RPC_ENDPOINT || 'http://localhost:9944/'
const rpcRateLimit = parseInt(process.env.RPC_RATE_LIMIT || '10')

const maxCachedEntities = parseInt(process.env.MAX_CACHED_ENTITIES || '1000')

PROCESSOR.setDataSource({
...(archiveUrl ? { archive: archiveUrl } : {}),
chain: {
url: rpcURL,
rateLimit: 10,
rateLimit: rpcRateLimit,
},
}).addEvent({
name: eventNames,
Expand Down

0 comments on commit f4302c0

Please sign in to comment.