Skip to content

Commit

Permalink
EVM-568 Increase MaxBlockBacklog for block tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcrevar committed Mar 30, 2023
1 parent 879cdf5 commit 9a592be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tracker/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

hcf "github.com/hashicorp/go-hclog"
"github.com/umbracle/ethgo"
"github.com/umbracle/ethgo/blocktracker"
"github.com/umbracle/ethgo/jsonrpc"
"github.com/umbracle/ethgo/tracker"
)
Expand Down Expand Up @@ -60,8 +61,12 @@ func (e *EventTracker) Start(ctx context.Context) error {
return err
}

blockMaxBacklog := e.numBlockConfirmations*2 + 1
blockTracker := blocktracker.NewBlockTracker(provider.Eth(), blocktracker.WithBlockMaxBacklog(blockMaxBacklog))

tt, err := tracker.NewTracker(provider.Eth(),
tracker.WithBatchSize(10),
tracker.WithBlockTracker(blockTracker),
tracker.WithStore(store),
tracker.WithFilter(&tracker.FilterConfig{
Async: true,
Expand All @@ -76,6 +81,19 @@ func (e *EventTracker) Start(ctx context.Context) error {
}

go func() {
if err := blockTracker.Start(); err != nil {
e.logger.Error("failed to start blocktracker", "error", err)
}
}()

go func() {
<-ctx.Done()
blockTracker.Close()
store.Close()
}()

go func() {
// Sync method will also call blocktracker.Init(), so no need to call that method here
if err := tt.Sync(ctx); err != nil {
e.logger.Error("failed to sync", "error", err)
}
Expand Down

0 comments on commit 9a592be

Please sign in to comment.