Skip to content

Commit

Permalink
Fix defer order to prevent concurrent map write panic (erigontech#6736)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
  • Loading branch information
AlexeyAkhunov and Alexey Sharp authored Jan 29, 2023
1 parent 939587b commit 0ccda84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion turbo/engineapi/fork_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ func (fv *ForkValidator) clear() {

// TryAddingPoWBlock adds a PoW block to the fork validator if possible
func (fv *ForkValidator) TryAddingPoWBlock(block *types.Block) {
defer fv.clean()
fv.lock.Lock()
defer fv.lock.Unlock()
defer fv.clean()
fv.sideForksBlock[block.Hash()] = types.RawBlock{Header: block.Header(), Body: block.RawBody()}
}

Expand Down

0 comments on commit 0ccda84

Please sign in to comment.