Skip to content

Commit 66462eb

Browse files
authored
Revert "miner: refactor getSealingBlock method (ethereum#27993)"
This reverts commit 4c1fe06.
1 parent 73c4545 commit 66462eb

File tree

3 files changed

+14
-42
lines changed

3 files changed

+14
-42
lines changed

miner/payload_building.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,10 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) {
175175
// Build the initial version with no transaction included. It should be fast
176176
// enough to run. The empty payload can at least make sure there is something
177177
// to deliver for not missing slot.
178-
emptyParams := &generateParams{
179-
timestamp: args.Timestamp,
180-
forceTime: true,
181-
parentHash: args.Parent,
182-
coinbase: args.FeeRecipient,
183-
random: args.Random,
184-
withdrawals: args.Withdrawals,
185-
noTxs: true,
186-
}
187-
empty := w.getSealingBlock(emptyParams)
178+
empty := w.getSealingBlock(args.Parent, args.Timestamp, args.FeeRecipient, args.Random, args.Withdrawals, true)
188179
if empty.err != nil {
189180
return nil, empty.err
190181
}
191-
192182
// Construct a payload object for return.
193183
payload := newPayload(empty.block, args.Id())
194184

@@ -205,21 +195,11 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) {
205195
// by the timestamp parameter.
206196
endTimer := time.NewTimer(time.Second * 12)
207197

208-
fullParams := &generateParams{
209-
timestamp: args.Timestamp,
210-
forceTime: true,
211-
parentHash: args.Parent,
212-
coinbase: args.FeeRecipient,
213-
random: args.Random,
214-
withdrawals: args.Withdrawals,
215-
noTxs: false,
216-
}
217-
218198
for {
219199
select {
220200
case <-timer.C:
221201
start := time.Now()
222-
r := w.getSealingBlock(fullParams)
202+
r := w.getSealingBlock(args.Parent, args.Timestamp, args.FeeRecipient, args.Random, args.Withdrawals, false)
223203
if r.err == nil {
224204
payload.update(r, time.Since(start))
225205
}

miner/worker.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,17 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
11061106
// getSealingBlock generates the sealing block based on the given parameters.
11071107
// The generation result will be passed back via the given channel no matter
11081108
// the generation itself succeeds or not.
1109-
func (w *worker) getSealingBlock(params *generateParams) *newPayloadResult {
1109+
func (w *worker) getSealingBlock(parent common.Hash, timestamp uint64, coinbase common.Address, random common.Hash, withdrawals types.Withdrawals, noTxs bool) *newPayloadResult {
11101110
req := &getWorkReq{
1111-
params: params,
1111+
params: &generateParams{
1112+
timestamp: timestamp,
1113+
forceTime: true,
1114+
parentHash: parent,
1115+
coinbase: coinbase,
1116+
random: random,
1117+
withdrawals: withdrawals,
1118+
noTxs: noTxs,
1119+
},
11121120
result: make(chan *newPayloadResult, 1),
11131121
}
11141122
select {

miner/worker_test.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,7 @@ func testGetSealingWork(t *testing.T, chainConfig *params.ChainConfig, engine co
452452

453453
// This API should work even when the automatic sealing is not enabled
454454
for _, c := range cases {
455-
r := w.getSealingBlock(&generateParams{
456-
parentHash: c.parent,
457-
timestamp: timestamp,
458-
coinbase: c.coinbase,
459-
random: c.random,
460-
withdrawals: nil,
461-
noTxs: false,
462-
forceTime: true,
463-
})
455+
r := w.getSealingBlock(c.parent, timestamp, c.coinbase, c.random, nil, false)
464456
if c.expectErr {
465457
if r.err == nil {
466458
t.Error("Expect error but get nil")
@@ -476,15 +468,7 @@ func testGetSealingWork(t *testing.T, chainConfig *params.ChainConfig, engine co
476468
// This API should work even when the automatic sealing is enabled
477469
w.start()
478470
for _, c := range cases {
479-
r := w.getSealingBlock(&generateParams{
480-
parentHash: c.parent,
481-
timestamp: timestamp,
482-
coinbase: c.coinbase,
483-
random: c.random,
484-
withdrawals: nil,
485-
noTxs: false,
486-
forceTime: true,
487-
})
471+
r := w.getSealingBlock(c.parent, timestamp, c.coinbase, c.random, nil, false)
488472
if c.expectErr {
489473
if r.err == nil {
490474
t.Error("Expect error but get nil")

0 commit comments

Comments
 (0)