From e2e4b47103b56004a34b09d9ca498e1357ca3fc1 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 26 May 2020 15:17:35 -0600 Subject: [PATCH] feat: add singleGossip commitment level --- web3.js/module.d.ts | 2 +- web3.js/module.flow.js | 2 +- web3.js/src/connection.js | 5 +++-- web3.js/test/connection.test.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index ad995c3e3..009a4928e 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -46,7 +46,7 @@ declare module '@solana/web3.js' { value: T; }; - export type Commitment = 'max' | 'recent' | 'root' | 'single'; + export type Commitment = 'max' | 'recent' | 'root' | 'single' | 'singleGossip'; export type LargestAccountsFilter = 'circulating' | 'nonCirculating'; diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index 47c65c9b1..4cc09d173 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -59,7 +59,7 @@ declare module '@solana/web3.js' { value: T, }; - declare export type Commitment = 'max' | 'recent' | 'root' | 'single'; + declare export type Commitment = 'max' | 'recent' | 'root' | 'single' | 'singleGossip'; declare export type LargestAccountsFilter = 'circulating' | 'nonCirculating'; diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index ca5abd7e9..3f48d71c1 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -94,11 +94,12 @@ function notificationResultAndContext(resultDescription: any) { * 'recent': Query the most recent block which has reached 1 confirmation by the connected node * 'root': Query the most recent block which has been rooted by the connected node * 'single': Query the most recent block which has reached 1 confirmation by the cluster + * 'singleGossip': Query the most recent block which has reached 1 confirmation according to votes seen in gossip * * - * @typedef {'max' | 'recent' | 'root' | 'single'} Commitment + * @typedef {'max' | 'recent' | 'root' | 'single' | 'singleGossip'} Commitment */ -export type Commitment = 'max' | 'recent' | 'root' | 'single'; +export type Commitment = 'max' | 'recent' | 'root' | 'single' | 'singleGossip'; /** * Filter for largest accounts query diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index 331eacb52..437076842 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -1056,7 +1056,7 @@ test('get confirmed block', async () => { test('get recent blockhash', async () => { const connection = new Connection(url); - for (const commitment of ['max', 'recent', 'root', 'single']) { + for (const commitment of ['max', 'recent', 'root', 'single', 'singleGossip']) { mockGetRecentBlockhash(commitment); const {blockhash, feeCalculator} = await connection.getRecentBlockhash(