Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVM-568 Increase MaxBlockBacklog for block tracker #1347

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 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 @@ -75,6 +80,24 @@ func (e *EventTracker) Start(ctx context.Context) error {
return err
}

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

return
}

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() {
if err := tt.Sync(ctx); err != nil {
e.logger.Error("failed to sync", "error", err)
Expand Down