Skip to content

Commit

Permalink
add getPendingRequestQueueSize
Browse files Browse the repository at this point in the history
  • Loading branch information
luu-alex committed Oct 4, 2023
1 parent 90d78c1 commit 715cfe2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/web3-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ Documentation:

- `soliditySha3()` with BigInt support

## [Unreleased]
## [Unreleased]

### Added

- `SocketProvider` now contains public function `getPendingRequestQueueSize` (#6451)
9 changes: 9 additions & 0 deletions packages/web3-utils/src/socket_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ export abstract class SocketProvider<
protected _validateProviderPath(path: string): boolean {
return !!path;
}

/**
*
* @returns the pendingRequestQueue size
*/
// eslint-disable-next-line class-methods-use-this
public getPendingRequestQueueSize() {
return this._pendingRequestsQueue.size;
}

/**
*
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-utils/test/unit/socket_provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ describe('SocketProvider', () => {
});
// @ts-expect-error run protected method
expect(provider._pendingRequestsQueue.size).toBe(1);

expect(provider.getPendingRequestQueueSize()).toBe(1);
const payload2 = { id: 2, method: 'some_rpc_method' };
provider.setStatus('connected');
const req2 = provider.request(payload2);
Expand All @@ -331,6 +331,7 @@ describe('SocketProvider', () => {
provider._clearQueues();
// @ts-expect-error run protected method
expect(provider._pendingRequestsQueue.size).toBe(0);
expect(provider.getPendingRequestQueueSize()).toBe(0);
// @ts-expect-error run protected method
expect(provider._sentRequestsQueue.size).toBe(0);
});
Expand Down

0 comments on commit 715cfe2

Please sign in to comment.