Skip to content
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
12 changes: 12 additions & 0 deletions tx-submitter/services/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func (r *ReorgDetector) DetectReorg(ctx context.Context) (bool, uint64, error) {
if err != nil {
return false, 0, fmt.Errorf("failed to get latest block: %w", err)
}
if latestBlock == nil {
return false, 0, fmt.Errorf("latest block is nil")
}

// Check each block in history to find reorg point
reorgDepth := uint64(0)
Expand All @@ -61,6 +64,9 @@ func (r *ReorgDetector) DetectReorg(ctx context.Context) (bool, uint64, error) {
if err != nil {
return false, 0, fmt.Errorf("failed to get block %d: %w", info.number, err)
}
if block == nil {
return false, 0, fmt.Errorf("block %d is nil", info.number)
}

if block.Hash() != info.hash {
// Reorg detected
Expand Down Expand Up @@ -92,6 +98,9 @@ func (r *ReorgDetector) updateHistory(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to get latest block: %w", err)
}
if latest == nil {
return fmt.Errorf("latest block is nil")
}

// Add new blocks to history
currentNum := latest.NumberU64()
Expand All @@ -105,6 +114,9 @@ func (r *ReorgDetector) updateHistory(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to get block %d: %w", num, err)
}
if block == nil {
return fmt.Errorf("block %d is nil", num)
}

r.blockHistory = append(r.blockHistory, blockInfo{
number: num,
Expand Down
Loading