Compare commits

..

No commits in common. "5ebf55204d0eadae87a213703c418ab55df8720a" and "b288ce93564f6c4e78d9ab0de219ffbc44b232e4" have entirely different histories.

2 changed files with 5 additions and 19 deletions

@ -412,11 +412,10 @@ class EventService {
async getEventsFromBlock({ fromBlock, graphMethod, type }) {
try {
// ToDo think about undefined
const graphEvents = await this.getEventsFromGraph({ fromBlock, methodName: graphMethod })
const lastSyncBlock = fromBlock > graphEvents?.lastBlock ? fromBlock : graphEvents?.lastBlock
const rpcEvents = await this.getEventsFromRpc({ fromBlock: lastSyncBlock, type })
const rpcEvents = await this.getEventsFromRpc({ fromBlock, type })
const allEvents = [].concat(rpcEvents || [])
const allEvents = [].concat(graphEvents?.events || [], rpcEvents || [])
if (allEvents.length) {
return {
events: allEvents,

@ -3,7 +3,6 @@ import namehash from 'eth-ens-namehash'
import { BigNumber as BN } from 'bignumber.js'
import { toChecksumAddress, isAddress } from 'web3-utils'
import { graph } from '@/services'
import networkConfig from '@/networkConfig'
import { REGISTRY_DEPLOYED_BLOCK } from '@/constants'
import { sleep, flattenNArray } from '@/utils'
@ -170,21 +169,9 @@ class RelayerRegister {
fetchRelayers = async () => {
const blockRange = 10000
// eslint-disable-next-line prefer-const
let { blockFrom, blockTo, cachedEvents } = await this.getCachedData()
let { blockTo, cachedEvents } = await this.getCachedData()
let allRelayers = cachedEvents
if (!cachedEvents || !cachedEvents.length) {
const { lastSyncBlock, events } = await graph.getAllRegisters(blockFrom)
if (events.length) {
blockTo = lastSyncBlock + 1
cachedEvents = events.map((el) => ({
ensName: el.ensName,
relayerAddress: toChecksumAddress(el.address)
}))
}
}
const currentBlockNumber = await this.provider.getBlockNumber()
const fromBlock = cachedEvents.length === 0 ? REGISTRY_DEPLOYED_BLOCK[1] : blockTo
const blockDifference = currentBlockNumber - fromBlock
@ -194,7 +181,7 @@ class RelayerRegister {
let registerRelayerEvents
let lastSyncBlock = blockTo
if (blockDifference <= 0) {
if (cachedEvents.length > 0 || blockDifference === 0) {
return cachedEvents
} else if (blockDifference >= blockRange) {
toBlock = currentBlockNumber