Skip to content

Commit

Permalink
Merge pull request #572 from ava-labs/repo-iter-error
Browse files Browse the repository at this point in the history
Move error handling to after iteration loop
  • Loading branch information
aaronbuchwald authored Jan 18, 2022
2 parents 6a9529f + 9774c5f commit a8e9c65
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 @@ -122,10 +122,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 @@ -168,6 +164,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 a8e9c65

Please sign in to comment.