Skip to content

Commit

Permalink
feat: scan safe blocks only
Browse files Browse the repository at this point in the history
  • Loading branch information
Candinya committed Jun 19, 2024
1 parent 21d9f6c commit 8da7f52
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/service/indexer/l2/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ func (s *server) Run(ctx context.Context) (err error) {
func (s *server) run(ctx context.Context) (err error) {
for {
// Refresh the latest block number.
if s.blockNumberLatest, err = s.ethereumClient.BlockNumber(ctx); err != nil {
var safeBlockHead *types.Header
if err = s.ethereumClient.Client().CallContext(
ctx, &safeBlockHead,
"eth_getBlockByNumber",
"safe", false,
); err != nil || safeBlockHead == nil {
return fmt.Errorf("get latest block number: %w", err)
}

s.blockNumberLatest = safeBlockHead.Number.Uint64()

zap.L().Info(
"refreshed the latest block number",
zap.Uint64("block.number.local", s.checkpoint.BlockNumber),
Expand Down

0 comments on commit 8da7f52

Please sign in to comment.