Skip to content

Commit

Permalink
fix: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
vgorkavenko committed Jul 12, 2023
1 parent 71fb8a8 commit 3996e23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/common/consensus-provider/consensus-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ConsensusProviderService {
protected version = '';
protected genesisTime = 0;
protected defaultMaxSlotDeepCount = 32;
protected lastFinalizedSlot = { slot: 0, fetchTime: 0 };
protected latestSlot = { slot: 0, fetchTime: 0 };

protected endpoints = {
version: 'eth/v1/node/version',
Expand Down Expand Up @@ -123,15 +123,15 @@ export class ConsensusProviderService {
{
maxRetries: this.config.get('CL_API_GET_BLOCK_INFO_MAX_RETRIES'),
useFallbackOnResolved: (r) => {
if (Number(r.data.header.message.slot) > this.lastFinalizedSlot.slot) {
this.lastFinalizedSlot = { slot: Number(r.data.header.message.slot), fetchTime: Number(Date.now()) };
if (Number(r.data.header.message.slot) > this.latestSlot.slot) {
this.latestSlot = { slot: Number(r.data.header.message.slot), fetchTime: Number(Date.now()) };
}
if (processingState.epoch <= Math.trunc(this.lastFinalizedSlot.slot / this.config.get('FETCH_INTERVAL_SLOTS'))) {
// if our last processed epoch is less than last finalized, we shouldn't use fallback
if (processingState.epoch <= Math.trunc(this.latestSlot.slot / this.config.get('FETCH_INTERVAL_SLOTS'))) {
// if our last processed epoch is less than last, we shouldn't use fallback
return false;
} else if (Number(Date.now()) - this.lastFinalizedSlot.fetchTime > 420 * 1000) {
// if 'finalized' slot doesn't change ~7m we must switch to fallback
this.logger.error("Finalized slot hasn't changed in ~7m");
} else if (Number(Date.now()) - this.latestSlot.fetchTime > 420 * 1000) {
// if latest slot doesn't change ~7m we must switch to fallback
this.logger.error("Latest slot hasn't changed in ~7m");
return true;
}
// for other states don't use fallback on resolved
Expand Down
2 changes: 1 addition & 1 deletion src/inspector/inspector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class InspectorService implements OnModuleInit {
setTimeout(() => resolve(undefined), sleepTime * 1000);
});
}
// new finalized epoch has happened, from which parent we can get information about needed state
// new epoch has happened, from which parent we can get information about needed state
const existedHeader = (await this.clClient.getBeaconBlockHeaderOrPreviousIfMissed(chosen.slot)).header.message;
this.logger.log(`Latest epoch [${latestEpoch}]. Next epoch to process [${chosen.epoch}]`);
if (chosen.slot == Number(existedHeader.slot)) {
Expand Down

0 comments on commit 3996e23

Please sign in to comment.