starknet.js
starknet.js copied to clipboard
feat: rpc batch requests
Motivation and Resolution
The BatchClient class allows requests to be batched together, either by the interval amount, or at the end of the callback queue if set to 0. By batching requests, we can reduce the overhead associated with handling individual requests, optimize resource utilization and improve overall performance.
Request:
Response:
closes #758
Usage related changes
batchoption added to RpcProvider options.
Development related changes
BatchClientclass created to manage batching of requests.
Checklist:
- [x] Performed a self-review of the code
- [x] Rebased to the last commit of the target branch (or merged it into my branch)
- [x] Linked the issues which this PR resolves
- [ ] Documented the changes in code (API docs will be generated automatically)
- [ ] Updated the tests
- [x] All tests are passing
I haven't gone into details yet, on first look, it seems good, but we need tests. Can you please add tests for new Classes and Batch requests, we must have tests for it before merging. Can you add a section to www/ documentation about usage? (optional - this can be done in separate PR)
Hi @tabaktoni sorry for late reply, I didn't see the notification. I will add the tests ASAP. There is only a single function to test, won't take long. But about documentation, the new Batch class is only used in the RpcChannel class, it's not used externally and is not exported. If it's not preferred to have a class for this, we can also convert it to a function. But I thought a class would be easier and cleaner. Only usage change is a new batch option. I will add this option to the documentation.
Hi @tabaktoni sorry for late reply. I've added tests and also moved the BatchClient class to utils, instead of the src. It is ready to review.
:tada: This issue has been resolved in version 6.12.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: