mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
miner: deduplicate code
This commit is contained in:
parent
5fe62fec5c
commit
a5477289a0
1 changed files with 13 additions and 14 deletions
|
|
@ -33,6 +33,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
// BuildPayloadArgs contains the provided parameters for building payload.
|
||||
|
|
@ -305,13 +306,7 @@ func (miner *Miner) buildPayload(ctx context.Context, args *BuildPayloadArgs, wi
|
|||
// Check payload.stop first to avoid an unnecessary generateWork.
|
||||
select {
|
||||
case <-payload.stop:
|
||||
payload.lock.Lock()
|
||||
emptyDelivered := payload.full == nil
|
||||
payload.lock.Unlock()
|
||||
bSpan.SetAttributes(
|
||||
telemetry.StringAttribute("exit.reason", "delivery"),
|
||||
telemetry.BoolAttribute("empty.delivered", emptyDelivered),
|
||||
)
|
||||
payload.updateSpanForDelivery(bSpan)
|
||||
log.Info("Stopping work on payload", "id", payload.id, "reason", "delivery")
|
||||
return
|
||||
default:
|
||||
|
|
@ -321,13 +316,7 @@ func (miner *Miner) buildPayload(ctx context.Context, args *BuildPayloadArgs, wi
|
|||
miner.runBuildIteration(bCtx, start, iteration, payload, fullParams, witness)
|
||||
timer.Reset(max(0, miner.config.Recommit-time.Since(start)))
|
||||
case <-payload.stop:
|
||||
payload.lock.Lock()
|
||||
emptyDelivered := payload.full == nil
|
||||
payload.lock.Unlock()
|
||||
bSpan.SetAttributes(
|
||||
telemetry.StringAttribute("exit.reason", "delivery"),
|
||||
telemetry.BoolAttribute("empty.delivered", emptyDelivered),
|
||||
)
|
||||
payload.updateSpanForDelivery(bSpan)
|
||||
log.Info("Stopping work on payload", "id", payload.id, "reason", "delivery")
|
||||
return
|
||||
case <-endTimer.C:
|
||||
|
|
@ -340,6 +329,16 @@ func (miner *Miner) buildPayload(ctx context.Context, args *BuildPayloadArgs, wi
|
|||
return payload, nil
|
||||
}
|
||||
|
||||
func (p *Payload) updateSpanForDelivery(bSpan trace.Span) {
|
||||
p.lock.Lock()
|
||||
emptyDelivered := p.full == nil
|
||||
p.lock.Unlock()
|
||||
bSpan.SetAttributes(
|
||||
telemetry.StringAttribute("exit.reason", "delivery"),
|
||||
telemetry.BoolAttribute("empty.delivered", emptyDelivered),
|
||||
)
|
||||
}
|
||||
|
||||
// BuildTestingPayload is for testing_buildBlockV*. It creates a block with the exact content given
|
||||
// by the parameters instead of using the locally available transactions.
|
||||
func (miner *Miner) BuildTestingPayload(args *BuildPayloadArgs, transactions []*types.Transaction, empty bool, extraData []byte) (*engine.ExecutionPayloadEnvelope, error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue