eth-blob-indexer/cmd/blobscan-scraper/main.go
Roy Crihfield 1d1ee73ff2
Some checks failed
Tests / Run Blobscan scraper tests (push) Successful in 2m23s
Tests / Run Beacon collector tests (push) Failing after 22m23s
Implement Blobscan scraper (#2)
New utility to backfill data from Blobscan.

Reviewed-on: #2
2024-07-01 14:01:27 +00:00

50 lines
1.4 KiB
Go

package main
import (
"context"
"log/slog"
"github.com/cerc-io/eth-blob-indexer/cmd"
"github.com/cerc-io/eth-blob-indexer/pkg/blobscan"
"github.com/cerc-io/eth-blob-indexer/pkg/storage"
"github.com/go-redis/redis/v8"
)
const (
defaultBlobscanAddr = "https://api.blobscan.com"
)
func main() {
var BlobscanAddress string
var FromBlock, ToBlock uint64
var BlockStep uint64
cmd.Flags.StringVar(&BlobscanAddress,
"blobscan-addr", defaultBlobscanAddr, "Address of the Blobscan API")
cmd.Flags.Uint64Var(&FromBlock,
"from-block", 0, "EL block number to start scanning from")
cmd.Flags.Uint64Var(&ToBlock,
"to-block", 0, "EL block number to scan up to (0 for no limit))")
cmd.Flags.Uint64Var(&BlockStep,
"block-step", blobscan.BlobscanMaxResults, "Number of blocks to fetch per API call")
cmd.ParseFlags()
if BlockStep > blobscan.BlobscanMaxResults {
slog.Warn("Block step exceeds max results supported by API",
"block-step", BlockStep, "max", blobscan.BlobscanMaxResults)
}
indexer := &blobscan.BlobscanScraper{URL: BlobscanAddress, BlockStep: BlockStep}
rdb := redis.NewClient(&redis.Options{
Addr: cmd.RedisAddress,
})
db := storage.NewRedisStorage(rdb)
slog.Info("Starting indexer", "blobscan", BlobscanAddress, "redis", cmd.RedisAddress)
err := indexer.ScrapeBlobs(context.Background(), FromBlock, ToBlock, db)
if err != nil {
panic(err)
}
}