Skip to content

Commit

Permalink
Move error handling to after iteration loop
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbuchwald committed Jan 12, 2022
1 parent 24a7d30 commit 9774c5f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugin/evm/atomic_tx_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ func (a *atomicTxRepository) initializeHeightIndex(lastAcceptedHeight uint64) er
// Keep track of the size of the currently pending writes
pendingBytesApproximation := 0
for iter.Next() {
if err := iter.Error(); err != nil {
return fmt.Errorf("atomic tx DB iterator errored while initializing atomic trie: %w", err)
}

// iter.Value() consists of [height packed as uint64] + [tx serialized as packed []byte]
iterValue := iter.Value()
if len(iterValue) < wrappers.LongLen {
Expand Down Expand Up @@ -162,6 +158,9 @@ func (a *atomicTxRepository) initializeHeightIndex(lastAcceptedHeight uint64) er
log.Info("Atomic repository initialization", "indexedTxs", indexedTxs)
}
}
if err := iter.Error(); err != nil {
return fmt.Errorf("atomic tx DB iterator errored while initializing atomic trie: %w", err)
}

// Updated the value stored [maxIndexedHeightKey] to be the lastAcceptedHeight
indexedHeight := make([]byte, wrappers.LongLen)
Expand Down

0 comments on commit 9774c5f

Please sign in to comment.