Rename variable
This commit is contained in:
parent
8c73c9b689
commit
217bcb0486
|
@ -146,7 +146,7 @@ export const cache = {
|
||||||
id: PublicKey | string,
|
id: PublicKey | string,
|
||||||
obj: AccountInfo<Buffer>,
|
obj: AccountInfo<Buffer>,
|
||||||
parser?: AccountParser,
|
parser?: AccountParser,
|
||||||
isEligibleForSub?: boolean | undefined | ((parsed: any) => boolean),
|
isActive?: boolean | undefined | ((parsed: any) => boolean),
|
||||||
) => {
|
) => {
|
||||||
if (obj.data.length === 0) {
|
if (obj.data.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -167,19 +167,13 @@ export const cache = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEligibleForSub == undefined) isEligibleForSub = true;
|
if (isActive == undefined) isActive = true;
|
||||||
else if (isEligibleForSub instanceof Function)
|
else if (isActive instanceof Function) isActive = isActive(account);
|
||||||
isEligibleForSub = isEligibleForSub(account);
|
|
||||||
|
|
||||||
const isNew = !genericCache.has(address);
|
const isNew = !genericCache.has(address);
|
||||||
|
|
||||||
genericCache.set(address, account);
|
genericCache.set(address, account);
|
||||||
cache.emitter.raiseCacheUpdated(
|
cache.emitter.raiseCacheUpdated(address, isNew, deserialize, isActive);
|
||||||
address,
|
|
||||||
isNew,
|
|
||||||
deserialize,
|
|
||||||
isEligibleForSub,
|
|
||||||
);
|
|
||||||
return account;
|
return account;
|
||||||
},
|
},
|
||||||
get: (pubKey: string | PublicKey) => {
|
get: (pubKey: string | PublicKey) => {
|
||||||
|
@ -417,7 +411,7 @@ export function AccountsProvider({ children = null as any }) {
|
||||||
cache.emitter.onCache(args => {
|
cache.emitter.onCache(args => {
|
||||||
cache.totalObjects += 1;
|
cache.totalObjects += 1;
|
||||||
|
|
||||||
if (args.isNew && args.isEligibleForSub) {
|
if (args.isNew && args.isActive) {
|
||||||
cache.totalSubs += 1;
|
cache.totalSubs += 1;
|
||||||
let id = args.id;
|
let id = args.id;
|
||||||
let deserialize = args.parser;
|
let deserialize = args.parser;
|
||||||
|
|
|
@ -5,17 +5,12 @@ export class CacheUpdateEvent {
|
||||||
id: string;
|
id: string;
|
||||||
parser: any;
|
parser: any;
|
||||||
isNew: boolean;
|
isNew: boolean;
|
||||||
isEligibleForSub: boolean;
|
isActive: boolean;
|
||||||
constructor(
|
constructor(id: string, isNew: boolean, parser: any, isActive: boolean) {
|
||||||
id: string,
|
|
||||||
isNew: boolean,
|
|
||||||
parser: any,
|
|
||||||
isEligibleForSub: boolean,
|
|
||||||
) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
this.isNew = isNew;
|
this.isNew = isNew;
|
||||||
this.isEligibleForSub = isEligibleForSub;
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +53,11 @@ export class EventEmitter {
|
||||||
id: string,
|
id: string,
|
||||||
isNew: boolean,
|
isNew: boolean,
|
||||||
parser: any,
|
parser: any,
|
||||||
isEligibleForSub: boolean,
|
isActive: boolean,
|
||||||
) {
|
) {
|
||||||
this.emitter.emit(
|
this.emitter.emit(
|
||||||
CacheUpdateEvent.type,
|
CacheUpdateEvent.type,
|
||||||
new CacheUpdateEvent(id, isNew, parser, isEligibleForSub),
|
new CacheUpdateEvent(id, isNew, parser, isActive),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue