Skip to content

Commit

Permalink
Copy MultiGasPool in miner environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ezdac committed May 7, 2024
1 parent 7d0fbb4 commit 7107f13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/celo_multi_gaspool.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ func (mgp MultiGasPool) GetPool(c *FeeCurrency) *GasPool {
// pools have been created already in the constructor.
return mgp.getOrInitPool(*c, nil)
}

func (mgp MultiGasPool) Copy() *MultiGasPool {
pools := make(map[FeeCurrency]*GasPool, len(mgp.pools))
for fc, gp := range mgp.pools {
gpCpy := *gp
pools[fc] = &gpCpy
}
return &MultiGasPool{
pools: pools,
blockGasLimit: mgp.blockGasLimit,
defaultLimit: mgp.defaultLimit,
}
}
3 changes: 3 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (env *environment) copy() *environment {
gasPool := *env.gasPool
cpy.gasPool = &gasPool
}
if env.multiGasPool != nil {
cpy.multiGasPool = env.multiGasPool.Copy()
}
cpy.txs = make([]*types.Transaction, len(env.txs))
copy(cpy.txs, env.txs)

Expand Down

0 comments on commit 7107f13

Please sign in to comment.