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

Create block filters before poll interval #152

Merged
merged 13 commits into from
Sep 6, 2024
Prev Previous commit
Next Next commit
Lock block listener loop started flag
Signed-off-by: rodion <rodion.lim@partior.com>
  • Loading branch information
rodion-lim-partior committed Sep 4, 2024
commit 7ae9785a5071cc3623587288073a76e53f7b0bf2
7 changes: 5 additions & 2 deletions internal/ethereum/blocklistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ func (bl *blockListener) listenLoop() {
log.L(bl.ctx).Errorf("Failed to establish new block filter: %s", err.Message)
failCount++
continue
} else {
bl.setBlockFilterStatus()
}
bl.setBlockFilterStatus()
}

var blockHashes []ethtypes.HexBytes0xPrefix
Expand Down Expand Up @@ -519,9 +518,13 @@ func (bl *blockListener) dispatchToConsumers(consumers []*blockUpdateConsumer, u
}

func (bl *blockListener) checkStartedLocked(ctx context.Context) {
bl.mux.Lock()
if bl.listenLoopDone == nil {
bl.listenLoopDone = make(chan struct{})
bl.mux.Unlock()
go bl.listenLoop()
} else {
bl.mux.Unlock()
}

bl.blockTillBlockFilterEstablished(ctx)
Expand Down