fix: a much simpler way to prevent getRecentPerformanceSamples from sending a commitment

This commit is contained in:
steveluscher 2022-07-01 22:34:05 -07:00
parent b1f8baf6ad
commit 6b82235fab
1 changed files with 3 additions and 8 deletions

View File

@ -195,9 +195,6 @@ type RpcRequest = (methodName: string, args: Array<any>) => Promise<any>;
type RpcBatchRequest = (requests: RpcParams[]) => Promise<any[]>;
const NO_COMMITMENT =
typeof Symbol === 'function' ? Symbol('NO_COMMITMENT') : ({} as const);
/**
* @internal
*/
@ -3434,10 +3431,9 @@ export class Connection {
async getRecentPerformanceSamples(
limit?: number,
): Promise<Array<PerfSample>> {
const args = this._buildArgs(limit ? [limit] : [], NO_COMMITMENT);
const unsafeRes = await this._rpcRequest(
'getRecentPerformanceSamples',
args,
limit ? [limit] : [],
);
const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
if ('error' in res) {
@ -5065,12 +5061,11 @@ export class Connection {
_buildArgs(
args: Array<any>,
override?: Commitment | typeof NO_COMMITMENT,
override?: Commitment,
encoding?: 'jsonParsed' | 'base64',
extra?: any,
): Array<any> {
const commitment =
override === NO_COMMITMENT ? undefined : override || this._commitment;
const commitment = override || this._commitment;
if (commitment || encoding || extra) {
let options: any = {};
if (encoding) {