@@ -8,16 +8,6 @@ import (
8
8
"github.com/ethereum/go-ethereum/params"
9
9
)
10
10
11
- type chainData struct {
12
- chainConfig * params.ChainConfig
13
- chain * core.BlockChain
14
- blacklist map [common.Address ]struct {}
15
- }
16
-
17
- type IBuilder interface {
18
- buildBlock (simBundles []types.SimulatedBundle , transactions map [common.Address ]types.Transactions ) (* environment , []types.SimulatedBundle )
19
- }
20
-
21
11
// / To use it:
22
12
// / 1. Copy relevant data from the worker
23
13
// / 2. Call buildBlock
@@ -37,14 +27,8 @@ func newGreedyBuilder(chain *core.BlockChain, chainConfig *params.ChainConfig, b
37
27
}
38
28
}
39
29
40
- func (b * greedyBuilder ) buildBlock (simBundles []types.SimulatedBundle , transactions map [common.Address ]types.Transactions ) (* environment , []types.SimulatedBundle ) {
41
-
42
- env := b .inputEnvironment .copy ()
43
-
44
- orders := types .NewTransactionsByPriceAndNonce (env .signer , transactions , simBundles , env .header .BaseFee )
45
- envDiff := newEnvironmentDiff (env )
46
-
47
- usedBundles := make ([]types.SimulatedBundle , 0 )
30
+ func (b * greedyBuilder ) mergeOrdersIntoEnvDiff (envDiff * environmentDiff , orders * types.TransactionsByPriceAndNonce ) []types.SimulatedBundle {
31
+ usedBundles := []types.SimulatedBundle {}
48
32
49
33
for {
50
34
order := orders .Peek ()
@@ -65,7 +49,7 @@ func (b *greedyBuilder) buildBlock(simBundles []types.SimulatedBundle, transacti
65
49
log .Trace ("could not apply tx" , "hash" , order .Tx .Hash (), "err" , err )
66
50
continue
67
51
}
68
- effGapPrice , err := order .Tx .EffectiveGasTip (env .header .BaseFee )
52
+ effGapPrice , err := order .Tx .EffectiveGasTip (envDiff . baseEnvironment .header .BaseFee )
69
53
if err == nil {
70
54
log .Trace ("Included tx" , "EGP" , effGapPrice .String (), "gasUsed" , receipt .GasUsed )
71
55
}
@@ -84,6 +68,13 @@ func (b *greedyBuilder) buildBlock(simBundles []types.SimulatedBundle, transacti
84
68
}
85
69
}
86
70
71
+ return usedBundles
72
+ }
73
+
74
+ func (b * greedyBuilder ) buildBlock (simBundles []types.SimulatedBundle , transactions map [common.Address ]types.Transactions ) (* environment , []types.SimulatedBundle ) {
75
+ orders := types .NewTransactionsByPriceAndNonce (b .inputEnvironment .signer , transactions , simBundles , b .inputEnvironment .header .BaseFee )
76
+ envDiff := newEnvironmentDiff (b .inputEnvironment .copy ())
77
+ usedBundles := b .mergeOrdersIntoEnvDiff (envDiff , orders )
87
78
envDiff .applyToBaseEnv ()
88
- return env , usedBundles
79
+ return envDiff . baseEnvironment , usedBundles
89
80
}
0 commit comments