Skip to content

Commit

Permalink
feat(indexer): Connect processor to cli app
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Cory authored and Will Cory committed Jun 9, 2023
1 parent 368a73d commit 722812d
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions indexer/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/ethereum-optimism/optimism/indexer/api"
"github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum-optimism/optimism/indexer/processor"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/urfave/cli/v2"
Expand All @@ -21,7 +23,9 @@ type Cli struct {
Flags []cli.Flag
}

func runIndexer(ctx *cli.Context) error {
func runProcessor(ctx *cli.Context) error {
var l1Proc *processor.L1Processor
var l2Proc *processor.L2Processor
configPath := ctx.String(ConfigFlag.Name)
conf, err := config.LoadConfig(configPath)

Expand All @@ -31,7 +35,32 @@ func runIndexer(ctx *cli.Context) error {
log.Crit("Failed to load config", "message", err)
}

// finish me
db, err := database.NewDB(conf.DB.Dsn)

if err != nil {
log.Crit("Failed to connect to database", "message", err)
}

// L1 Processor
l1EthClient, err := node.NewEthClient(conf.RPCs.L1RPC)
if err != nil {
return err
}
l1Proc, err = processor.NewL1Processor(l1EthClient, db)
if err != nil {
return err
}

// L2Processor
l2EthClient, err := node.NewEthClient(conf.RPCs.L2RPC)
if err != nil {
return err
}
l2Proc, err = processor.NewL2Processor(l2EthClient, db)

go l1Proc.Start()
go l2Proc.Start()

return nil
}

Expand Down Expand Up @@ -107,7 +136,7 @@ func NewCli(GitVersion string, GitCommit string, GitDate string) *Cli {
Name: "indexer",
Flags: flags,
Description: "Runs the indexing service",
Action: runIndexer,
Action: runProcessor,
},
},
}
Expand Down

0 comments on commit 722812d

Please sign in to comment.