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) } }