From 7f596e16b3fe0cd377a25d0790bfe24ab274a92e Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Mon, 21 Feb 2022 14:45:10 +0100 Subject: [PATCH] added sleep (#3561) --- ethdb/privateapi/ethbackend.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 6362f9dec..b707c10af 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -9,6 +9,7 @@ import ( "sort" "sync" "sync/atomic" + "time" "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/gointerfaces" @@ -35,6 +36,7 @@ type assemblePayloadPOSFunc func(random common.Hash, suggestedFeeRecipient commo var EthBackendAPIVersion = &types2.VersionReply{Major: 3, Minor: 0, Patch: 0} const MaxPendingPayloads = 128 +const payloadWaitTime = time.Millisecond type EthBackendServer struct { remote.UnimplementedETHBACKENDServer // must be embedded to have forward compatible implementations. @@ -269,7 +271,7 @@ func (s *EthBackendServer) EngineNewPayloadV1(ctx context.Context, req *types2.E if header.Hash() != blockHash { return &remote.EnginePayloadStatus{Status: remote.EngineStatus_INVALID_BLOCK_HASH}, nil } - + time.Sleep(payloadWaitTime) // If another payload is already commissioned then we just reply with syncing if atomic.LoadUint32(s.waitingForBeaconChain) == 0 { // We are still syncing a commissioned payload @@ -340,7 +342,7 @@ func (s *EthBackendServer) EngineForkChoiceUpdatedV1(ctx context.Context, req *r // MUST NOT begin a payload build process if forkchoiceState.headBlockHash doesn't reference a leaf of the block tree // (i.e. it references an old block). // https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.6/src/engine/specification.md#specification-1 - + time.Sleep(payloadWaitTime) if atomic.LoadUint32(s.waitingForBeaconChain) == 0 { return &remote.EngineForkChoiceUpdatedReply{ PayloadStatus: &remote.EnginePayloadStatus{Status: remote.EngineStatus_SYNCING},