@elrondnetwork/epoch-watcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published
Elrond Network

Epoch Watcher

Description

Package for monitoring when an epoch changes.

The epoch watcher service must be called inside a scheduler task how often it's needed.

An external storage is needed for storing Elrond Stats data of current epoch. (e.g.: Redis)

Elrond Stats must be loaded from an instance of Elrond API, route: GET /stats.

Usage

await new EpochWatcher({
getEpochWatcherInfo: () => redisClient.get(key),
setEpochWatcherInfo: (epochWatcherInfo) => redisClient.set(key, info, TTL), /* 1 day */,
loadElrondStats: () => elrondApi.getStats(),
callback: (info) => { console.log(`Epoch has changed. New epoch: ${info.newEpoch}.`); },
}).execute();

Models:

export class EpochChangedInfo {
  newEpoch: number;
}
export class EpochWatcherInfo {
  statsLoadTime: number;
  timeLeftUntilEpochChange: number;
  epoch: number;
}

Dependents (0)

Package Sidebar

Install

npm i @elrondnetwork/epoch-watcher

Weekly Downloads

0

Version

1.0.0

License

GPL-3.0-or-later

Unpacked Size

6.19 kB

Total Files

4

Last publish

Collaborators

  • lucian.mincu