Skip to content

Commit

Permalink
refactor(eth1indexer): update ens in seperate go-routine (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush authored Sep 16, 2024
1 parent 100529b commit 2c55bd2
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions backend/cmd/eth1indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ func Run() {
}()
}

if *enableEnsUpdater {
go ImportEnsUpdatesLoop(bt, client, *ensBatchSize)
}

if *enableFullBalanceUpdater {
ProcessMetadataUpdates(bt, client, balanceUpdaterPrefix, *balanceUpdaterBatchSize, -1)
return
Expand Down Expand Up @@ -375,21 +379,26 @@ func Run() {
ProcessMetadataUpdates(bt, client, balanceUpdaterPrefix, *balanceUpdaterBatchSize, 10)
}

if *enableEnsUpdater {
err := bt.ImportEnsUpdates(client.GetNativeClient(), *ensBatchSize)
if err != nil {
log.Error(err, "error importing ens updates", 0, nil)
continue
}
}

log.Infof("index run completed")
services.ReportStatus("eth1indexer", "Running", nil)
}

// utils.WaitForCtrlC()
}

func ImportEnsUpdatesLoop(bt *db.Bigtable, client *rpc.ErigonClient, batchSize int64) {
time.Sleep(time.Second * 5)
for {
err := bt.ImportEnsUpdates(client.GetNativeClient(), batchSize)
if err != nil {
log.Error(err, "error importing ens updates", 0, nil)
} else {
services.ReportStatus("ensIndexer", "Running", nil)
}
time.Sleep(time.Second * 5)
}
}

func UpdateTokenPrices(bt *db.Bigtable, client *rpc.ErigonClient, tokenListPath string) error {
tokenListContent, err := os.ReadFile(tokenListPath)
if err != nil {
Expand Down

0 comments on commit 2c55bd2

Please sign in to comment.