Skip to content

Commit

Permalink
feat(eventindexer): speed up sync (#14258)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored and dong77 committed Jul 24, 2023
1 parent 6363f6e commit e10bee7
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions packages/eventindexer/indexer/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/labstack/gommon/log"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
log "github.com/sirupsen/logrus"
)

type FilterFunc func(
Expand Down Expand Up @@ -162,18 +163,26 @@ func L2FilterFunc(
svc *Service,
filterOpts *bind.FilterOpts,
) error {
wg, ctx := errgroup.WithContext(ctx)

for _, s := range svc.swaps {
swaps, err := s.FilterSwap(filterOpts, nil, nil)
if err != nil {
return errors.Wrap(err, "svc.bridge.FilterSwap")
}
swap := s

// only save ones above 0.01 ETH, this is only for Galaxe
// and we dont care about the rest
err = svc.saveSwapEvents(ctx, chainID, swaps)
if err != nil {
return errors.Wrap(err, "svc.saveSwapEvents")
}
wg.Go(func() error {
swaps, err := swap.FilterSwap(filterOpts, nil, nil)
if err != nil {
return errors.Wrap(err, "svc.bridge.FilterSwap")
}

// only save ones above 0.01 ETH, this is only for Galaxe
// and we dont care about the rest
err = svc.saveSwapEvents(ctx, chainID, swaps)
if err != nil {
return errors.Wrap(err, "svc.saveSwapEvents")
}

return nil
})
}

return nil
Expand Down

0 comments on commit e10bee7

Please sign in to comment.