From 7b7ee403ba39874b868683cdfcdd3a6f23794b99 Mon Sep 17 00:00:00 2001 From: Igor Crevar Date: Fri, 31 Mar 2023 10:23:15 +0200 Subject: [PATCH] EVM-568 Increase MaxBlockBacklog for block tracker (#1347) --- tracker/event_tracker.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tracker/event_tracker.go b/tracker/event_tracker.go index 5791b6bad1..882e7bab6e 100644 --- a/tracker/event_tracker.go +++ b/tracker/event_tracker.go @@ -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" ) @@ -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, @@ -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)