From 7107f1309d627dd90dc078225389b33323d02fa4 Mon Sep 17 00:00:00 2001 From: Maximilian Langenfeld <15726643+ezdac@users.noreply.github.com> Date: Tue, 7 May 2024 11:48:18 +0200 Subject: [PATCH] Copy MultiGasPool in miner environment --- core/celo_multi_gaspool.go | 13 +++++++++++++ miner/worker.go | 3 +++ 2 files changed, 16 insertions(+) diff --git a/core/celo_multi_gaspool.go b/core/celo_multi_gaspool.go index db8c7e8425..2f64cef4d8 100644 --- a/core/celo_multi_gaspool.go +++ b/core/celo_multi_gaspool.go @@ -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, + } +} diff --git a/miner/worker.go b/miner/worker.go index a5dc2b7b66..ba62d8949a 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -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)