Minor updates #1
1
dist/events/base.d.ts
vendored
1
dist/events/base.d.ts
vendored
@ -184,6 +184,7 @@ export interface CachedRelayerInfo extends RelayerParams {
|
||||
export interface CachedRelayers {
|
||||
timestamp: number;
|
||||
relayers: CachedRelayerInfo[];
|
||||
fromCache?: boolean;
|
||||
}
|
||||
export type BaseRegistryServiceConstructor = {
|
||||
netId: NetIdType;
|
||||
|
9
dist/index.js
vendored
9
dist/index.js
vendored
@ -3344,7 +3344,8 @@ class BaseRegistryService extends BaseEventsService {
|
||||
return __async$8(this, null, function* () {
|
||||
return {
|
||||
timestamp: 0,
|
||||
relayers: []
|
||||
relayers: [],
|
||||
fromCache: true
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -3415,10 +3416,14 @@ class BaseRegistryService extends BaseEventsService {
|
||||
*/
|
||||
updateRelayers() {
|
||||
return __async$8(this, null, function* () {
|
||||
let { timestamp, relayers } = yield this.getSavedRelayers();
|
||||
let { timestamp, relayers, fromCache } = yield this.getSavedRelayers();
|
||||
let shouldSave = fromCache != null ? fromCache : false;
|
||||
if (!relayers.length || timestamp + this.updateInterval < Math.floor(Date.now() / 1e3)) {
|
||||
console.log("\nUpdating relayers from registry\n");
|
||||
({ timestamp, relayers } = yield this.getLatestRelayers());
|
||||
shouldSave = true;
|
||||
}
|
||||
if (shouldSave) {
|
||||
yield this.saveRelayers({ timestamp, relayers });
|
||||
}
|
||||
return { timestamp, relayers };
|
||||
|
9
dist/index.mjs
vendored
9
dist/index.mjs
vendored
@ -3323,7 +3323,8 @@ class BaseRegistryService extends BaseEventsService {
|
||||
return __async$8(this, null, function* () {
|
||||
return {
|
||||
timestamp: 0,
|
||||
relayers: []
|
||||
relayers: [],
|
||||
fromCache: true
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -3394,10 +3395,14 @@ class BaseRegistryService extends BaseEventsService {
|
||||
*/
|
||||
updateRelayers() {
|
||||
return __async$8(this, null, function* () {
|
||||
let { timestamp, relayers } = yield this.getSavedRelayers();
|
||||
let { timestamp, relayers, fromCache } = yield this.getSavedRelayers();
|
||||
let shouldSave = fromCache != null ? fromCache : false;
|
||||
if (!relayers.length || timestamp + this.updateInterval < Math.floor(Date.now() / 1e3)) {
|
||||
console.log("\nUpdating relayers from registry\n");
|
||||
({ timestamp, relayers } = yield this.getLatestRelayers());
|
||||
shouldSave = true;
|
||||
}
|
||||
if (shouldSave) {
|
||||
yield this.saveRelayers({ timestamp, relayers });
|
||||
}
|
||||
return { timestamp, relayers };
|
||||
|
9
dist/index.umd.js
vendored
9
dist/index.umd.js
vendored
@ -59692,7 +59692,8 @@ class BaseRegistryService extends BaseEventsService {
|
||||
return __async(this, null, function* () {
|
||||
return {
|
||||
timestamp: 0,
|
||||
relayers: []
|
||||
relayers: [],
|
||||
fromCache: true
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -59763,10 +59764,14 @@ class BaseRegistryService extends BaseEventsService {
|
||||
*/
|
||||
updateRelayers() {
|
||||
return __async(this, null, function* () {
|
||||
let { timestamp, relayers } = yield this.getSavedRelayers();
|
||||
let { timestamp, relayers, fromCache } = yield this.getSavedRelayers();
|
||||
let shouldSave = fromCache != null ? fromCache : false;
|
||||
if (!relayers.length || timestamp + this.updateInterval < Math.floor(Date.now() / 1e3)) {
|
||||
console.log("\nUpdating relayers from registry\n");
|
||||
({ timestamp, relayers } = yield this.getLatestRelayers());
|
||||
shouldSave = true;
|
||||
}
|
||||
if (shouldSave) {
|
||||
yield this.saveRelayers({ timestamp, relayers });
|
||||
}
|
||||
return { timestamp, relayers };
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tornado/core",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "An SDK for building applications on top of Privacy Pools",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
@ -31,7 +31,7 @@ import {
|
||||
} from '../batch';
|
||||
|
||||
import type { fetchDataOptions } from '../providers';
|
||||
import type { NetIdType, Config, SubdomainMap } from '../networkConfig';
|
||||
import type { NetIdType, SubdomainMap } from '../networkConfig';
|
||||
import { RelayerParams, MIN_STAKE_BALANCE } from '../relayerClient';
|
||||
|
||||
import type {
|
||||
@ -773,6 +773,7 @@ export interface CachedRelayerInfo extends RelayerParams {
|
||||
export interface CachedRelayers {
|
||||
timestamp: number;
|
||||
relayers: CachedRelayerInfo[];
|
||||
fromCache?: boolean;
|
||||
}
|
||||
|
||||
export type BaseRegistryServiceConstructor = {
|
||||
@ -858,6 +859,7 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
|
||||
return {
|
||||
timestamp: 0,
|
||||
relayers: [],
|
||||
fromCache: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -939,13 +941,20 @@ export class BaseRegistryService extends BaseEventsService<RegistersEvents> {
|
||||
* Get cached or latest relayer and save to local
|
||||
*/
|
||||
async updateRelayers(): Promise<CachedRelayers> {
|
||||
let { timestamp, relayers } = await this.getSavedRelayers();
|
||||
// eslint-disable-next-line prefer-const
|
||||
let { timestamp, relayers, fromCache } = await this.getSavedRelayers();
|
||||
|
||||
let shouldSave = fromCache ?? false;
|
||||
|
||||
if (!relayers.length || timestamp + this.updateInterval < Math.floor(Date.now() / 1000)) {
|
||||
console.log('\nUpdating relayers from registry\n');
|
||||
|
||||
({ timestamp, relayers } = await this.getLatestRelayers());
|
||||
|
||||
shouldSave = true;
|
||||
}
|
||||
|
||||
if (shouldSave) {
|
||||
await this.saveRelayers({ timestamp, relayers });
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user