Add zstd compression (#12)
* Use ZSTD compression for GMA calls --------- Co-authored-by: solpkr <solpkr1@gmail.com>
This commit is contained in:
parent
de728f2861
commit
881cbf7cb0
|
@ -32,6 +32,7 @@
|
|||
"axios": "^1.3.2",
|
||||
"bn.js": "^5.1.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"fzstd": "^0.1.0",
|
||||
"tslog": "^3.3.4"
|
||||
},
|
||||
"resolutions": {
|
||||
|
|
|
@ -5,6 +5,8 @@ import {
|
|||
PublicKey,
|
||||
} from '@solana/web3.js';
|
||||
|
||||
import * as fzstd from 'fzstd';
|
||||
|
||||
export async function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
@ -40,7 +42,10 @@ export async function getMultipleAccounts(
|
|||
// set no minimum context slot by default
|
||||
minContextSlot ||= 0;
|
||||
|
||||
const args = commitment ? [publicKeyStrs, { commitment,minContextSlot }] : [publicKeyStrs, {minContextSlot}];
|
||||
//use zstd to compress large responses
|
||||
let encoding = 'base64+zstd';
|
||||
|
||||
const args = [publicKeyStrs, {commitment,encoding,minContextSlot}];
|
||||
|
||||
// @ts-ignore
|
||||
const resp = await connection._rpcRequest('getMultipleAccounts', args);
|
||||
|
@ -61,7 +66,7 @@ export async function getMultipleAccounts(
|
|||
publicKey: publicKeys[i],
|
||||
context: resp.result.context,
|
||||
accountInfo: {
|
||||
data: Buffer.from(data[0], 'base64'),
|
||||
data: Buffer.from(fzstd.decompress(Buffer.from(data[0], 'base64'))),
|
||||
executable,
|
||||
owner: new PublicKey(owner),
|
||||
lamports,
|
||||
|
|
Loading…
Reference in New Issue