Skip to content

Commit

Permalink
config: support l2-starting-number
Browse files Browse the repository at this point in the history
  • Loading branch information
bendanzhentan committed Dec 4, 2023
1 parent 3db3815 commit 5b25992
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/bot/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func RunCommand(ctx *cli.Context) error {
return fmt.Errorf("failed to migrate l2_contract_events: %w", err)
}

l2ScannedBlock, err := queryL2ScannedBlock(db)
l2ScannedBlock, err := queryL2ScannedBlock(db, cfg.L2StartingNumber)
if err != nil {
return err
}
Expand Down Expand Up @@ -311,8 +311,8 @@ func connect(log log.Logger, dbConfig config.DBConfig) (*gorm.DB, error) {
}

// queryL2ScannedBlock queries the l2_scanned_blocks table for the last scanned block
func queryL2ScannedBlock(db *gorm.DB) (*core.L2ScannedBlock, error) {
l2ScannedBlock := core.L2ScannedBlock{Number: 0}
func queryL2ScannedBlock(db *gorm.DB, l2StartingNumber int64) (*core.L2ScannedBlock, error) {
l2ScannedBlock := core.L2ScannedBlock{Number: l2StartingNumber}
result := db.Order("number desc").Last(&l2ScannedBlock)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
Expand Down
1 change: 1 addition & 0 deletions core/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
)

type Config struct {
L2StartingNumber int64 `toml:"l2-starting-number"`
ProposeTimeWindow int64 `toml:"propose-time-window"`
ChallengeTimeWindow int64 `toml:"challenge-time-window"`

Expand Down

0 comments on commit 5b25992

Please sign in to comment.