Skip to content

Commit

Permalink
fix: concurrent map write issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Apr 2, 2024
1 parent 0ca13b9 commit 0353423
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions miner/worker_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]*
simResult := make(map[common.Hash]*types.SimulatedBundle)

var wg sync.WaitGroup
var mu sync.Mutex
for i, bundle := range bundles {
if simmed, ok := simCache.GetSimulatedBundle(bundle.Hash()); ok {
simResult[bundle.Hash()] = simmed
Expand All @@ -301,6 +302,8 @@ func (w *worker) simulateBundles(env *environment, bundles []*types.Bundle) ([]*
return
}

mu.Lock()
defer mu.Unlock()
simResult[bundle.Hash()] = simmed
}(i, bundle, env.state.Copy())
}
Expand Down

0 comments on commit 0353423

Please sign in to comment.