Fix defer order to prevent concurrent map write panic (#6736)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2023-01-29 09:06:36 +00:00 committed by GitHub
parent 939587bdab
commit 0ccda84439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()}
}