Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@helium/account-fetch-cache

Package Overview
Dependencies
Maintainers
7
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helium/account-fetch-cache - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2-next.0

54

lib/cjs/accountFetchCache.js

@@ -170,3 +170,3 @@ "use strict";

if (this.currentBatch.size > exports.DEFAULT_CHUNK_SIZE) {
return this.fetchBatch().then(() => { });
return this.fetchBatch();
}

@@ -292,2 +292,6 @@ else {

return __awaiter(this, void 0, void 0, function* () {
// Store results of batch fetches in this map. If isStatic is false, genericCache will have none of the
// results of our searches in the batch. So need to accumulate them here
const result = {};
const searched = new Set(pubKeys.map((p) => p.toBase58()));
for (const key of pubKeys) {

@@ -303,21 +307,43 @@ this.registerParser(key, parser);

if (forceRequery || !this.genericCache.has(address)) {
yield this.addToBatchIgnoreResult(key);
const { keys, array } = (yield this.addToBatchIgnoreResult(key)) || {
keys: [],
array: [],
};
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
const parsed = this.getParsed(key, item, parser) || null;
// Cache these results if they aren't going to change
if (isStatic) {
this.genericCache.set(key, parsed);
}
if (parsed) {
result[key] = parsed;
}
}
}
});
}
}
const searched = new Set(pubKeys.map((p) => p.toBase58()));
// Force a batch fetch to resolve all accounts
const { keys, array } = yield this.fetchBatch();
// Cache these results if they aren't going to change
if (isStatic) {
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
this.genericCache.set(key, this.getParsed(key, item, parser) || null);
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
const parsed = this.getParsed(key, item, parser) || null;
// Cache these results if they aren't going to change
if (isStatic) {
this.genericCache.set(key, parsed);
}
if (parsed) {
result[key] = parsed;
}
}
});
}
return pubKeys.map((key) => this.genericCache.get(key.toBase58()));
}
});
return pubKeys.map((key) => result[key.toBase58()] || this.genericCache.get(key.toBase58()));
});

@@ -324,0 +350,0 @@ }

@@ -156,3 +156,3 @@ import { Connection, PublicKey, Transaction, } from "@solana/web3.js";

if (this.currentBatch.size > DEFAULT_CHUNK_SIZE) {
return this.fetchBatch().then(() => { });
return this.fetchBatch();
}

@@ -271,2 +271,6 @@ else {

forceRequery = false) {
// Store results of batch fetches in this map. If isStatic is false, genericCache will have none of the
// results of our searches in the batch. So need to accumulate them here
const result = {};
const searched = new Set(pubKeys.map((p) => p.toBase58()));
for (const key of pubKeys) {

@@ -282,21 +286,43 @@ this.registerParser(key, parser);

if (forceRequery || !this.genericCache.has(address)) {
await this.addToBatchIgnoreResult(key);
const { keys, array } = (await this.addToBatchIgnoreResult(key)) || {
keys: [],
array: [],
};
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
const parsed = this.getParsed(key, item, parser) || null;
// Cache these results if they aren't going to change
if (isStatic) {
this.genericCache.set(key, parsed);
}
if (parsed) {
result[key] = parsed;
}
}
}
});
}
}
const searched = new Set(pubKeys.map((p) => p.toBase58()));
// Force a batch fetch to resolve all accounts
const { keys, array } = await this.fetchBatch();
// Cache these results if they aren't going to change
if (isStatic) {
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
this.genericCache.set(key, this.getParsed(key, item, parser) || null);
keys.forEach((key, index) => {
this.statics.add(key);
if (searched.has(key)) {
const item = array[index];
if (item) {
const parsed = this.getParsed(key, item, parser) || null;
// Cache these results if they aren't going to change
if (isStatic) {
this.genericCache.set(key, parsed);
}
if (parsed) {
result[key] = parsed;
}
}
});
}
return pubKeys.map((key) => this.genericCache.get(key.toBase58()));
}
});
return pubKeys.map((key) => result[key.toBase58()] || this.genericCache.get(key.toBase58()));
}

@@ -303,0 +329,0 @@ onAccountChange(key, parser, account) {

@@ -52,3 +52,6 @@ /// <reference types="node" />

}>;
addToBatchIgnoreResult(id: PublicKey): Promise<void> | undefined;
addToBatchIgnoreResult(id: PublicKey): Promise<{
keys: string[];
array: AccountInfo<Buffer>[];
}> | undefined;
addToBatch(id: PublicKey): Promise<AccountInfo<Buffer>>;

@@ -55,0 +58,0 @@ flush(): Promise<void>;

{
"name": "@helium/account-fetch-cache",
"version": "0.3.1",
"version": "0.3.2-next.0+58b9ccf8",
"description": "Solana account fetch cache to eliminate reduntant fetching, and batch fetches",

@@ -42,3 +42,3 @@ "publishConfig": {

},
"gitHead": "c42716da4d2ba04f048a371568440fea45b9e3c5"
"gitHead": "58b9ccf8e728f3fb82223a29abcde082da20b678"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc