Skip to content

Commit 0602308

Browse files
committed
chore: tweak default polling interval
1 parent 32f3033 commit 0602308

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/clients/createClient.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ test('behavior: cacheTime, pollingInterval based on chain.blockTime', () => {
461461
transport: http(),
462462
})
463463

464-
expect(client.cacheTime).toEqual(Math.floor(base.blockTime / 3))
465-
expect(client.pollingInterval).toEqual(Math.floor(base.blockTime / 3))
464+
expect(client.cacheTime).toEqual(Math.floor(base.blockTime / 2))
465+
expect(client.pollingInterval).toEqual(Math.floor(base.blockTime / 2))
466466
})
467467

468468
describe('extends', () => {

src/clients/createClient.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,12 @@ export function createClient(parameters: ClientConfig): Client {
224224
} = parameters
225225

226226
const blockTime = chain?.blockTime ?? 12_000
227-
const pollingInterval =
228-
parameters.pollingInterval ?? Math.floor(blockTime / 3)
227+
228+
const defaultPollingInterval = Math.min(
229+
Math.max(Math.floor(blockTime / 2), 500),
230+
4_000,
231+
)
232+
const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval
229233
const cacheTime = parameters.cacheTime ?? pollingInterval
230234

231235
const account = parameters.account

0 commit comments

Comments
 (0)