Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
begmaroman committed Aug 27, 2024
1 parent d0bc399 commit 0b672f9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions reorgdetector/reorgdetector.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,14 @@ func (rd *ReorgDetector) detectReorgInTrackedList(ctx context.Context) error {
for _, hdr := range headers {
// Get the actual header from the network or from the cache
headersCacheLock.Lock()
if headersCache[hdr.Num] == nil {
h, err := rd.client.HeaderByNumber(ctx, big.NewInt(int64(hdr.Num)))
if err != nil {
currentHeader, ok := headersCache[hdr.Num]
if !ok || currentHeader == nil {
if currentHeader, err = rd.client.HeaderByNumber(ctx, big.NewInt(int64(hdr.Num))); err != nil {
headersCacheLock.Unlock()
return fmt.Errorf("failed to get the header: %w", err)
}
headersCache[hdr.Num] = h
headersCache[hdr.Num] = currentHeader
}
currentHeader := headersCache[hdr.Num]
headersCacheLock.Unlock()

// Check if the block hash matches with the actual block hash
Expand Down

0 comments on commit 0b672f9

Please sign in to comment.